kaluga: start_cpu: inheritcn_delete: remove trigger once it is called
authorSimon Gerber <simon.gerber@inf.ethz.ch>
Wed, 21 Sep 2016 16:42:59 +0000 (18:42 +0200)
committerSimon Gerber <simon.gerber@inf.ethz.ch>
Wed, 21 Sep 2016 16:42:59 +0000 (18:42 +0200)
Signed-off-by: Simon Gerber <simon.gerber@inf.ethz.ch>

usr/kaluga/start_cpu.c

index 7e23de9..8d0c4dc 100644 (file)
@@ -81,7 +81,6 @@ struct inheritcn_del_st {
     struct capref        capref;
     octopus_trigger_id_t tid;
     coreid_t             coreid;
-    bool                 deleted; // XXX: necessary because we get triggered multiple times?
 };
 
 // Trigger function: gets called when spanwd on core n is up to delete
@@ -90,8 +89,8 @@ static void delete_inheritcn(octopus_mode_t mode, char *record, void *state)
 {
     errval_t err;
     struct inheritcn_del_st *st = state;
-    if (mode & OCT_ON_SET && !st->deleted) {
-        debug_printf("spawnd up for %d: deleting inheritcn\n", st->coreid);
+    if (mode & OCT_ON_SET) {
+        KALUGA_DEBUG("spawnd up for %d: deleting inheritcn\n", st->coreid);
         err = cap_delete(st->capref);
         if (err_is_fail(err)) {
             DEBUG_ERR(err, "deleting inheritcn for %d\n", st->coreid);
@@ -102,15 +101,12 @@ static void delete_inheritcn(octopus_mode_t mode, char *record, void *state)
             DEBUG_ERR(err, "freeing slot for %d\n", st->coreid);
         }
         assert(err_is_ok(err));
-        // XXX: should remove trigger here, but that code seems broken
-        //err = oct_remove_trigger(st->tid);
-        //assert(err_is_ok(err));
-        // XXX: cannot free state if we get triggered multiple times
-        //free(state);
-        // XXX: Instead we set deleted flag true
-        st->deleted = true;
-    } else if (mode & OCT_ON_SET) {
-        debug_printf(">>>>>>> GOT SPAWND UP NOTIFICATION FOR %d WHILE ST->DELETED SET!\n", st->coreid);
+        err = oct_remove_trigger(st->tid);
+        if (err_is_fail(err)) {
+            DEBUG_ERR(err, "removing trigger");
+        }
+        assert(err_is_ok(err));
+        free(state);
     }
 }
 
@@ -222,10 +218,8 @@ errval_t start_boot_driver(coreid_t where, struct module_info* mi,
     struct inheritcn_del_st *tstate = calloc(1, sizeof(*tstate));
     tstate->capref = inheritcn_cap;
     tstate->coreid = barrelfish_id;
-    octopus_trigger_id_t tid;
     errval_t err2 = oct_trigger_existing_and_watch(spawnd, delete_inheritcn,
-                                                   tstate, &tid);
-    tstate->tid = tid;
+                                                   tstate, &tstate->tid);
     if (err_is_fail(err2)) {
         free(tstate);
         return err2;