diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-10 21:08:23 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-10 21:08:23 +0200 |
commit | c4202563fb4210adf3eb94fbdb6f40e059b63e37 (patch) | |
tree | 93ffb329f394c9e7bac113f183aacba10c8d4680 /src/namestore/namestore_api.c | |
parent | bb230d4d990db60513c1e8083b46c7b8e91489f5 (diff) | |
download | gnunet-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/namestore_api.c')
-rw-r--r-- | src/namestore/namestore_api.c | 49 |
1 files changed, 48 insertions, 1 deletions
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 | */ | ||
988 | static void | ||
989 | warn_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 | ||