void *thread (void *arg) { thd_t *t = arg; if (!(t->h = flux_open (NULL, 0))) { log_err ("%d: flux_open", t->n); goto done; } signal_ready (); /* The first kvs.watch reply is handled synchronously, then other kvs.watch * replies will arrive asynchronously and be handled by the reactor. */ if (kvs_watch_int (t->h, key, mt_watch_cb, t) < 0) { log_err ("%d: kvs_watch_int", t->n); goto done; } if (kvs_watch_int (t->h, "nonexistent-key", mt_watchnil_cb, t) < 0) { log_err ("%d: kvs_watch_int", t->n); goto done; } if (kvs_watch_int (t->h, key_stable, mt_watchstable_cb, t) < 0) { log_err ("%d: kvs_watch_int", t->n); goto done; } if (flux_reactor_run (flux_get_reactor (t->h), 0) < 0) { log_err ("%d: flux_reactor_run", t->n); goto done; } done: if (t->h) flux_close (t->h); return NULL; }
// set to 0 to have no finish msg (as order is non-deterministic) static void *sleeper_or_burner(void *v) { int i = 0; struct spec* s = (struct spec*)v; int ret; fprintf(stderr, "%s ready to sleep and/or burn\n", s->name); fflush (stderr); signal_ready(); nr_sleeper_or_burner++; for (i = 0; i < loops; i++) { if (sleepms > 0 && s->sleep) { t[s->t].tv_sec = sleepms / 1000; t[s->t].tv_usec = (sleepms % 1000) * 1000; ret = select (0, NULL, NULL, NULL, &t[s->t]); /* We only expect a timeout result or EINTR from the above. */ if (ret != 0 && errno != EINTR) perror("unexpected result from select"); } if (burn > 0 && s->burn) do_burn(); } if (report_finished) { fprintf(stderr, "%s finished to sleep and/or burn\n", s->name); fflush (stderr); } return NULL; }