- }
- if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT)
- {
- if (process_monitor_message (handle, msg) == GNUNET_OK)
- return;
- GNUNET_break (0);
- do_disconnect (handle);
- return;
- }
- if (ntohs (msg->size) < sizeof (struct GNUNET_DHT_ClientResultMessage))
+ cont = ph->cont;
+ cont_cls = ph->cont_cls;
+ GNUNET_DHT_put_cancel (ph);
+ if (NULL != cont)
+ cont (cont_cls,
+ GNUNET_OK);
+}
+
+
+/**
+ * Try to (re)connect to the DHT service.
+ *
+ * @param h DHT handle to reconnect
+ * @return #GNUNET_YES on success, #GNUNET_NO on failure.
+ */
+static int
+try_connect (struct GNUNET_DHT_Handle *h)
+{
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (monitor_get,
+ GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET,
+ struct GNUNET_DHT_MonitorGetMessage,
+ h),
+ GNUNET_MQ_hd_var_size (monitor_get_resp,
+ GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET_RESP,
+ struct GNUNET_DHT_MonitorGetRespMessage,
+ h),
+ GNUNET_MQ_hd_var_size (monitor_put,
+ GNUNET_MESSAGE_TYPE_DHT_MONITOR_PUT,
+ struct GNUNET_DHT_MonitorPutMessage,
+ h),
+ GNUNET_MQ_hd_var_size (client_result,
+ GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT,
+ struct GNUNET_DHT_ClientResultMessage,
+ h),
+ GNUNET_MQ_hd_fixed_size (put_confirmation,
+ GNUNET_MESSAGE_TYPE_DHT_CLIENT_PUT_OK,
+ struct GNUNET_DHT_ClientPutConfirmationMessage,
+ h),
+ GNUNET_MQ_handler_end ()
+ };
+ if (NULL != h->mq)
+ return GNUNET_OK;
+ h->mq = GNUNET_CLIENT_connect (h->cfg,
+ "dht",
+ handlers,
+ &mq_error_handler,
+ h);
+ if (NULL == h->mq)