#include "gnunet_transport_service.h"
#include "gnunet_hello_lib.h"
-#define DEBUG_TESTING GNUNET_YES
-#define DEBUG_TESTING_RECONNECT GNUNET_YES
+#define DEBUG_TESTING GNUNET_NO
+#define DEBUG_TESTING_RECONNECT GNUNET_NO
/**
* How long do we wait after starting gnunet-service-arm
*/
struct GNUNET_CORE_Handle *d1core;
+ /**
+ * Have we actually connected to the core of the first daemon yet?
+ */
+ int d1core_ready;
+
/**
* Testing handle to the second daemon.
*/
GNUNET_CORE_disconnect (ctx->d1core);
ctx->d1core = NULL;
}
+ ctx->d1core_ready = GNUNET_NO;
#if CONNECT_CORE2
if (ctx->d2core != NULL)
{
ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN)
return;
- if ((ctx->d2->hello != NULL)
+ if ((ctx->d1core_ready == GNUNET_YES) && (ctx->d2->hello != NULL)
&& (NULL != GNUNET_HELLO_get_header (ctx->d2->hello)))
{
hello = GNUNET_HELLO_get_header (ctx->d2->hello);
&send_hello, ctx);
}
+void
+core_init_notify (void *cls,
+ struct GNUNET_CORE_Handle * server,
+ const struct GNUNET_PeerIdentity *
+ my_identity,
+ const struct
+ GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *
+ publicKey)
+{
+ struct ConnectContext *connect_ctx = cls;
+
+ connect_ctx->d1core_ready = GNUNET_YES;
+}
+
/**
* Establish a connection between two GNUnet daemons.
*
d1->shortname, d2->shortname);
#endif
+ /* FIXME: possible bug, core gets connected after peers are connected, thus the connect_notify function is never called (?) */
ctx->d1core = GNUNET_CORE_connect (d1->cfg, 1,
ctx,
- NULL,
+ &core_init_notify,
&connect_notify, NULL, NULL,
NULL, GNUNET_NO,
NULL, GNUNET_NO, no_handlers);
#endif
GNUNET_assert (ctx->d1core == NULL);
-
+ ctx->d1core_ready = GNUNET_NO;
ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1,
-#if NO_MORE_TIMEOUT_FIXME
- GNUNET_TIME_absolute_get_remaining
- (ctx->timeout),
-#endif
ctx,
- NULL,
+ &core_init_notify,
&connect_notify, NULL, NULL,
NULL, GNUNET_NO,
NULL, GNUNET_NO, no_handlers);