xl: free all data on exit from the domain monitor daemon.
authorIan Campbell <ian.campbell@citrix.com>
Thu, 19 Aug 2010 13:40:24 +0000 (14:40 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 19 Aug 2010 13:40:24 +0000 (14:40 +0100)
[PATCH 01 of 16
 libxl: autogenerate type definitions and destructor functions]

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c

index b5a1cddb47949112356b3bee49633f6987000edb..92d847d3be4693b05615d57dfd0aa55be390b10c 100644 (file)
@@ -1557,9 +1557,11 @@ start:
                 if (ret) {
                     switch (handle_domain_death(&ctx, domid, &event, &d_config, &info)) {
                     case 2:
-                        if (!preserve_domain(&ctx, domid, &event, &d_config, &info))
+                        if (!preserve_domain(&ctx, domid, &event, &d_config, &info)) {
                             /* If we fail then exit leaving the old domain in place. */
-                            exit(-1);
+                            ret = -1;
+                            goto out;
+                        }
 
                         /* Otherwise fall through and restart. */
                     case 1:
@@ -1577,7 +1579,8 @@ start:
                         goto start;
                     case 0:
                         LOG("Done. Exiting now");
-                        exit(0);
+                        ret = 0;
+                        goto out;
                     }
                 }
                 break;
@@ -1589,13 +1592,13 @@ start:
         libxl_free_event(&event);
     }
 
-    close(logfile);
-    exit(0);
-
 error_out:
     if (domid)
         libxl_domain_destroy(&ctx, domid, 0);
+
 out:
+    if (logfile != 2)
+        close(logfile);
 
     free_domain_config(&d_config);