- removed strongswan includes, we are now self-contained ;-)
authorMartin Willi <martin@strongswan.org>
Thu, 10 Nov 2005 09:17:23 +0000 (09:17 -0000)
committerMartin Willi <martin@strongswan.org>
Thu, 10 Nov 2005 09:17:23 +0000 (09:17 -0000)
26 files changed:
Source/charon/configuration.c
Source/charon/daemon.c
Source/charon/encodings.c
Source/charon/encodings.h
Source/charon/encodings/ike_header.h
Source/charon/event_queue.c
Source/charon/generator.c
Source/charon/ike_sa_id.c
Source/charon/ike_sa_id.h
Source/charon/job.c
Source/charon/job_queue.c
Source/charon/linked_list.c
Source/charon/linked_list.h
Source/charon/logger.h
Source/charon/message.c
Source/charon/packet.h
Source/charon/parser.c
Source/charon/receiver.c
Source/charon/scheduler.c
Source/charon/sender.c
Source/charon/socket.c
Source/charon/tester.c
Source/charon/tester.h
Source/charon/tests/generator_test.c
Source/charon/tests/job_queue_test.c
Source/charon/thread_pool.c

index 46e961c..ae57b5c 100644 (file)
@@ -23,9 +23,6 @@
  */
 
 #include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
 
 #include "allocator.h"
 #include "types.h"
index fb50c8e..269cf75 100644 (file)
@@ -21,9 +21,6 @@
  */
  
 #include <stdio.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
  
 #include "types.h"
 #include "tester.h"
index 26170bd..99b2722 100644 (file)
  * 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;
 
index 232ec13..7eda87c 100644 (file)
@@ -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. 
index 58b4348..22978a7 100644 (file)
@@ -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
index 120efd2..a6c1197 100644 (file)
@@ -20,9 +20,6 @@
  * for more details.
  */
 
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
 #include <pthread.h>
 #include <stdlib.h>
 
index 83c4b4a..5d852c5 100644 (file)
@@ -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"
index 3634c82..800dba8 100644 (file)
@@ -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"
index eaaa811..9d50495 100644 (file)
 #ifndef IKE_SA_ID_H_
 #define IKE_SA_ID_H_
 
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
-
 #include "types.h"
 
 /**
index 5332cc8..557961d 100644 (file)
@@ -21,9 +21,6 @@
  */
 
 #include <stdlib.h>
- #include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
 
 #include "allocator.h"
  #include "job.h"
index aeb0da9..d14289b 100644 (file)
@@ -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"
index 0361165..e1a5157 100644 (file)
@@ -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"
index 8a8dbc2..2b900a4 100644 (file)
 #ifndef LINKED_LIST_H_
 #define LINKED_LIST_H_
 
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
-
 #include "types.h"
 
 /**
index 076944b..7833120 100644 (file)
 #ifndef LOGGER_H_
 #define LOGGER_H_
 
-
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
-
 #include "types.h"
 
 /**
index 1651d9d..1dc5a15 100644 (file)
@@ -21,9 +21,6 @@
  */
 
 #include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
 
 #include "allocator.h"
 #include "types.h"
index ca8ea13..8e5f9e9 100644 (file)
@@ -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>
 
 
 /**
index dd9d649..0f4af57 100644 (file)
@@ -21,9 +21,6 @@
  */
 
 #include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
 
 #include "allocator.h"
 #include "types.h"
index abbb5cf..93a4adb 100644 (file)
@@ -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"
index 7a00bc8..f8692fb 100644 (file)
@@ -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"
index 20d301f..a0118bf 100644 (file)
@@ -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"
index 5b6ad2f..e650cd8 100644 (file)
@@ -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"
index 09c0989..938ca46 100644 (file)
@@ -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>
index 498ab41..3a90baa 100644 (file)
 #define TESTER_H_ 
 
 #include <stdio.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
 
 #include "types.h"
 
+
 /**
  * @brief Specifies a test
  */
index 228d501..2f6fa47 100644 (file)
@@ -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"
index 8ea291b..63fbb45 100644 (file)
@@ -22,9 +22,6 @@
 
 
 #include <stdlib.h>
-#include <freeswan.h>
-#include <pluto/constants.h>
-#include <pluto/defs.h>
 #include <pthread.h>
 #include <unistd.h>
 
index ec3d05c..0231d1f 100644 (file)
  */
  
 #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;
                }