some stability improvements
authorMartin Willi <martin@strongswan.org>
Fri, 4 Jul 2008 06:58:04 +0000 (06:58 -0000)
committerMartin Willi <martin@strongswan.org>
Fri, 4 Jul 2008 06:58:04 +0000 (06:58 -0000)
src/dumm/cowfs.c
src/dumm/guest.c
src/dumm/iface.c
src/dumm/mconsole.c

index 4c16c7c..f798463 100644 (file)
@@ -858,13 +858,15 @@ cowfs_t *cowfs_create(char *master, char *host, char *mount)
     {
        DBG1("failed to open master filesystem '%s'", master);
        free(this);
+       return NULL;
     }
     this->host_fd = open(host, O_RDONLY | O_DIRECTORY);
-       if (this->master_fd < 0)
+       if (this->host_fd < 0)
     {
        DBG1("failed to open host filesystem '%s'", host);
        close(this->master_fd);
        free(this);
+       return NULL;
     }
        this->over_fd = -1;
        
index 4b26526..d43f46d 100644 (file)
@@ -424,6 +424,7 @@ static void destroy(private_guest_t *this)
        {
                close(this->dir);
        }
+       this->ifaces->destroy(this->ifaces);
        free(this->dirname);
        free(this->name);
        free(this);
index b78c10b..b1fc641 100644 (file)
@@ -205,10 +205,6 @@ iface_t *iface_create(char *guest, char *guestif, mconsole_t *mconsole)
                free(this);
                return NULL;
        }
-       if (!iface_control(this->hostif, TRUE))
-       {
-               DBG1("bringing iface '%s' up failed: %m", this->hostif);
-       }
        if (!this->mconsole->add_iface(this->mconsole, this->guestif, this->hostif))
        {
                DBG1("creating interface '%s' in guest failed", this->guestif);
@@ -218,6 +214,10 @@ iface_t *iface_create(char *guest, char *guestif, mconsole_t *mconsole)
                free(this);
                return NULL;
        }
+       if (!iface_control(this->hostif, TRUE))
+       {
+               DBG1("bringing iface '%s' up failed: %m", this->hostif);
+       }
        return &this->public;
 }
 
index d9864f6..78c97fb 100644 (file)
@@ -156,21 +156,25 @@ static int request(private_mconsole_t *this, char *command,
  */
 static bool add_iface(private_mconsole_t *this, char *guest, char *host)
 {
-       char buf[128];
-       int len;
+       char in[128], out[128];
+       int len, tries = 0;
        
-       len = snprintf(buf, sizeof(buf), "config %s=tuntap,%s", guest, host);
-       if (len < 0 || len >= sizeof(buf))
+       len = snprintf(in, sizeof(in), "config %s=tuntap,%s", guest, host);
+       if (len < 0 || len >= sizeof(in))
        {
                return FALSE;
        }
-       len = sizeof(buf);
-       if (request(this, buf, buf, &len) != 0)
+       while (tries++ < 10)
        {
-               DBG1("adding interface failed: %.*s", len, buf);
-               return FALSE;
+               len = sizeof(in);
+               if (request(this, in, out, &len) == 0)
+               {
+                       return TRUE;
+               }
+               usleep(10000 * tries);
        }
-       return TRUE;
+       DBG1("adding interface failed: %.*s", len, out);
+       return FALSE;
 }
 
 /**
@@ -188,7 +192,6 @@ static bool del_iface(private_mconsole_t *this, char *guest)
        }
        if (request(this, buf, buf, &len) != 0)
        {
-               DBG1("removing interface failed: %.*s", len, buf);
                return FALSE;
        }
        return TRUE;