From: Nathan S. Evans Date: Wed, 9 Mar 2011 11:08:00 +0000 (+0000) Subject: allow peer connect call directly from peer started callback X-Git-Tag: initial-import-from-subversion-38251~19004 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=23b3936c07498c0f06c4bfb669be95051292e5b2;p=oweals%2Fgnunet.git allow peer connect call directly from peer started callback --- diff --git a/src/testing/testing.c b/src/testing/testing.c index e6671c99a..bfdc30a55 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -216,6 +216,27 @@ testing_init (void *cls, } #endif +/** + * Notify of a peer being up and running. Scheduled as a task + * so that variables which may need to be set are set before + * the connect callback can set up new operations. + * + * @param cls the testing daemon + * @param tc task scheduler context + */ +static void +notify_daemon_started (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct GNUNET_TESTING_Daemon *d = cls; + GNUNET_TESTING_NotifyDaemonRunning cb; + + cb = d->cb; + d->cb = NULL; + if (NULL != cb) + cb (d->cb_cls, &d->id, d->cfg, d, NULL); +} + /** * Finite-state machine for starting GNUnet. * @@ -671,10 +692,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) #endif GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d); - cb = d->cb; + GNUNET_SCHEDULER_add_now(¬ify_daemon_started, d); + /*cb = d->cb; d->cb = NULL; - if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */ - cb (d->cb_cls, &d->id, d->cfg, d, NULL); + if (NULL != cb) + cb (d->cb_cls, &d->id, d->cfg, d, NULL);*/ d->running = GNUNET_YES; d->phase = SP_GET_HELLO; #endif