};
+static void
+reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+
+
/**
* Function called when we are ready to transmit our
* "START" message (or when this operation timed out).
static void
reconnect (struct GNUNET_CORE_Handle *h)
{
- GNUNET_CLIENT_disconnect (h->client_notifications);
+ if (h->client_notifications != NULL)
+ GNUNET_CLIENT_disconnect (h->client_notifications, GNUNET_NO);
h->currently_down = GNUNET_YES;
h->client_notifications = GNUNET_CLIENT_connect (h->sched, "core", h->cfg);
- h->th = GNUNET_CLIENT_notify_transmit_ready (h->client_notifications,
- sizeof (struct InitMessage) +
- sizeof (uint16_t) * h->hcnt,
- GNUNET_TIME_UNIT_SECONDS,
- GNUNET_NO,
- &transmit_start, h);
+ if (h->client_notifications == NULL)
+ h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched,
+ GNUNET_TIME_UNIT_SECONDS,
+ &reconnect_task,
+ h);
+ else
+ h->th = GNUNET_CLIENT_notify_transmit_ready (h->client_notifications,
+ sizeof (struct InitMessage) +
+ sizeof (uint16_t) * h->hcnt,
+ GNUNET_TIME_UNIT_SECONDS,
+ GNUNET_NO,
+ &transmit_start, h);
}
if (h->currently_down)
{
+#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "\nIn trigger_next_request, connection currently down...\n");
+ "In trigger_next_request, connection currently down...\n");
+#endif
return; /* connection temporarily down */
}
if (NULL == (th = h->pending_head))
/* start our message processing loop */
#if DEBUG_CORE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- _
- ("Successfully connected to core service, starting processing loop.\n"));
+ "Successfully connected to core service, starting processing loop.\n");
#endif
h->currently_down = GNUNET_NO;
trigger_next_request (h);
{
/* mark so we don't call init on reconnect */
h->init = NULL;
-#if DEBUG_CORE
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Successfully connected to core service.\n"));
-#endif
GNUNET_CRYPTO_hash (&m->publicKey,
sizeof (struct
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
GNUNET_CORE_notify_transmit_ready_cancel (handle->solicit_transmit_req);
if (handle->reconnect_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (handle->sched, handle->reconnect_task);
- GNUNET_CLIENT_disconnect (handle->client_notifications);
+ if (handle->client_notifications != NULL)
+ GNUNET_CLIENT_disconnect (handle->client_notifications, GNUNET_NO);
GNUNET_free_non_null (handle->solicit_buffer);
GNUNET_free (handle);
}
return 0;
}
GNUNET_assert (dt >= sizeof (struct GNUNET_MessageHeader));
+ if (dt + sizeof (struct SendMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
+ {
+ GNUNET_break (0);
+ return 0;
+ }
sm->header.size = htons (dt + sizeof (struct SendMessage));
GNUNET_assert (dt + sizeof (struct SendMessage) <= size);
return dt + sizeof (struct SendMessage);