Use CRITICAL job priority class for long running dispatcher jobs
authorMartin Willi <martin@revosec.ch>
Thu, 5 May 2011 08:51:11 +0000 (10:51 +0200)
committerMartin Willi <martin@revosec.ch>
Mon, 16 May 2011 13:24:15 +0000 (15:24 +0200)
25 files changed:
src/libcharon/network/receiver.c
src/libcharon/network/sender.c
src/libcharon/plugins/dhcp/dhcp_socket.c
src/libcharon/plugins/duplicheck/duplicheck_notify.c
src/libcharon/plugins/farp/farp_spoofer.c
src/libcharon/plugins/ha/ha_cache.c
src/libcharon/plugins/ha/ha_ctl.c
src/libcharon/plugins/ha/ha_dispatcher.c
src/libcharon/plugins/ha/ha_segments.c
src/libcharon/plugins/ha/ha_socket.c
src/libcharon/plugins/led/led_listener.c
src/libcharon/plugins/load_tester/load_tester_plugin.c
src/libcharon/plugins/maemo/maemo_service.c
src/libcharon/plugins/nm/nm_plugin.c
src/libcharon/plugins/smp/smp.c
src/libcharon/plugins/stroke/stroke_socket.c
src/libcharon/plugins/uci/uci_control.c
src/libcharon/plugins/whitelist/whitelist_control.c
src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
src/libhydra/plugins/kernel_netlink/kernel_netlink_ipsec.c
src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c
src/libhydra/plugins/kernel_pfkey/kernel_pfkey_ipsec.c
src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
src/libstrongswan/plugins/pkcs11/pkcs11_manager.c
src/libstrongswan/processing/scheduler.c

index e2e4d92..2887595 100644 (file)
@@ -478,8 +478,8 @@ receiver_t *receiver_create()
        this->rng->get_bytes(this->rng, SECRET_LENGTH, this->secret);
        memcpy(this->secret_old, this->secret, SECRET_LENGTH);
 
-       this->job = callback_job_create((callback_job_cb_t)receive_packets,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_packets,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index 4177fb3..4df930b 100644 (file)
@@ -183,8 +183,8 @@ sender_t * sender_create()
                .mutex = mutex_create(MUTEX_TYPE_DEFAULT),
                .got = condvar_create(CONDVAR_TYPE_DEFAULT),
                .sent = condvar_create(CONDVAR_TYPE_DEFAULT),
-               .job = callback_job_create((callback_job_cb_t)send_packets,
-                                                                       this, NULL, NULL),
+               .job = callback_job_create_with_prio((callback_job_cb_t)send_packets,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL),
                .send_delay = lib->settings->get_int(lib->settings,
                                                                                        "charon.send_delay", 0),
                .send_delay_type = lib->settings->get_int(lib->settings,
index c98d505..5d98e5b 100644 (file)
@@ -760,8 +760,8 @@ dhcp_socket_t *dhcp_socket_create()
                return NULL;
        }
 
-       this->job = callback_job_create((callback_job_cb_t)receive_dhcp,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_dhcp,
+                                                                       this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index 4e76182..b86f1ef 100644 (file)
@@ -203,8 +203,8 @@ duplicheck_notify_t *duplicheck_notify_create()
                destroy(this);
                return NULL;
        }
-       this->job = callback_job_create((callback_job_cb_t)receive,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
+                                                                       this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index a904a65..7a8ca85 100644 (file)
@@ -189,8 +189,8 @@ farp_spoofer_t *farp_spoofer_create(farp_listener_t *listener)
                return NULL;
        }
 
-       this->job = callback_job_create((callback_job_cb_t)receive_arp,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_arp,
+                                                                       this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index c27cd0b..b6525a8 100644 (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 */
                lib->scheduler->schedule_job(lib->scheduler, (job_t*)
-                                               callback_job_create((callback_job_cb_t)request_resync,
-                                                                                       this, NULL, NULL), 1);
+                       callback_job_create_with_prio((callback_job_cb_t)request_resync,
+                                                                       this, NULL, NULL, JOB_PRIO_CRITICAL), 1);
        }
        return &this->public;
 }
