Removed strayed code fragment
[strongswan.git] / src / charon / plugins / uci / uci_control.c
index c773bff..3c4928b 100644 (file)
@@ -12,8 +12,6 @@
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  * for more details.
- *
- * $Id$
  */
 
 #define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <pthread.h>
 
 #include "uci_control.h"
 
 #include <daemon.h>
+#include <threading/thread.h>
 #include <processing/jobs/callback_job.h>
 
 #define FIFO_FILE "/var/run/charon.fifo"
@@ -41,13 +39,13 @@ typedef struct private_uci_control_t private_uci_control_t;
 struct private_uci_control_t {
 
        /**
-        * Public part
-        */
+        * Public part
+        */
        uci_control_t public;
 
        /**
-        * Job 
-        */
+        * Job
+        */
        callback_job_t *job;
 };
 
@@ -58,7 +56,7 @@ static void write_fifo(private_uci_control_t *this, char *format, ...)
 {
        va_list args;
        FILE *out;
-       
+
        out = fopen(FIFO_FILE, "w");
        if (out)
        {
@@ -85,14 +83,15 @@ static void status(private_uci_control_t *this, char *name)
        peer_cfg_t *peer_cfg;
        char buf[2048];
        FILE *out = NULL;
-       
-    configs = charon->backends->create_peer_cfg_enumerator(charon->backends);
-    while (configs->enumerate(configs, &peer_cfg))
-    {
-       if (name && !streq(name, peer_cfg->get_name(peer_cfg)))
-       {
-               continue;
-       }
+
+       configs = charon->backends->create_peer_cfg_enumerator(charon->backends,
+                                                                                                               NULL, NULL, NULL, NULL);
+       while (configs->enumerate(configs, &peer_cfg))
+       {
+               if (name && !streq(name, peer_cfg->get_name(peer_cfg)))
+               {
+                       continue;
+               }
                sas = charon->controller->create_ike_sa_enumerator(charon->controller);
                while (sas->enumerate(sas, &ike_sa))
                {
@@ -108,9 +107,9 @@ static void status(private_uci_control_t *this, char *name)
                                        continue;
                                }
                        }
-               fprintf(out, "%-8s %-20D %-16H ", ike_sa->get_name(ike_sa),
-                       ike_sa->get_other_id(ike_sa), ike_sa->get_other_host(ike_sa));
-               
+                       fprintf(out, "%-8s %-20D %-16H ", ike_sa->get_name(ike_sa),
+                               ike_sa->get_other_id(ike_sa), ike_sa->get_other_host(ike_sa));
+
                        children = ike_sa->create_child_sa_iterator(ike_sa);
                        while (children->iterate(children, (void**)&child_sa))
                        {
@@ -118,7 +117,7 @@ static void status(private_uci_control_t *this, char *name)
                                                child_sa->get_traffic_selectors(child_sa, FALSE));
                        }
                        children->destroy(children);
-               fprintf(out, "\n");
+                       fprintf(out, "\n");
                }
                sas->destroy(sas);
        }
@@ -198,7 +197,7 @@ static void terminate(private_uci_control_t *this, char *name)
 static void process(private_uci_control_t *this, char *message)
 {
        enumerator_t* enumerator;
-       
+
        enumerator = enumerator_create_token(message, " \n", "");
        if (enumerator->enumerate(enumerator, &message))
        {
@@ -218,7 +217,7 @@ static void process(private_uci_control_t *this, char *message)
                {
                        initiate(this, message);
                }
-               else if (streq(message, "down") && 
+               else if (streq(message, "down") &&
                                 enumerator->enumerate(enumerator, &message))
                {
                        terminate(this, message);
@@ -238,13 +237,14 @@ static void process(private_uci_control_t *this, char *message)
 static job_requeue_t receive(private_uci_control_t *this)
 {
        char message[128];
-       int oldstate, len;
+       int len;
+       bool oldstate;
        FILE *in;
 
        memset(message, 0, sizeof(message));
-       pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
+       oldstate = thread_cancelability(TRUE);
        in = fopen(FIFO_FILE, "r");
-       pthread_setcancelstate(oldstate, NULL);
+       thread_cancelability(oldstate);
        if (in)
        {
                len = fread(message, 1, sizeof(message) - 1, in);
@@ -284,8 +284,8 @@ uci_control_t *uci_control_create()
 
        this->public.destroy = (void(*)(uci_control_t*))destroy;
 
-       if (access(FIFO_FILE, F_OK) != 0 &&
-               mkfifo(FIFO_FILE, S_IRUSR|S_IWUSR) != 0)
+       unlink(FIFO_FILE);
+       if (mkfifo(FIFO_FILE, S_IRUSR|S_IWUSR) != 0)
        {
                DBG1(DBG_CFG, "creating UCI control fifo '%s' failed: %s",
                         FIFO_FILE, strerror(errno));