GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending RECORD_STORE_RESPONSE message\n");
+ GNUNET_STATISTICS_update (statistics,
+ "Store requests completed",
+ 1,
+ GNUNET_NO);
env = GNUNET_MQ_msg (rcr_msg,
GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE);
rcr_msg->gns_header.r_id = htonl (rid);
GNUNET_SERVICE_client_drop (nc->client);
return;
}
+ GNUNET_STATISTICS_update (statistics,
+ "Well-formed store requests received",
+ 1,
+ GNUNET_NO);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating %u records for name `%s'\n",
(unsigned int) rd_count,
#define LOG(kind,...) GNUNET_log_from (kind, "namestore-api",__VA_ARGS__)
+/**
+ * We grant the namestore up to 1 minute of latency, if it is slower than
+ * that, store queries will fail.
+ */
+#define NAMESTORE_DELAY_TOLERANCE GNUNET_TIME_UNIT_MINUTES
/**
* An QueueEntry used to store information for a pending
*/
struct GNUNET_MQ_Envelope *env;
+ /**
+ * Task scheduled to warn us if the namestore is way too slow.
+ */
+ struct GNUNET_SCHEDULER_Task *timeout_task;
+
/**
* The operation id this zone iteration operation has
*/
qe);
if (NULL != qe->env)
GNUNET_MQ_discard (qe->env);
+ if (NULL != qe->timeout_task)
+ GNUNET_SCHEDULER_cancel (qe->timeout_task);
GNUNET_free (qe);
}
}
+/**
+ * Task launched to warn the user that the namestore is
+ * excessively slow and that a query was thus dropped.
+ *
+ * @param cls a `struct GNUNET_NAMESTORE_QueueEntry *`
+ */
+static void
+warn_delay (void *cls)
+{
+ struct GNUNET_NAMESTORE_QueueEntry *qe = cls;
+
+ qe->timeout_task = NULL;
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Did not receive response from namestore after %s!\n",
+ GNUNET_STRINGS_relative_time_to_string (NAMESTORE_DELAY_TOLERANCE,
+ GNUNET_YES));
+ if (NULL != qe->cont)
+ {
+ qe->cont (qe->cont_cls,
+ GNUNET_SYSERR,
+ "timeout");
+ qe->cont = NULL;
+ }
+ GNUNET_NAMESTORE_cancel (qe);
+}
+
+
/**
* Store an item in the namestore. If the item is already present,
* it is replaced with the new record. Use an empty array to
"Sending NAMESTORE_RECORD_STORE message for name `%s' with %u records\n",
label,
rd_count);
-
+ qe->timeout_task = GNUNET_SCHEDULER_add_delayed (NAMESTORE_DELAY_TOLERANCE,
+ &warn_delay,
+ qe);
if (NULL == h->mq)
+ {
qe->env = env;
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "Delaying NAMESTORE_RECORD_STORE message as namestore is not ready!\n");
+ }
else
+ {
GNUNET_MQ_send (h->mq,
env);
+ }
return qe;
}