Use CRITICAL job priority class for long running dispatcher jobs

This commit is contained in:
Martin Willi 2011-05-05 10:51:11 +02:00
parent 1c8f58adb9
commit 14bf2f689d
25 changed files with 54 additions and 50 deletions

View File

@ -478,8 +478,8 @@ receiver_t *receiver_create()
this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret); this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret);
memcpy(this->secret_old, this->secret, SECRET_LENGTH); memcpy(this->secret_old, this->secret, SECRET_LENGTH);
this->job = callback_job_create((callback_job_cb_t)receive_packets, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_packets,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -183,8 +183,8 @@ sender_t * sender_create()
.mutex = mutex_create(MUTEX_TYPE_DEFAULT), .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
.got = condvar_create(CONDVAR_TYPE_DEFAULT), .got = condvar_create(CONDVAR_TYPE_DEFAULT),
.sent = condvar_create(CONDVAR_TYPE_DEFAULT), .sent = condvar_create(CONDVAR_TYPE_DEFAULT),
.job = callback_job_create((callback_job_cb_t)send_packets, .job = callback_job_create_with_prio((callback_job_cb_t)send_packets,
this, NULL, NULL), this, NULL, NULL, JOB_PRIO_CRITICAL),
.send_delay = lib->settings->get_int(lib->settings, .send_delay = lib->settings->get_int(lib->settings,
"charon.send_delay", 0), "charon.send_delay", 0),
.send_delay_type = lib->settings->get_int(lib->settings, .send_delay_type = lib->settings->get_int(lib->settings,

View File

@ -760,8 +760,8 @@ dhcp_socket_t *dhcp_socket_create()
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive_dhcp, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_dhcp,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -203,8 +203,8 @@ duplicheck_notify_t *duplicheck_notify_create()
destroy(this); destroy(this);
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive, this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -189,8 +189,8 @@ farp_spoofer_t *farp_spoofer_create(farp_listener_t *listener)
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive_arp, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_arp,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -355,8 +355,8 @@ ha_cache_t *ha_cache_create(ha_kernel_t *kernel, ha_socket_t *socket,
{ {
/* request a resync as soon as we are up */ /* request a resync as soon as we are up */
lib->scheduler->schedule_job(lib->scheduler, (job_t*) lib->scheduler->schedule_job(lib->scheduler, (job_t*)
callback_job_create((callback_job_cb_t)request_resync, callback_job_create_with_prio((callback_job_cb_t)request_resync,
this, NULL, NULL), 1); this, NULL, NULL, JOB_PRIO_CRITICAL), 1);
} }
return &this->public; return &this->public;
} }

View File

@ -141,8 +141,8 @@ ha_ctl_t *ha_ctl_create(ha_segments_t *segments, ha_cache_t *cache)
strerror(errno)); strerror(errno));
} }
this->job = callback_job_create((callback_job_cb_t)dispatch_fifo, this->job = callback_job_create_with_prio((callback_job_cb_t)dispatch_fifo,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;
} }

View File

@ -872,8 +872,8 @@ ha_dispatcher_t *ha_dispatcher_create(ha_socket_t *socket,
.kernel = kernel, .kernel = kernel,
.attr = attr, .attr = attr,
); );
this->job = callback_job_create((callback_job_cb_t)dispatch, this->job = callback_job_create_with_prio((callback_job_cb_t)dispatch,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -280,8 +280,8 @@ static job_requeue_t watchdog(private_ha_segments_t *this)
*/ */
static void start_watchdog(private_ha_segments_t *this) static void start_watchdog(private_ha_segments_t *this)
{ {
this->job = callback_job_create((callback_job_cb_t)watchdog, this->job = callback_job_create_with_prio((callback_job_cb_t)watchdog,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
} }

View File

@ -105,8 +105,8 @@ METHOD(ha_socket_t, push, void,
.fd = this->fd, .fd = this->fd,
); );
job = callback_job_create((callback_job_cb_t)send_message, job = callback_job_create_with_prio((callback_job_cb_t)send_message,
data, (void*)job_data_destroy, NULL); data, (void*)job_data_destroy, NULL, JOB_PRIO_HIGH);
lib->processor->queue_job(lib->processor, (job_t*)job); lib->processor->queue_job(lib->processor, (job_t*)job);
return; return;
} }

View File

@ -156,9 +156,9 @@ static void blink_activity(private_led_listener_t *this)
{ {
set_led(this->activity, this->activity_max); set_led(this->activity, this->activity_max);
} }
lib->scheduler->schedule_job_ms(lib->scheduler, lib->scheduler->schedule_job_ms(lib->scheduler, (job_t*)
(job_t*)callback_job_create((callback_job_cb_t)reset_activity_led, callback_job_create_with_prio((callback_job_cb_t)reset_activity_led,
this, NULL, NULL), this->blink_time); this, NULL, NULL, JOB_PRIO_CRITICAL), this->blink_time);
this->mutex->unlock(this->mutex); this->mutex->unlock(this->mutex);
} }
} }

View File

@ -235,9 +235,9 @@ plugin_t *load_tester_plugin_create()
this->running = 0; this->running = 0;
for (i = 0; i < this->initiators; i++) for (i = 0; i < this->initiators; i++)
{ {
lib->processor->queue_job(lib->processor, lib->processor->queue_job(lib->processor, (job_t*)
(job_t*)callback_job_create((callback_job_cb_t)do_load_test, callback_job_create_with_prio((callback_job_cb_t)do_load_test,
this, NULL, NULL)); this, NULL, NULL, JOB_PRIO_CRITICAL));
} }
return &this->public.plugin; return &this->public.plugin;
} }

