*/
int in_receive;
+ /**
+ * Are we ignoring shutdown signals?
+ */
+ int ignore_shutdown;
+
};
return ret;
}
+/**
+ * Configure this connection to ignore shutdown signals.
+ *
+ * @param h client handle
+ * @param do_ignore GNUNET_YES to ignore, GNUNET_NO to restore default
+ */
+void
+GNUNET_CLIENT_ignore_shutdown (struct GNUNET_CLIENT_Connection *h,
+ int do_ignore)
+{
+ h->ignore_shutdown = do_ignore;
+ if (h->sock != NULL)
+ GNUNET_CONNECTION_ignore_shutdown (h->sock,
+ do_ignore);
+}
+
/**
* Destroy connection with the service. This will automatically
th->sock->sock = do_connect (th->sock->sched,
th->sock->service_name, th->sock->cfg);
GNUNET_assert (NULL != th->sock->sock);
+ GNUNET_CONNECTION_ignore_shutdown (th->sock->sock,
+ th->sock->ignore_shutdown);
+
delay = GNUNET_TIME_relative_min (delay, th->sock->back_off);
th->sock->back_off
= GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (th->sock->back_off, 2),
msize = ntohs (tc->hdr->size);
if (NULL == buf)
{
+#if DEBUG_CLIENT
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Could not submit request, not expecting to receive a response.\n"));
+#endif
tc->rn (tc->rn_cls, NULL);
GNUNET_free (tc);
return 0;
*/
size_t max;
+ /**
+ * Ignore GNUNET_SCHEDULER_REASON_SHUTDOWN for this socket.
+ */
+ int ignore_shutdown;
+
/**
* Port to connect to.
*/
return;
}
#if DEBUG_CONNECTION
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroy actually runs (%p)!\n", sock);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Destroy actually runs (%p)!\n", sock);
#endif
+ if (sock->dns_active != NULL)
+ {
+ GNUNET_RESOLVER_request_cancel (sock->dns_active);
+ sock->dns_active = NULL;
+ }
GNUNET_assert (sock->nth.timeout_task == GNUNET_SCHEDULER_NO_TASK);
GNUNET_assert (sock->ccs == COCO_NONE);
if (NULL != (notify = sock->nth.notify_ready))
sock->dns_active = NULL;
}
GNUNET_assert (sock->sched != NULL);
- GNUNET_SCHEDULER_add_after (sock->sched,
- GNUNET_SCHEDULER_NO_TASK,
- &destroy_continuation, sock);
+ GNUNET_SCHEDULER_add_now (sock->sched,
+ &destroy_continuation, sock);
}
GNUNET_CONNECTION_Receiver receiver;
sh->read_task = GNUNET_SCHEDULER_NO_TASK;
+ if ( (GNUNET_YES == sh->ignore_shutdown) &&
+ (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)))
+ {
+ /* ignore shutdown request, go again immediately */
+#if DEBUG_CONNECTION
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Ignoring shutdown signal per configuration\n");
+#endif
+ sh->read_task = GNUNET_SCHEDULER_add_read_net (tc->sched,
+ GNUNET_TIME_absolute_get_remaining
+ (sh->receive_timeout),
+ sh->sock,
+ &receive_ready, sh);
+ return;
+ }
now = GNUNET_TIME_absolute_get ();
if ((now.value > sh->receive_timeout.value) ||
(0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) ||
}
+/**
+ * Configure this connection to ignore shutdown signals.
+ *
+ * @param sock socket handle
+ * @param do_ignore GNUNET_YES to ignore, GNUNET_NO to restore default
+ */
+void
+GNUNET_CONNECTION_ignore_shutdown (struct GNUNET_CONNECTION_Handle *sock,
+ int do_ignore)
+{
+ sock->ignore_shutdown = do_ignore;
+}
+
+
/**
* Cancel receive job on the given socket. Note that the
* receiver callback must not have been called yet in order