if (c > max_queue_size)
{
response_proc (ret, NULL);
- GNUNET_free (ret);
return NULL;
}
ret->task = GNUNET_SCHEDULER_add_delayed (h->sched,
{
if (h->client == NULL)
return;
+#if 0
+ GNUNET_STATISTICS_update (stats,
+ gettext_noop ("# reconnected to datastore"),
+ 1,
+ GNUNET_NO);
+#endif
GNUNET_CLIENT_disconnect (h->client, GNUNET_NO);
h->client = NULL;
h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->sched,
const struct StatusMessage *sm;
const char *emsg;
int32_t status;
+ int was_transmitted;
- free_queue_entry (qe);
+ was_transmitted = qe->was_transmitted;
if (msg == NULL)
{
+ free_queue_entry (qe);
if (NULL == h->client)
return; /* forced disconnect */
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to receive response from database.\n"));
- do_disconnect (h);
+ if (was_transmitted == GNUNET_YES)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to receive response from database.\n"));
+ do_disconnect (h);
+ }
return;
}
-
+ GNUNET_assert (GNUNET_YES == qe->was_transmitted);
+ GNUNET_assert (h->queue_head == qe);
+ free_queue_entry (qe);
if ( (ntohs(msg->size) < sizeof(struct StatusMessage)) ||
(ntohs(msg->type) != GNUNET_MESSAGE_TYPE_DATASTORE_STATUS) )
{
struct GNUNET_DATASTORE_Handle *h = qe->h;
struct ResultContext rc = qe->qc.rc;
const struct DataMessage *dm;
+ int was_transmitted;
- GNUNET_assert (h->queue_head == qe);
if (msg == NULL)
{
-#if DEBUG_DATASTORE
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to receive response from datastore\n"));
-#endif
+ was_transmitted = qe->was_transmitted;
free_queue_entry (qe);
- do_disconnect (h);
- rc.iter (rc.iter_cls,
- NULL, 0, NULL, 0, 0, 0,
- GNUNET_TIME_UNIT_ZERO_ABS, 0);
+ if (was_transmitted == GNUNET_YES)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ _("Failed to receive response from database.\n"));
+ do_disconnect (h);
+ }
+ if (rc.iter != NULL)
+ rc.iter (rc.iter_cls,
+ NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
return;
}
+ GNUNET_assert (GNUNET_YES == qe->was_transmitted);
+ GNUNET_assert (h->queue_head == qe);
if (ntohs(msg->type) == GNUNET_MESSAGE_TYPE_DATASTORE_DATA_END)
{
GNUNET_break (ntohs(msg->size) == sizeof(struct GNUNET_MessageHeader));
"Received end of result set\n");
#endif
free_queue_entry (qe);
- rc.iter (rc.iter_cls,
- NULL, 0, NULL, 0, 0, 0,
- GNUNET_TIME_UNIT_ZERO_ABS, 0);
+ if (rc.iter != NULL)
+ rc.iter (rc.iter_cls,
+ NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
process_queue (h);
return;
}
free_queue_entry (qe);
h->retry_time = GNUNET_TIME_UNIT_ZERO;
do_disconnect (h);
- rc.iter (rc.iter_cls,
- NULL, 0, NULL, 0, 0, 0,
- GNUNET_TIME_UNIT_ZERO_ABS, 0);
+ if (rc.iter != NULL)
+ rc.iter (rc.iter_cls,
+ NULL, 0, NULL, 0, 0, 0,
+ GNUNET_TIME_UNIT_ZERO_ABS, 0);
+ return;
+ }
+ if (rc.iter == NULL)
+ {
+ /* abort iteration */
+ do_disconnect (h);
return;
}
dm = (const struct DataMessage*) msg;
int reconnect;
h = qe->h;
- reconnect = qe->was_transmitted;
+ reconnect = GNUNET_NO;
+ if (GNUNET_YES == qe->was_transmitted)
+ {
+ if (qe->response_proc == &process_result_message)
+ {
+ qe->qc.rc.iter = NULL;
+ return;
+ }
+ reconnect = GNUNET_YES;
+ }
free_queue_entry (qe);
h->queue_size--;
if (reconnect)