aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/threads
diff options
context:
space:
mode:
Diffstat (limited to 'Source/charon/threads')
-rw-r--r--Source/charon/threads/receiver.c12
-rw-r--r--Source/charon/threads/scheduler.c12
-rw-r--r--Source/charon/threads/sender.c10
-rw-r--r--Source/charon/threads/thread_pool.c28
4 files changed, 31 insertions, 31 deletions
diff --git a/Source/charon/threads/receiver.c b/Source/charon/threads/receiver.c
index e2fb192db..e02fd89e1 100644
--- a/Source/charon/threads/receiver.c
+++ b/Source/charon/threads/receiver.c
@@ -26,7 +26,7 @@
#include "receiver.h"
-#include <globals.h>
+#include <daemon.h>
#include <network/socket.h>
#include <network/packet.h>
#include <queues/job_queue.h>
@@ -78,12 +78,12 @@ static void receive_packets(private_receiver_t * this)
while (1)
{
- while (global_socket->receive(global_socket,&current_packet) == SUCCESS)
+ while (charon->socket->receive(charon->socket,&current_packet) == SUCCESS)
{
this->logger->log(this->logger, CONTROL, "creating job from packet");
current_job = (job_t *) incoming_packet_job_create(current_packet);
- global_job_queue->add(global_job_queue,current_job);
+ charon->job_queue->add(charon->job_queue,current_job);
}
/* bad bad, rebuild the socket ? */
@@ -102,7 +102,7 @@ static void destroy(private_receiver_t *this)
pthread_join(this->assigned_thread, NULL);
this->logger->log(this->logger, CONTROL | MORE, "Receiver thread terminated");
- global_logger_manager->destroy_logger(global_logger_manager, this->logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->logger);
allocator_free(this);
}
@@ -117,12 +117,12 @@ receiver_t * receiver_create()
this->public.destroy = (void(*)(receiver_t*)) destroy;
this->receive_packets = receive_packets;
- this->logger = global_logger_manager->create_logger(global_logger_manager, RECEIVER, NULL);
+ this->logger = charon->logger_manager->create_logger(charon->logger_manager, RECEIVER, NULL);
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))this->receive_packets, this) != 0)
{
this->logger->log(this->logger, ERROR, "Receiver thread could not be started");
- global_logger_manager->destroy_logger(global_logger_manager, this->logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->logger);
allocator_free(this);
return NULL;
}
diff --git a/Source/charon/threads/scheduler.c b/Source/charon/threads/scheduler.c
index cc051e702..50271eb62 100644
--- a/Source/charon/threads/scheduler.c
+++ b/Source/charon/threads/scheduler.c
@@ -26,7 +26,7 @@
#include "scheduler.h"
-#include <globals.h>
+#include <daemon.h>
#include <definitions.h>
#include <utils/allocator.h>
#include <utils/logger_manager.h>
@@ -79,9 +79,9 @@ static void get_events(private_scheduler_t * this)
{
this->logger->log(this->logger, CONTROL|MORE, "waiting for next event...");
/* get a job, this block until one is available */
- current_job = global_event_queue->get(global_event_queue);
+ current_job = charon->event_queue->get(charon->event_queue);
/* queue the job in the job queue, workers will eat them */
- global_job_queue->add(global_job_queue, current_job);
+ charon->job_queue->add(charon->job_queue, current_job);
this->logger->log(this->logger, CONTROL, "got event, added job %s to job-queue.",
mapping_find(job_type_m, current_job->get_type(current_job)));
}
@@ -98,7 +98,7 @@ static void destroy(private_scheduler_t *this)
pthread_join(this->assigned_thread, NULL);
this->logger->log(this->logger, CONTROL | MORE, "Scheduler thread terminated");
- global_logger_manager->destroy_logger(global_logger_manager, this->logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->logger);
allocator_free(this);
}
@@ -111,13 +111,13 @@ scheduler_t * scheduler_create()
this->public.destroy = (void(*)(scheduler_t*)) destroy;
this->get_events = get_events;
- this->logger = global_logger_manager->create_logger(global_logger_manager, SCHEDULER, NULL);
+ this->logger = charon->logger_manager->create_logger(charon->logger_manager, SCHEDULER, NULL);
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))this->get_events, this) != 0)
{
/* thread could not be created */
this->logger->log(this->logger, ERROR, "Scheduler thread could not be created!");
- global_logger_manager->destroy_logger(global_logger_manager, this->logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->logger);
allocator_free(this);
return NULL;
}
diff --git a/Source/charon/threads/sender.c b/Source/charon/threads/sender.c
index bdd7ccf58..7c7180ad8 100644
--- a/Source/charon/threads/sender.c
+++ b/Source/charon/threads/sender.c
@@ -26,7 +26,7 @@
#include "sender.h"
-#include <globals.h>
+#include <daemon.h>
#include <network/socket.h>
#include <network/packet.h>
#include <queues/send_queue.h>
@@ -78,9 +78,9 @@ static void send_packets(private_sender_t * this)
while (1)
{
- current_packet = global_send_queue->get(global_send_queue);
+ current_packet = charon->send_queue->get(charon->send_queue);
this->logger->log(this->logger, CONTROL|MORE, "got a packet, sending it");
- status = global_socket->send(global_socket,current_packet);
+ status = charon->socket->send(charon->socket,current_packet);
if (status != SUCCESS)
{
this->logger->log(this->logger, ERROR, "sending failed, socket returned %s",
@@ -101,7 +101,7 @@ static void destroy(private_sender_t *this)
pthread_join(this->assigned_thread, NULL);
this->logger->log(this->logger, CONTROL | MORE, "Sender thread terminated");
- global_logger_manager->destroy_logger(global_logger_manager, this->logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->logger);
allocator_free(this);
}
@@ -116,7 +116,7 @@ sender_t * sender_create()
this->send_packets = send_packets;
this->public.destroy = (void(*)(sender_t*)) destroy;
- this->logger = global_logger_manager->create_logger(global_logger_manager, SENDER, NULL);
+ this->logger = charon->logger_manager->create_logger(charon->logger_manager, SENDER, NULL);
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))this->send_packets, this) != 0)
{
diff --git a/Source/charon/threads/thread_pool.c b/Source/charon/threads/thread_pool.c
index 58310ebc5..0157e2af3 100644
--- a/Source/charon/threads/thread_pool.c
+++ b/Source/charon/threads/thread_pool.c
@@ -28,7 +28,7 @@
#include "thread_pool.h"
-#include <globals.h>
+#include <daemon.h>
#include <queues/job_queue.h>
#include <queues/jobs/delete_ike_sa_job.h>
#include <queues/jobs/incoming_packet_job.h>
@@ -115,7 +115,7 @@ static void process_jobs(private_thread_pool_t *this)
job_t *job;
job_type_t job_type;
- job = global_job_queue->get(global_job_queue);
+ job = charon->job_queue->get(charon->job_queue);
job_type = job->get_type(job);
this->worker_logger->log(this->worker_logger, CONTROL|MORE, "got a job of type %s",
mapping_find(job_type_m,job_type));
@@ -194,7 +194,7 @@ static void process_incoming_packet_job(private_thread_pool_t *this, incoming_pa
ike_sa_id->get_responder_spi(ike_sa_id),
ike_sa_id->is_initiator(ike_sa_id) ? "initiator" : "responder");
- status = global_ike_sa_manager->checkout(global_ike_sa_manager,ike_sa_id, &ike_sa);
+ status = charon->ike_sa_manager->checkout(charon->ike_sa_manager,ike_sa_id, &ike_sa);
if (status != SUCCESS)
{
this->worker_logger->log(this->worker_logger, ERROR, "IKE SA could not be checked out");
@@ -215,7 +215,7 @@ static void process_incoming_packet_job(private_thread_pool_t *this, incoming_pa
ike_sa_id->is_initiator(ike_sa_id) ? "initiator" : "responder");
ike_sa_id->destroy(ike_sa_id);
- status = global_ike_sa_manager->checkin(global_ike_sa_manager, ike_sa);
+ status = charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
if (status != SUCCESS)
{
this->worker_logger->log(this->worker_logger, ERROR, "checkin of IKE SA failed");
@@ -240,7 +240,7 @@ static void process_initiate_ike_sa_job(private_thread_pool_t *this, initiate_ik
this->worker_logger->log(this->worker_logger, CONTROL|MOST, "create and checking out IKE SA");
- global_ike_sa_manager->create_and_checkout(global_ike_sa_manager, &ike_sa);
+ charon->ike_sa_manager->create_and_checkout(charon->ike_sa_manager, &ike_sa);
this->worker_logger->log(this->worker_logger, CONTROL|MOST, "initializing connection \"%s\"",
job->get_configuration_name(job));
@@ -249,12 +249,12 @@ static void process_initiate_ike_sa_job(private_thread_pool_t *this, initiate_ik
{
this->worker_logger->log(this->worker_logger, ERROR, "%s by initialize_conection, job and rejected, IKE_SA deleted.",
mapping_find(status_m, status));
- global_ike_sa_manager->checkin_and_delete(global_ike_sa_manager, ike_sa);
+ charon->ike_sa_manager->checkin_and_delete(charon->ike_sa_manager, ike_sa);
return;
}
this->worker_logger->log(this->worker_logger, CONTROL|MOST, "checking in IKE SA");
- status = global_ike_sa_manager->checkin(global_ike_sa_manager, ike_sa);
+ status = charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
if (status != SUCCESS)
{
this->worker_logger->log(this->worker_logger, ERROR, "%s could not checkin IKE_SA.",
@@ -275,7 +275,7 @@ static void process_delete_ike_sa_job(private_thread_pool_t *this, delete_ike_sa
ike_sa_id->get_responder_spi(ike_sa_id),
ike_sa_id->is_initiator(ike_sa_id) ? "initiator" : "responder");
- status = global_ike_sa_manager->delete(global_ike_sa_manager, ike_sa_id);
+ status = charon->ike_sa_manager->delete(charon->ike_sa_manager, ike_sa_id);
if (status != SUCCESS)
{
this->worker_logger->log(this->worker_logger, ERROR, "could not delete IKE_SA (%s)",
@@ -311,8 +311,8 @@ static void destroy(private_thread_pool_t *this)
}
/* free mem */
- global_logger_manager->destroy_logger(global_logger_manager, this->pool_logger);
- global_logger_manager->destroy_logger(global_logger_manager, this->worker_logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->pool_logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->worker_logger);
allocator_free(this->threads);
allocator_free(this);
}
@@ -338,9 +338,9 @@ thread_pool_t *thread_pool_create(size_t pool_size)
this->threads = allocator_alloc(sizeof(pthread_t) * pool_size);
- this->pool_logger = global_logger_manager->create_logger(global_logger_manager,THREAD_POOL,NULL);
+ this->pool_logger = charon->logger_manager->create_logger(charon->logger_manager,THREAD_POOL,NULL);
- this->worker_logger = global_logger_manager->create_logger(global_logger_manager,WORKER,NULL);
+ this->worker_logger = charon->logger_manager->create_logger(charon->logger_manager,WORKER,NULL);
/* try to create as many threads as possible, up tu pool_size */
for (current = 0; current < pool_size; current++)
@@ -355,8 +355,8 @@ thread_pool_t *thread_pool_create(size_t pool_size)
if (current == 0)
{
this->pool_logger->log(this->pool_logger, ERROR, "could not create any thread");
- global_logger_manager->destroy_logger(global_logger_manager, this->pool_logger);
- global_logger_manager->destroy_logger(global_logger_manager, this->worker_logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->pool_logger);
+ charon->logger_manager->destroy_logger(charon->logger_manager, this->worker_logger);
allocator_free(this->threads);
allocator_free(this);
return NULL;