From b55a742ce90f56f266f16172ccbc85180590b4b1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 20 Jun 2016 20:12:52 +0000 Subject: [PATCH] -tolerate init CB being NULL from the beginning --- src/core/core_api.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core/core_api.c b/src/core/core_api.c index b7fe812f8..7699f8b74 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c @@ -215,6 +215,11 @@ struct GNUNET_CORE_Handle */ int currently_down; + /** + * Did we ever get INIT? + */ + int have_init; + }; @@ -359,6 +364,7 @@ handle_init_reply (void *cls, LOG (GNUNET_ERROR_TYPE_DEBUG, "Connected to core service of peer `%s'.\n", GNUNET_i2s (&h->me)); + h->have_init = GNUNET_YES; init (h->cls, &h->me); } @@ -366,9 +372,17 @@ handle_init_reply (void *cls, { LOG (GNUNET_ERROR_TYPE_DEBUG, "Successfully reconnected to core service.\n"); - GNUNET_break (0 == memcmp (&h->me, - &m->my_identity, - sizeof (struct GNUNET_PeerIdentity))); + if (GNUNET_NO == h->have_init) + { + h->me = m->my_identity; + h->have_init = GNUNET_YES; + } + else + { + GNUNET_break (0 == memcmp (&h->me, + &m->my_identity, + sizeof (struct GNUNET_PeerIdentity))); + } } /* fake 'connect to self' */ pr = GNUNET_new (struct PeerRecord); -- 2.25.1