View File

@ -502,7 +502,8 @@ maemo_service_t *maemo_service_create()
} }
lib->processor->queue_job(lib->processor, lib->processor->queue_job(lib->processor,
(job_t*)callback_job_create((callback_job_cb_t)run, this, NULL, NULL)); (job_t*)callback_job_create_with_prio((callback_job_cb_t)run,
this, NULL, NULL, JOB_PRIO_CRITICAL));
return &this->public; return &this->public;
} }

View File

@ -134,7 +134,8 @@ plugin_t *nm_plugin_create()
charon->keep_cap(charon, CAP_DAC_OVERRIDE); charon->keep_cap(charon, CAP_DAC_OVERRIDE);
lib->processor->queue_job(lib->processor, lib->processor->queue_job(lib->processor,
(job_t*)callback_job_create((callback_job_cb_t)run, this, NULL, NULL)); (job_t*)callback_job_create_with_prio((callback_job_cb_t)run,
this, NULL, NULL, JOB_PRIO_CRITICAL));
return &this->public.plugin; return &this->public.plugin;
} }

View File

@ -774,7 +774,8 @@ plugin_t *smp_plugin_create()
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)dispatch, this, NULL, NULL); this->job = callback_job_create_with_prio((callback_job_cb_t)dispatch,
this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public.plugin; return &this->public.plugin;

View File

@ -625,8 +625,8 @@ static job_requeue_t receive(private_stroke_socket_t *this)
ctx = malloc_thing(stroke_job_context_t); ctx = malloc_thing(stroke_job_context_t);
ctx->fd = strokefd; ctx->fd = strokefd;
ctx->this = this; ctx->this = this;
job = callback_job_create((callback_job_cb_t)process, job = callback_job_create_with_prio((callback_job_cb_t)process,
ctx, (void*)stroke_job_context_destroy, this->job); ctx, (void*)stroke_job_context_destroy, this->job, JOB_PRIO_HIGH);
lib->processor->queue_job(lib->processor, (job_t*)job); lib->processor->queue_job(lib->processor, (job_t*)job);
return JOB_REQUEUE_FAIR; return JOB_REQUEUE_FAIR;
@ -723,8 +723,8 @@ stroke_socket_t *stroke_socket_create()
charon->backends->add_backend(charon->backends, &this->config->backend); charon->backends->add_backend(charon->backends, &this->config->backend);
hydra->attributes->add_provider(hydra->attributes, &this->attribute->provider); hydra->attributes->add_provider(hydra->attributes, &this->attribute->provider);
this->job = callback_job_create((callback_job_cb_t)receive, this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -294,8 +294,8 @@ uci_control_t *uci_control_create()
} }
else else
{ {
this->job = callback_job_create((callback_job_cb_t)receive, this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
} }
return &this->public; return &this->public;

View File

@ -225,8 +225,8 @@ whitelist_control_t *whitelist_control_create(whitelist_listener_t *listener)
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive, this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -2634,8 +2634,8 @@ kernel_klips_ipsec_t *kernel_klips_ipsec_create()
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive_events, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -2321,8 +2321,8 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
destroy(this); destroy(this);
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive_events, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -1537,8 +1537,8 @@ kernel_netlink_net_t *kernel_netlink_net_create()
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive_events, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
if (init_address_list(this) != SUCCESS) if (init_address_list(this) != SUCCESS)

View File

@ -2172,8 +2172,8 @@ kernel_pfkey_ipsec_t *kernel_pfkey_ipsec_create()
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive_events, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;

View File

@ -710,8 +710,8 @@ kernel_pfroute_net_t *kernel_pfroute_net_create()
return NULL; return NULL;
} }
this->job = callback_job_create((callback_job_cb_t)receive_events, this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
this, NULL, NULL); this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
if (init_address_list(this) != SUCCESS) if (init_address_list(this) != SUCCESS)

View File

@ -392,8 +392,8 @@ pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb,
while (enumerator->enumerate(enumerator, &entry)) while (enumerator->enumerate(enumerator, &entry))
{ {
query_slots(entry); query_slots(entry);
entry->job = callback_job_create((void*)dispatch_slot_events, entry->job = callback_job_create_with_prio((void*)dispatch_slot_events,
entry, (void*)end_dispatch, NULL); entry, (void*)end_dispatch, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)entry->job); lib->processor->queue_job(lib->processor, (job_t*)entry->job);
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);

View File

@ -341,7 +341,8 @@ scheduler_t * scheduler_create()
this->heap = (event_t**)calloc(this->heap_size + 1, sizeof(event_t*)); this->heap = (event_t**)calloc(this->heap_size + 1, sizeof(event_t*));
this->job = callback_job_create((callback_job_cb_t)schedule, this, NULL, NULL); this->job = callback_job_create_with_prio((callback_job_cb_t)schedule,
this, NULL, NULL, JOB_PRIO_CRITICAL);
lib->processor->queue_job(lib->processor, (job_t*)this->job); lib->processor->queue_job(lib->processor, (job_t*)this->job);
return &this->public; return &this->public;