index 15f7824..9c99807 100644 (file)
@@ -141,8 +141,8 @@ ha_ctl_t *ha_ctl_create(ha_segments_t *segments, ha_cache_t *cache)
                         strerror(errno));
        }
 
-       this->job = callback_job_create((callback_job_cb_t)dispatch_fifo,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)dispatch_fifo,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
        return &this->public;
 }
index 0d0df8d..04267f5 100644 (file)
@@ -872,8 +872,8 @@ ha_dispatcher_t *ha_dispatcher_create(ha_socket_t *socket,
                .kernel = kernel,
                .attr = attr,
        );
-       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);
 
        return &this->public;
index 70b8d1d..c5a1806 100644 (file)
@@ -280,8 +280,8 @@ static job_requeue_t 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, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)watchdog,
+                                                                       this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 }
 
index 0861784..c02cf10 100644 (file)
@@ -105,8 +105,8 @@ METHOD(ha_socket_t, push, void,
                                .fd = this->fd,
                        );
 
-                       job = callback_job_create((callback_job_cb_t)send_message,
-                                                                         data, (void*)job_data_destroy, NULL);
+                       job = callback_job_create_with_prio((callback_job_cb_t)send_message,
+                                                       data, (void*)job_data_destroy, NULL, JOB_PRIO_HIGH);
                        lib->processor->queue_job(lib->processor, (job_t*)job);
                        return;
                }
index 18def80..4aae2ab 100644 (file)
@@ -156,9 +156,9 @@ static void blink_activity(private_led_listener_t *this)
                {
                        set_led(this->activity, this->activity_max);
                }
-               lib->scheduler->schedule_job_ms(lib->scheduler,
-                       (job_t*)callback_job_create((callback_job_cb_t)reset_activity_led,
-                                                                               this, NULL, NULL), this->blink_time);
+               lib->scheduler->schedule_job_ms(lib->scheduler, (job_t*)
+                       callback_job_create_with_prio((callback_job_cb_t)reset_activity_led,
+                                               this, NULL, NULL, JOB_PRIO_CRITICAL), this->blink_time);
                this->mutex->unlock(this->mutex);
        }
 }
index 94115e3..dbdf96f 100644 (file)
@@ -235,9 +235,9 @@ plugin_t *load_tester_plugin_create()
        this->running = 0;
        for (i = 0; i < this->initiators; i++)
        {
-               lib->processor->queue_job(lib->processor,
-                                       (job_t*)callback_job_create((callback_job_cb_t)do_load_test,
-                                                                                               this, NULL, NULL));
+               lib->processor->queue_job(lib->processor, (job_t*)
+                               callback_job_create_with_prio((callback_job_cb_t)do_load_test,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL));
        }
        return &this->public.plugin;
 }
index 0e9fd8c..d6ba8fa 100644 (file)
@@ -502,7 +502,8 @@ maemo_service_t *maemo_service_create()
        }
 
        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;
 }
index f1d3be7..fb8c16f 100644 (file)
@@ -134,7 +134,8 @@ plugin_t *nm_plugin_create()
        charon->keep_cap(charon, CAP_DAC_OVERRIDE);
 
        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;
 }
index 8fb59d3..58f98cf 100644 (file)
@@ -774,7 +774,8 @@ plugin_t *smp_plugin_create()
                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);
 
        return &this->public.plugin;
index d684680..74374ba 100644 (file)
@@ -625,8 +625,8 @@ static job_requeue_t receive(private_stroke_socket_t *this)
        ctx = malloc_thing(stroke_job_context_t);
        ctx->fd = strokefd;
        ctx->this = this;
