add a atexit() call to remove the domain socket when the daemon exits
authorRonnie sahlberg <ronniesahlberg@gmail.com>
Mon, 9 Apr 2007 22:47:39 +0000 (08:47 +1000)
committerRonnie sahlberg <ronniesahlberg@gmail.com>
Mon, 9 Apr 2007 22:47:39 +0000 (08:47 +1000)
(This used to be ctdb commit 2f685c68e0b17ed8a290a265ebd64c1d089ceec5)

ctdb/common/ctdb_daemon.c

index 8ef2366074c7e981a75a38d832ba772489fdcf33..dc1e1477163100be74ba143fed6aec176e7c4b11 100644 (file)
@@ -277,6 +277,14 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
        return 0;
 }
 
+static char *domain_socket_name=NULL;
+static void unlink_domain_socket(void)
+{
+       if (domain_socket_name) {
+               unlink(domain_socket_name);
+       }
+}
+
 /*
   start the protocol going
 */
@@ -292,6 +300,9 @@ int ctdbd_start(struct ctdb_context *ctdb)
        /* get rid of any old sockets */
        unlink(ctdb->daemon.name);
 
+       domain_socket_name = ctdb->daemon.name;
+       atexit(unlink_domain_socket);
+
        /* create a unix domain stream socket to listen to */
        res = ux_socket_bind(ctdb);
        if (res!=0) {