aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2005-11-10 09:17:23 +0000
committerMartin Willi <martin@strongswan.org>2005-11-10 09:17:23 +0000
commit67a57dc6f4f0eaec37e9e4b71be91595d1c5d2ac (patch)
tree52612eee7347913592e39abb07dc5f830c1bc4e4
parentd62ea0ddf28d8785fc9ed7cfee801c6705c68754 (diff)
downloadstrongswan-67a57dc6f4f0eaec37e9e4b71be91595d1c5d2ac.tar.bz2
strongswan-67a57dc6f4f0eaec37e9e4b71be91595d1c5d2ac.tar.xz
- removed strongswan includes, we are now self-contained ;-)
-rw-r--r--Source/charon/configuration.c3
-rw-r--r--Source/charon/daemon.c3
-rw-r--r--Source/charon/encodings.c9
-rw-r--r--Source/charon/encodings.h5
-rw-r--r--Source/charon/encodings/ike_header.h3
-rw-r--r--Source/charon/event_queue.c3
-rw-r--r--Source/charon/generator.c3
-rw-r--r--Source/charon/ike_sa_id.c3
-rw-r--r--Source/charon/ike_sa_id.h4
-rw-r--r--Source/charon/job.c3
-rw-r--r--Source/charon/job_queue.c3
-rw-r--r--Source/charon/linked_list.c3
-rw-r--r--Source/charon/linked_list.h4
-rw-r--r--Source/charon/logger.h5
-rw-r--r--Source/charon/message.c3
-rw-r--r--Source/charon/packet.h3
-rw-r--r--Source/charon/parser.c3
-rw-r--r--Source/charon/receiver.c3
-rw-r--r--Source/charon/scheduler.c3
-rw-r--r--Source/charon/sender.c3
-rw-r--r--Source/charon/socket.c3
-rw-r--r--Source/charon/tester.c3
-rw-r--r--Source/charon/tester.h4
-rw-r--r--Source/charon/tests/generator_test.c3
-rw-r--r--Source/charon/tests/job_queue_test.c3
-rw-r--r--Source/charon/thread_pool.c28
26 files changed, 28 insertions, 88 deletions
diff --git a/Source/charon/configuration.c b/Source/charon/configuration.c
index 46e961cb4..ae57b5c58 100644
--- a/Source/charon/configuration.c
+++ b/Source/charon/configuration.c
@@ -23,9 +23,6 @@
*/
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "types.h"
diff --git a/Source/charon/daemon.c b/Source/charon/daemon.c
index fb50c8e5b..269cf75a9 100644
--- a/Source/charon/daemon.c
+++ b/Source/charon/daemon.c
@@ -21,9 +21,6 @@
*/
#include <stdio.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "types.h"
#include "tester.h"
diff --git a/Source/charon/encodings.c b/Source/charon/encodings.c
index 26170bddd..99b272211 100644
--- a/Source/charon/encodings.c
+++ b/Source/charon/encodings.c
@@ -25,9 +25,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
- #include "encodings.h"
- #include "encodings/ike_header.h"
+
+#include <stdlib.h>
+
+#include "types.h"
+#include "encodings.h"
+#include "encodings/ike_header.h"
extern payload_info_t ike_header_info;
diff --git a/Source/charon/encodings.h b/Source/charon/encodings.h
index 232ec13ac..7eda87c0a 100644
--- a/Source/charon/encodings.h
+++ b/Source/charon/encodings.h
@@ -29,9 +29,8 @@
#ifndef ENCODINGS_H_
#define ENCODINGS_H_
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
+#include "types.h"
+
/**
* @brief All different kinds of encoding types.
diff --git a/Source/charon/encodings/ike_header.h b/Source/charon/encodings/ike_header.h
index 58b4348f6..22978a756 100644
--- a/Source/charon/encodings/ike_header.h
+++ b/Source/charon/encodings/ike_header.h
@@ -25,9 +25,6 @@
#ifndef IKE_HEADER_H_
#define IKE_HEADER_H_
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
/**
* Data structure to hold the data of an IKEv2-Header
diff --git a/Source/charon/event_queue.c b/Source/charon/event_queue.c
index 120efd2a3..a6c1197c8 100644
--- a/Source/charon/event_queue.c
+++ b/Source/charon/event_queue.c
@@ -20,9 +20,6 @@
* for more details.
*/
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include <pthread.h>
#include <stdlib.h>
diff --git a/Source/charon/generator.c b/Source/charon/generator.c
index 83c4b4ad8..5d852c50b 100644
--- a/Source/charon/generator.c
+++ b/Source/charon/generator.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
#include <string.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "types.h"
diff --git a/Source/charon/ike_sa_id.c b/Source/charon/ike_sa_id.c
index 3634c829c..800dba816 100644
--- a/Source/charon/ike_sa_id.c
+++ b/Source/charon/ike_sa_id.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
#include <string.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "types.h"
diff --git a/Source/charon/ike_sa_id.h b/Source/charon/ike_sa_id.h
index eaaa8112b..9d504951f 100644
--- a/Source/charon/ike_sa_id.h
+++ b/Source/charon/ike_sa_id.h
@@ -24,10 +24,6 @@
#ifndef IKE_SA_ID_H_
#define IKE_SA_ID_H_
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
-
#include "types.h"
/**
diff --git a/Source/charon/job.c b/Source/charon/job.c
index 5332cc84e..557961df2 100644
--- a/Source/charon/job.c
+++ b/Source/charon/job.c
@@ -21,9 +21,6 @@
*/
#include <stdlib.h>
- #include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "job.h"
diff --git a/Source/charon/job_queue.c b/Source/charon/job_queue.c
index aeb0da950..d14289bb0 100644
--- a/Source/charon/job_queue.c
+++ b/Source/charon/job_queue.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
#include <pthread.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "job_queue.h"
diff --git a/Source/charon/linked_list.c b/Source/charon/linked_list.c
index 036116505..e1a5157e6 100644
--- a/Source/charon/linked_list.c
+++ b/Source/charon/linked_list.c
@@ -21,9 +21,6 @@
*/
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "linked_list.h"
diff --git a/Source/charon/linked_list.h b/Source/charon/linked_list.h
index 8a8dbc212..2b900a469 100644
--- a/Source/charon/linked_list.h
+++ b/Source/charon/linked_list.h
@@ -23,10 +23,6 @@
#ifndef LINKED_LIST_H_
#define LINKED_LIST_H_
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
-
#include "types.h"
/**
diff --git a/Source/charon/logger.h b/Source/charon/logger.h
index 076944b8e..7833120b2 100644
--- a/Source/charon/logger.h
+++ b/Source/charon/logger.h
@@ -23,11 +23,6 @@
#ifndef LOGGER_H_
#define LOGGER_H_
-
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
-
#include "types.h"
/**
diff --git a/Source/charon/message.c b/Source/charon/message.c
index 1651d9daf..1dc5a15ac 100644
--- a/Source/charon/message.c
+++ b/Source/charon/message.c
@@ -21,9 +21,6 @@
*/
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "types.h"
diff --git a/Source/charon/packet.h b/Source/charon/packet.h
index ca8ea1323..8e5f9e9f8 100644
--- a/Source/charon/packet.h
+++ b/Source/charon/packet.h
@@ -31,9 +31,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
/**
diff --git a/Source/charon/parser.c b/Source/charon/parser.c
index dd9d649bf..0f4af57d9 100644
--- a/Source/charon/parser.c
+++ b/Source/charon/parser.c
@@ -21,9 +21,6 @@
*/
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "types.h"
diff --git a/Source/charon/receiver.c b/Source/charon/receiver.c
index abbb5cf8d..93a4adb02 100644
--- a/Source/charon/receiver.c
+++ b/Source/charon/receiver.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
#include <pthread.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "receiver.h"
diff --git a/Source/charon/scheduler.c b/Source/charon/scheduler.c
index 7a00bc88f..f8692fbd7 100644
--- a/Source/charon/scheduler.c
+++ b/Source/charon/scheduler.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
#include <pthread.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "scheduler.h"
diff --git a/Source/charon/sender.c b/Source/charon/sender.c
index 20d301f5e..a0118bf95 100644
--- a/Source/charon/sender.c
+++ b/Source/charon/sender.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
#include <pthread.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "sender.h"
diff --git a/Source/charon/socket.c b/Source/charon/socket.c
index 5b6ad2f8c..e650cd83d 100644
--- a/Source/charon/socket.c
+++ b/Source/charon/socket.c
@@ -28,9 +28,6 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "allocator.h"
#include "socket.h"
diff --git a/Source/charon/tester.c b/Source/charon/tester.c
index 09c0989ef..938ca46bd 100644
--- a/Source/charon/tester.c
+++ b/Source/charon/tester.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include <string.h>
#include <pthread.h>
#include <sys/time.h>
diff --git a/Source/charon/tester.h b/Source/charon/tester.h
index 498ab412e..3a90baae6 100644
--- a/Source/charon/tester.h
+++ b/Source/charon/tester.h
@@ -24,12 +24,10 @@
#define TESTER_H_
#include <stdio.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "types.h"
+
/**
* @brief Specifies a test
*/
diff --git a/Source/charon/tests/generator_test.c b/Source/charon/tests/generator_test.c
index 228d50184..2f6fa47f9 100644
--- a/Source/charon/tests/generator_test.c
+++ b/Source/charon/tests/generator_test.c
@@ -21,9 +21,6 @@
*/
#include <string.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include "../allocator.h"
#include "generator_test.h"
diff --git a/Source/charon/tests/job_queue_test.c b/Source/charon/tests/job_queue_test.c
index 8ea291b7e..63fbb458f 100644
--- a/Source/charon/tests/job_queue_test.c
+++ b/Source/charon/tests/job_queue_test.c
@@ -22,9 +22,6 @@
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include <pthread.h>
#include <unistd.h>
diff --git a/Source/charon/thread_pool.c b/Source/charon/thread_pool.c
index ec3d05cfb..0231d1f7c 100644
--- a/Source/charon/thread_pool.c
+++ b/Source/charon/thread_pool.c
@@ -21,12 +21,12 @@
*/
#include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
#include <pthread.h>
+#include <string.h>
+#include <errno.h>
#include "allocator.h"
+#include "logger.h"
#include "thread_pool.h"
#include "job_queue.h"
#include "globals.h"
@@ -47,6 +47,10 @@ typedef struct {
* array of thread ids
*/
pthread_t *threads;
+ /**
+ * logger of the threadpool
+ */
+ logger_t *logger;
} private_thread_pool_t;
@@ -83,13 +87,15 @@ static status_t destroy(private_thread_pool_t *this)
{
int current;
/* flag thread for termination */
- for (current = 0; current < this->pool_size; current++) {
+ for (current = 0; current < this->pool_size; current++) {
+ this->logger->log(this->logger, CONTROL, "cancelling thread %u", this->threads[current]);
pthread_cancel(this->threads[current]);
}
/* wait for all threads */
for (current = 0; current < this->pool_size; current++) {
pthread_join(this->threads[current], NULL);
+ this->logger->log(this->logger, CONTROL, "thread %u terminated", this->threads[current]);
}
/* free mem */
@@ -113,19 +119,23 @@ thread_pool_t *thread_pool_create(size_t pool_size)
this->pool_size = pool_size;
this->threads = allocator_alloc(sizeof(pthread_t) * pool_size);
-
+ this->logger = logger_create("thread_pool", 0);
/* try to create as many threads as possible, up tu pool_size */
for (current = 0; current < pool_size; current++) {
- if (pthread_create(&(this->threads[current]), NULL, (void*(*)(void*))job_processing, this)) {
- /* did we get any? */
- if (current == 0) {
-
+ if (pthread_create(&(this->threads[current]), NULL, (void*(*)(void*))job_processing, this))
+ {
+ /* did we get any? */
+ if (current == 0)
+ {
+ this->logger->log(this->logger, CONTROL, "could not create any thread: %s\n", strerror(errno));
allocator_free(this->threads);
allocator_free(this);
return NULL;
}
/* not all threads could be created, but at least one :-/ */
+ this->logger->log(this->logger, CONTROL, "could only create %d from requested %d threads: %s\n", current, pool_size, strerror(errno));
+
this->pool_size = current;
return (thread_pool_t*)this;
}