-       job = callback_job_create((callback_job_cb_t)process,
-                                                         ctx, (void*)stroke_job_context_destroy, this->job);
+       job = callback_job_create_with_prio((callback_job_cb_t)process,
+                       ctx, (void*)stroke_job_context_destroy, this->job, JOB_PRIO_HIGH);
        lib->processor->queue_job(lib->processor, (job_t*)job);
 
        return JOB_REQUEUE_FAIR;
@@ -723,8 +723,8 @@ stroke_socket_t *stroke_socket_create()
        charon->backends->add_backend(charon->backends, &this->config->backend);
        hydra->attributes->add_provider(hydra->attributes, &this->attribute->provider);
 
-       this->job = callback_job_create((callback_job_cb_t)receive,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index 8296c41..1fe9818 100644 (file)
@@ -294,8 +294,8 @@ uci_control_t *uci_control_create()
        }
        else
        {
-               this->job = callback_job_create((callback_job_cb_t)receive,
-                                                                               this, NULL, NULL);
+               this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
                lib->processor->queue_job(lib->processor, (job_t*)this->job);
        }
        return &this->public;
index 4a1fc5d..202c9a4 100644 (file)
@@ -225,8 +225,8 @@ whitelist_control_t *whitelist_control_create(whitelist_listener_t *listener)
                return NULL;
        }
 
-       this->job = callback_job_create((callback_job_cb_t)receive,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index ff4f0ed..71c4bf8 100644 (file)
@@ -2634,8 +2634,8 @@ kernel_klips_ipsec_t *kernel_klips_ipsec_create()
                return NULL;
        }
 
-       this->job = callback_job_create((callback_job_cb_t)receive_events,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
+                                                                       this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index 8b2a1aa..23db187 100644 (file)
@@ -2321,8 +2321,8 @@ kernel_netlink_ipsec_t *kernel_netlink_ipsec_create()
                destroy(this);
                return NULL;
        }
-       this->job = callback_job_create((callback_job_cb_t)receive_events,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index 8315ed3..050b753 100644 (file)
@@ -1537,8 +1537,8 @@ kernel_netlink_net_t *kernel_netlink_net_create()
                return NULL;
        }
 
-       this->job = callback_job_create((callback_job_cb_t)receive_events,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        if (init_address_list(this) != SUCCESS)
index b252b70..e32866a 100644 (file)
@@ -2172,8 +2172,8 @@ kernel_pfkey_ipsec_t *kernel_pfkey_ipsec_create()
                return NULL;
        }
 
-       this->job = callback_job_create((callback_job_cb_t)receive_events,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        return &this->public;
index fca46bf..5464568 100644 (file)
@@ -710,8 +710,8 @@ kernel_pfroute_net_t *kernel_pfroute_net_create()
                return NULL;
        }
 
-       this->job = callback_job_create((callback_job_cb_t)receive_events,
-                                                                       this, NULL, NULL);
+       this->job = callback_job_create_with_prio((callback_job_cb_t)receive_events,
+                                                                               this, NULL, NULL, JOB_PRIO_CRITICAL);
        lib->processor->queue_job(lib->processor, (job_t*)this->job);
 
        if (init_address_list(this) != SUCCESS)
index 431cd6a..1d6237e 100644 (file)
@@ -392,8 +392,8 @@ pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb,
        while (enumerator->enumerate(enumerator, &entry))
        {
                query_slots(entry);
-               entry->job = callback_job_create((void*)dispatch_slot_events,
-                                                                                entry, (void*)end_dispatch, NULL);
+               entry->job = callback_job_create_with_prio((void*)dispatch_slot_events,
+                                                entry, (void*)end_dispatch, NULL, JOB_PRIO_CRITICAL);
                lib->processor->queue_job(lib->processor, (job_t*)entry->job);
        }
        enumerator->destroy(enumerator);
index 7d9bcd7..f3cc116 100644 (file)
@@ -341,7 +341,8 @@ scheduler_t * scheduler_create()
 
        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);
 
        return &this->public;