Use CRITICAL job priority class for long running dispatcher jobs
[strongswan.git] / src / libcharon / plugins / smp / smp.c
index 60937f2..58f98cf 100644 (file)
@@ -208,7 +208,8 @@ static void request_query_ikesa(xmlTextReaderPtr reader, xmlTextWriterPtr writer
        /* <ikesalist> */
        xmlTextWriterStartElement(writer, "ikesalist");
 
-       enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
+       enumerator = charon->controller->create_ike_sa_enumerator(
+                                                                                                       charon->controller, TRUE);
        while (enumerator->enumerate(enumerator, &ike_sa))
        {
                ike_sa_id_t *id;
@@ -394,7 +395,8 @@ static void request_control_terminate(xmlTextReaderPtr reader,
                        enumerator_t *enumerator;
                        ike_sa_t *ike_sa;
 
-                       enumerator = charon->controller->create_ike_sa_enumerator(charon->controller);
+                       enumerator = charon->controller->create_ike_sa_enumerator(
+                                                                                                       charon->controller, TRUE);
                        while (enumerator->enumerate(enumerator, &ike_sa))
                        {
                                if (streq(str, ike_sa->get_name(ike_sa)))
@@ -707,10 +709,14 @@ static job_requeue_t dispatch(private_smp_t *this)
        return JOB_REQUEUE_DIRECT;
 }
 
-/**
- * Implementation of itnerface_t.destroy.
- */
-static void destroy(private_smp_t *this)
+METHOD(plugin_t, get_name, char*,
+       private_smp_t *this)
+{
+       return "smp";
+}
+
+METHOD(plugin_t, destroy, void,
+       private_smp_t *this)
 {
        this->job->cancel(this->job);
        close(this->socket);
@@ -723,10 +729,18 @@ static void destroy(private_smp_t *this)
 plugin_t *smp_plugin_create()
 {
        struct sockaddr_un unix_addr = { AF_UNIX, IPSEC_PIDDIR "/charon.xml"};
-       private_smp_t *this = malloc_thing(private_smp_t);
+       private_smp_t *this;
        mode_t old;
 
-       this->public.plugin.destroy = (void (*)(plugin_t*))destroy;
+       INIT(this,
+               .public = {
+                       .plugin = {
+                               .get_name = _get_name,
+                               .reload = (void*)return_false,
+                               .destroy = _destroy,
+                       },
+               },
+       );
 
        /* set up unix socket */
        this->socket = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -760,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;