afb-ditf: track daemon state
[src/app-framework-binder.git] / src / afb-api-so-v1.c
index 2a5dc08..a341dac 100644 (file)
@@ -88,7 +88,7 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
        if (desc->service != NULL) {
                /* not an error when onneed */
                if (onneed != 0)
-                       return 0;
+                       goto done;
 
                /* already started: it is an error */
                ERROR("Service %s already started", desc->binding->v1.prefix);
@@ -101,7 +101,7 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
        if (init == NULL && onevent == NULL) {
                /* not an error when onneed */
                if (onneed != 0)
-                       return 0;
+                       goto done;
 
                /* no initialisation method */
                ERROR("Binding %s is not a service", desc->binding->v1.prefix);
@@ -116,6 +116,7 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
        }
 
        /* Starts the service */
+       desc->ditf.state = Daemon_Init;
        rc = afb_svc_start_v1(desc->service, init);
        if (rc < 0) {
                /* initialisation error */
@@ -125,6 +126,8 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct
                return rc;
        }
 
+done:
+       desc->ditf.state = Daemon_Run;
        return 0;
 }