- removed strongswan includes, we are now self-contained ;-)

This commit is contained in:
Martin Willi
2005-11-10 09:17:23 +00:00
parent d62ea0ddf2
commit 67a57dc6f4
26 changed files with 28 additions and 88 deletions
-3
View File
@@ -23,9 +23,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "types.h" #include "types.h"
-3
View File
@@ -21,9 +21,6 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "types.h" #include "types.h"
#include "tester.h" #include "tester.h"
+6 -3
View File
@@ -25,9 +25,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details. * for more details.
*/ */
#include "encodings.h" #include <stdlib.h>
#include "encodings/ike_header.h"
#include "types.h"
#include "encodings.h"
#include "encodings/ike_header.h"
extern payload_info_t ike_header_info; extern payload_info_t ike_header_info;
+2 -3
View File
@@ -29,9 +29,8 @@
#ifndef ENCODINGS_H_ #ifndef ENCODINGS_H_
#define ENCODINGS_H_ #define ENCODINGS_H_
#include <freeswan.h> #include "types.h"
#include <pluto/constants.h>
#include <pluto/defs.h>
/** /**
* @brief All different kinds of encoding types. * @brief All different kinds of encoding types.
-3
View File
@@ -25,9 +25,6 @@
#ifndef IKE_HEADER_H_ #ifndef IKE_HEADER_H_
#define 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 * Data structure to hold the data of an IKEv2-Header
-3
View File
@@ -20,9 +20,6 @@
* for more details. * for more details.
*/ */
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include <pthread.h> #include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "types.h" #include "types.h"
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "types.h" #include "types.h"
-4
View File
@@ -24,10 +24,6 @@
#ifndef IKE_SA_ID_H_ #ifndef IKE_SA_ID_H_
#define IKE_SA_ID_H_ #define IKE_SA_ID_H_
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "types.h" #include "types.h"
/** /**
-3
View File
@@ -21,9 +21,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "job.h" #include "job.h"
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "job_queue.h" #include "job_queue.h"
-3
View File
@@ -21,9 +21,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "linked_list.h" #include "linked_list.h"
-4
View File
@@ -23,10 +23,6 @@
#ifndef LINKED_LIST_H_ #ifndef LINKED_LIST_H_
#define LINKED_LIST_H_ #define LINKED_LIST_H_
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "types.h" #include "types.h"
/** /**
-5
View File
@@ -23,11 +23,6 @@
#ifndef LOGGER_H_ #ifndef LOGGER_H_
#define LOGGER_H_ #define LOGGER_H_
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "types.h" #include "types.h"
/** /**
-3
View File
@@ -21,9 +21,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "types.h" #include "types.h"
-3
View File
@@ -31,9 +31,6 @@
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
/** /**
-3
View File
@@ -21,9 +21,6 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "types.h" #include "types.h"
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "receiver.h" #include "receiver.h"
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "scheduler.h" #include "scheduler.h"
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <pthread.h> #include <pthread.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "sender.h" #include "sender.h"
-3
View File
@@ -28,9 +28,6 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "allocator.h" #include "allocator.h"
#include "socket.h" #include "socket.h"
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include <string.h> #include <string.h>
#include <pthread.h> #include <pthread.h>
#include <sys/time.h> #include <sys/time.h>
+1 -3
View File
@@ -24,12 +24,10 @@
#define TESTER_H_ #define TESTER_H_
#include <stdio.h> #include <stdio.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "types.h" #include "types.h"
/** /**
* @brief Specifies a test * @brief Specifies a test
*/ */
-3
View File
@@ -21,9 +21,6 @@
*/ */
#include <string.h> #include <string.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include "../allocator.h" #include "../allocator.h"
#include "generator_test.h" #include "generator_test.h"
-3
View File
@@ -22,9 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include <pthread.h> #include <pthread.h>
#include <unistd.h> #include <unistd.h>
+19 -9
View File
@@ -21,12 +21,12 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <freeswan.h>
#include <pluto/constants.h>
#include <pluto/defs.h>
#include <pthread.h> #include <pthread.h>
#include <string.h>
#include <errno.h>
#include "allocator.h" #include "allocator.h"
#include "logger.h"
#include "thread_pool.h" #include "thread_pool.h"
#include "job_queue.h" #include "job_queue.h"
#include "globals.h" #include "globals.h"
@@ -47,6 +47,10 @@ typedef struct {
* array of thread ids * array of thread ids
*/ */
pthread_t *threads; pthread_t *threads;
/**
* logger of the threadpool
*/
logger_t *logger;
} private_thread_pool_t; } private_thread_pool_t;
@@ -83,13 +87,15 @@ static status_t destroy(private_thread_pool_t *this)
{ {
int current; int current;
/* flag thread for termination */ /* 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]); pthread_cancel(this->threads[current]);
} }
/* wait for all threads */ /* wait for all threads */
for (current = 0; current < this->pool_size; current++) { for (current = 0; current < this->pool_size; current++) {
pthread_join(this->threads[current], NULL); pthread_join(this->threads[current], NULL);
this->logger->log(this->logger, CONTROL, "thread %u terminated", this->threads[current]);
} }
/* free mem */ /* free mem */
@@ -113,19 +119,23 @@ thread_pool_t *thread_pool_create(size_t pool_size)
this->pool_size = pool_size; this->pool_size = pool_size;
this->threads = allocator_alloc(sizeof(pthread_t) * 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 */ /* try to create as many threads as possible, up tu pool_size */
for (current = 0; current < pool_size; current++) { for (current = 0; current < pool_size; current++) {
if (pthread_create(&(this->threads[current]), NULL, (void*(*)(void*))job_processing, this)) { if (pthread_create(&(this->threads[current]), NULL, (void*(*)(void*))job_processing, this))
/* did we get any? */ {
if (current == 0) { /* 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->threads);
allocator_free(this); allocator_free(this);
return NULL; return NULL;
} }
/* not all threads could be created, but at least one :-/ */ /* 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; this->pool_size = current;
return (thread_pool_t*)this; return (thread_pool_t*)this;
} }