gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: watch for namestore not com


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: watch for namestore not completing store operations, add auto-abort with warning plus statistics to detect
Date: Thu, 10 May 2018 21:08:30 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new c4202563f watch for namestore not completing store operations, add 
auto-abort with warning plus statistics to detect
c4202563f is described below

commit c4202563fb4210adf3eb94fbdb6f40e059b63e37
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu May 10 21:08:23 2018 +0200

    watch for namestore not completing store operations, add auto-abort with 
warning plus statistics to detect
---
 src/namestore/gnunet-service-namestore.c |  8 ++++++
 src/namestore/namestore_api.c            | 49 +++++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/src/namestore/gnunet-service-namestore.c 
b/src/namestore/gnunet-service-namestore.c
index ffc76a911..6dedcd754 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -681,6 +681,10 @@ send_store_response (struct NamestoreClient *nc,
 
   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);
@@ -1308,6 +1312,10 @@ handle_record_store (void *cls,
       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,
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c
index ab356838b..57bf8f81b 100644
--- a/src/namestore/namestore_api.c
+++ b/src/namestore/namestore_api.c
@@ -40,6 +40,11 @@
 
 #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
@@ -100,6 +105,11 @@ struct GNUNET_NAMESTORE_QueueEntry
   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
    */
   uint32_t op_id;
@@ -300,6 +310,8 @@ free_qe (struct GNUNET_NAMESTORE_QueueEntry *qe)
                                qe);
   if (NULL != qe->env)
     GNUNET_MQ_discard (qe->env);
+  if (NULL != qe->timeout_task)
+    GNUNET_SCHEDULER_cancel (qe->timeout_task);
   GNUNET_free (qe);
 }
 
@@ -968,6 +980,33 @@ GNUNET_NAMESTORE_disconnect (struct 
GNUNET_NAMESTORE_Handle *h)
 
 
 /**
+ * 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
  * remove all records under the given name.
@@ -1048,12 +1087,20 @@ GNUNET_NAMESTORE_records_store (struct 
GNUNET_NAMESTORE_Handle *h,
        "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;
 }
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]