diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-06 23:06:16 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-06 23:06:16 +0200 |
commit | 7648cde6cfb181f03df9e145a576430220234f5f (patch) | |
tree | 987badd6024e09608b47e72f56052cf79f67b405 /src/namestore | |
parent | 19fe8e8ff74a9639fc075f5d974a01a977e1196a (diff) | |
download | gnunet-7648cde6cfb181f03df9e145a576430220234f5f.tar.gz gnunet-7648cde6cfb181f03df9e145a576430220234f5f.zip |
-improve request cleanup handling
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/plugin_rest_namestore.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index 0d52b5625..9354b9896 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c | |||
@@ -161,6 +161,16 @@ enum UpdateStrategy | |||
161 | struct RequestHandle | 161 | struct RequestHandle |
162 | { | 162 | { |
163 | /** | 163 | /** |
164 | * DLL | ||
165 | */ | ||
166 | struct RequestHandle *next; | ||
167 | |||
168 | /** | ||
169 | * DLL | ||
170 | */ | ||
171 | struct RequestHandle *prev; | ||
172 | |||
173 | /** | ||
164 | * Records to store | 174 | * Records to store |
165 | */ | 175 | */ |
166 | char *record_name; | 176 | char *record_name; |
@@ -258,6 +268,17 @@ struct RequestHandle | |||
258 | }; | 268 | }; |
259 | 269 | ||
260 | /** | 270 | /** |
271 | * DLL | ||
272 | */ | ||
273 | static struct RequestHandle *requests_head; | ||
274 | |||
275 | /** | ||
276 | * DLL | ||
277 | */ | ||
278 | static struct RequestHandle *requests_tail; | ||
279 | |||
280 | |||
281 | /** | ||
261 | * Cleanup lookup handle | 282 | * Cleanup lookup handle |
262 | * @param handle Handle to clean up | 283 | * @param handle Handle to clean up |
263 | */ | 284 | */ |
@@ -298,7 +319,9 @@ cleanup_handle (void *cls) | |||
298 | { | 319 | { |
299 | json_decref (handle->resp_object); | 320 | json_decref (handle->resp_object); |
300 | } | 321 | } |
301 | 322 | GNUNET_CONTAINER_DLL_remove (requests_head, | |
323 | requests_tail, | ||
324 | handle); | ||
302 | GNUNET_free (handle); | 325 | GNUNET_free (handle); |
303 | } | 326 | } |
304 | 327 | ||
@@ -329,7 +352,7 @@ do_error (void *cls) | |||
329 | handle->proc (handle->proc_cls, resp, handle->response_code); | 352 | handle->proc (handle->proc_cls, resp, handle->response_code); |
330 | json_decref (json_error); | 353 | json_decref (json_error); |
331 | GNUNET_free (response); | 354 | GNUNET_free (response); |
332 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 355 | cleanup_handle (handle); |
333 | } | 356 | } |
334 | 357 | ||
335 | 358 | ||
@@ -1024,10 +1047,14 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1024 | handle->proc = proc; | 1047 | handle->proc = proc; |
1025 | handle->rest_handle = rest_handle; | 1048 | handle->rest_handle = rest_handle; |
1026 | handle->zone_pkey = NULL; | 1049 | handle->zone_pkey = NULL; |
1027 | 1050 | handle->timeout_task = | |
1051 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle); | ||
1028 | handle->url = GNUNET_strdup (rest_handle->url); | 1052 | handle->url = GNUNET_strdup (rest_handle->url); |
1029 | if (handle->url[strlen (handle->url) - 1] == '/') | 1053 | if (handle->url[strlen (handle->url) - 1] == '/') |
1030 | handle->url[strlen (handle->url) - 1] = '\0'; | 1054 | handle->url[strlen (handle->url) - 1] = '\0'; |
1055 | GNUNET_CONTAINER_DLL_insert (requests_head, | ||
1056 | requests_tail, | ||
1057 | handle); | ||
1031 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); | 1058 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); |
1032 | if (GNUNET_NO == | 1059 | if (GNUNET_NO == |
1033 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) | 1060 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) |
@@ -1036,9 +1063,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1036 | return GNUNET_NO; | 1063 | return GNUNET_NO; |
1037 | } | 1064 | } |
1038 | 1065 | ||
1039 | handle->timeout_task = | ||
1040 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle); | ||
1041 | |||
1042 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); | 1066 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); |
1043 | return GNUNET_YES; | 1067 | return GNUNET_YES; |
1044 | } | 1068 | } |
@@ -1092,10 +1116,13 @@ libgnunet_plugin_rest_namestore_done (void *cls) | |||
1092 | { | 1116 | { |
1093 | struct GNUNET_REST_Plugin *api = cls; | 1117 | struct GNUNET_REST_Plugin *api = cls; |
1094 | struct Plugin *plugin = api->cls; | 1118 | struct Plugin *plugin = api->cls; |
1119 | struct RequestHandle *request; | ||
1095 | struct EgoEntry *ego_entry; | 1120 | struct EgoEntry *ego_entry; |
1096 | struct EgoEntry *ego_tmp; | 1121 | struct EgoEntry *ego_tmp; |
1097 | 1122 | ||
1098 | plugin->cfg = NULL; | 1123 | plugin->cfg = NULL; |
1124 | while (NULL != (request = requests_head)) | ||
1125 | do_error (request); | ||
1099 | if (NULL != identity_handle) | 1126 | if (NULL != identity_handle) |
1100 | GNUNET_IDENTITY_disconnect (identity_handle); | 1127 | GNUNET_IDENTITY_disconnect (identity_handle); |
1101 | if (NULL != ns_handle) | 1128 | if (NULL != ns_handle) |