properly shut down and unref nm mainloop, fixes crash at shutdown
authorMartin Willi <martin@strongswan.org>
Tue, 9 Jun 2009 13:13:10 +0000 (15:13 +0200)
committerMartin Willi <martin@strongswan.org>
Tue, 9 Jun 2009 13:13:10 +0000 (15:13 +0200)
src/charon/plugins/nm/nm_plugin.c

index 0b9d1c4..1fb46f8 100644 (file)
@@ -63,8 +63,6 @@ static job_requeue_t run(private_nm_plugin_t *this)
 {
        this->loop = g_main_loop_new(NULL, FALSE);
        g_main_loop_run(this->loop);
-       g_main_loop_unref(this->loop);
-       
        return JOB_REQUEUE_NONE;
 }
 
@@ -75,7 +73,11 @@ static void destroy(private_nm_plugin_t *this)
 {
        if (this->loop)
        {
-               g_main_loop_quit(this->loop);
+               if (g_main_loop_is_running(this->loop))
+               {
+                       g_main_loop_quit(this->loop);
+               }
+               g_main_loop_unref(this->loop);
        }
        if (this->plugin)
        {