wait for DMAPI to startup
authorAndrew Tridgell <tridge@samba.org>
Sun, 17 Aug 2008 23:15:08 +0000 (09:15 +1000)
committerAndrew Tridgell <tridge@samba.org>
Sun, 17 Aug 2008 23:15:08 +0000 (09:15 +1000)
hacksmd.c

index 3ef4bf1..bf6854c 100644 (file)
--- a/hacksmd.c
+++ b/hacksmd.c
@@ -23,6 +23,8 @@ static struct {
 
 #define SESSION_NAME "hacksmd"
 
+/* no special handling on terminate in hacksmd, as we want existing
+   events to stay around so we can continue them on restart */
 static void hsm_term_handler(int signal)
 {
        printf("Got signal %d - exiting\n", signal);
@@ -42,8 +44,13 @@ static void hsm_init(void)
        int ret;
 
        ret = dm_init_service(&dmapi_version);
+       if (ret == -1 && errno == ENOSYS) {
+               printf("Waiting for DMAPI to initialise\n");
+               while ((ret = dm_init_service(&dmapi_version)) == -1 &&
+                      errno == ENOSYS) sleep(1);
+       }
        if (ret != 0) {
-               printf("Failed to init dmapi\n");
+               printf("Failed to init dmapi (%s)\n", strerror(errno));
                exit(1);
        }