aboutsummaryrefslogtreecommitdiff
path: root/src/namestore
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-10 21:08:23 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-10 21:08:23 +0200
commitc4202563fb4210adf3eb94fbdb6f40e059b63e37 (patch)
tree93ffb329f394c9e7bac113f183aacba10c8d4680 /src/namestore
parentbb230d4d990db60513c1e8083b46c7b8e91489f5 (diff)
downloadgnunet-c4202563fb4210adf3eb94fbdb6f40e059b63e37.tar.gz
gnunet-c4202563fb4210adf3eb94fbdb6f40e059b63e37.zip
watch for namestore not completing store operations, add auto-abort with warning plus statistics to detect
Diffstat (limited to 'src/namestore')
-rw-r--r--src/namestore/gnunet-service-namestore.c8
-rw-r--r--src/namestore/namestore_api.c49
2 files changed, 56 insertions, 1 deletions
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,
681 681
682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 682 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
683 "Sending RECORD_STORE_RESPONSE message\n"); 683 "Sending RECORD_STORE_RESPONSE message\n");
684 GNUNET_STATISTICS_update (statistics,
685 "Store requests completed",
686 1,
687 GNUNET_NO);
684 env = GNUNET_MQ_msg (rcr_msg, 688 env = GNUNET_MQ_msg (rcr_msg,
685 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE); 689 GNUNET_MESSAGE_TYPE_NAMESTORE_RECORD_STORE_RESPONSE);
686 rcr_msg->gns_header.r_id = htonl (rid); 690 rcr_msg->gns_header.r_id = htonl (rid);
@@ -1308,6 +1312,10 @@ handle_record_store (void *cls,
1308 GNUNET_SERVICE_client_drop (nc->client); 1312 GNUNET_SERVICE_client_drop (nc->client);
1309 return; 1313 return;
1310 } 1314 }
1315 GNUNET_STATISTICS_update (statistics,
1316 "Well-formed store requests received",
1317 1,
1318 GNUNET_NO);
1311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1312 "Creating %u records for name `%s'\n", 1320 "Creating %u records for name `%s'\n",
1313 (unsigned int) rd_count, 1321 (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 @@
40 40
41#define LOG(kind,...) GNUNET_log_from (kind, "namestore-api",__VA_ARGS__) 41#define LOG(kind,...) GNUNET_log_from (kind, "namestore-api",__VA_ARGS__)
42 42
43/**
44 * We grant the namestore up to 1 minute of latency, if it is slower than
45 * that, store queries will fail.
46 */
47#define NAMESTORE_DELAY_TOLERANCE GNUNET_TIME_UNIT_MINUTES
43 48
44/** 49/**
45 * An QueueEntry used to store information for a pending 50 * An QueueEntry used to store information for a pending
@@ -100,6 +105,11 @@ struct GNUNET_NAMESTORE_QueueEntry
100 struct GNUNET_MQ_Envelope *env; 105 struct GNUNET_MQ_Envelope *env;
101 106
102 /** 107 /**
108 * Task scheduled to warn us if the namestore is way too slow.
109 */
110 struct GNUNET_SCHEDULER_Task *timeout_task;
111
112 /**
103 * The operation id this zone iteration operation has 113 * The operation id this zone iteration operation has
104 */ 114 */
105 uint32_t op_id; 115 uint32_t op_id;
@@ -300,6 +310,8 @@ free_qe (struct GNUNET_NAMESTORE_QueueEntry *qe)
300 qe); 310 qe);
301 if (NULL != qe->env) 311 if (NULL != qe->env)
302 GNUNET_MQ_discard (qe->env); 312 GNUNET_MQ_discard (qe->env);
313 if (NULL != qe->timeout_task)
314 GNUNET_SCHEDULER_cancel (qe->timeout_task);
303 GNUNET_free (qe); 315 GNUNET_free (qe);
304} 316}
305 317
@@ -968,6 +980,33 @@ GNUNET_NAMESTORE_disconnect (struct GNUNET_NAMESTORE_Handle *h)
968 980
969 981
970/** 982/**
983 * Task launched to warn the user that the namestore is
984 * excessively slow and that a query was thus dropped.
985 *
986 * @param cls a `struct GNUNET_NAMESTORE_QueueEntry *`
987 */
988static void
989warn_delay (void *cls)
990{
991 struct GNUNET_NAMESTORE_QueueEntry *qe = cls;
992
993 qe->timeout_task = NULL;
994 LOG (GNUNET_ERROR_TYPE_WARNING,
995 "Did not receive response from namestore after %s!\n",
996 GNUNET_STRINGS_relative_time_to_string (NAMESTORE_DELAY_TOLERANCE,
997 GNUNET_YES));
998 if (NULL != qe->cont)
999 {
1000 qe->cont (qe->cont_cls,
1001 GNUNET_SYSERR,
1002 "timeout");
1003 qe->cont = NULL;
1004 }
1005 GNUNET_NAMESTORE_cancel (qe);
1006}
1007
1008
1009/**
971 * Store an item in the namestore. If the item is already present, 1010 * Store an item in the namestore. If the item is already present,
972 * it is replaced with the new record. Use an empty array to 1011 * it is replaced with the new record. Use an empty array to
973 * remove all records under the given name. 1012 * remove all records under the given name.
@@ -1048,12 +1087,20 @@ GNUNET_NAMESTORE_records_store (struct GNUNET_NAMESTORE_Handle *h,
1048 "Sending NAMESTORE_RECORD_STORE message for name `%s' with %u records\n", 1087 "Sending NAMESTORE_RECORD_STORE message for name `%s' with %u records\n",
1049 label, 1088 label,
1050 rd_count); 1089 rd_count);
1051 1090 qe->timeout_task = GNUNET_SCHEDULER_add_delayed (NAMESTORE_DELAY_TOLERANCE,
1091 &warn_delay,
1092 qe);
1052 if (NULL == h->mq) 1093 if (NULL == h->mq)
1094 {
1053 qe->env = env; 1095 qe->env = env;
1096 LOG (GNUNET_ERROR_TYPE_WARNING,
1097 "Delaying NAMESTORE_RECORD_STORE message as namestore is not ready!\n");
1098 }
1054 else 1099 else
1100 {
1055 GNUNET_MQ_send (h->mq, 1101 GNUNET_MQ_send (h->mq,
1056 env); 1102 env);
1103 }
1057 return qe; 1104 return qe;
1058} 1105}
1059 1106