aboutsummaryrefslogtreecommitdiff
path: root/src/reclaim/plugin_rest_reclaim.c
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 23:06:16 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-06 23:06:16 +0200
commit7648cde6cfb181f03df9e145a576430220234f5f (patch)
tree987badd6024e09608b47e72f56052cf79f67b405 /src/reclaim/plugin_rest_reclaim.c
parent19fe8e8ff74a9639fc075f5d974a01a977e1196a (diff)
downloadgnunet-7648cde6cfb181f03df9e145a576430220234f5f.tar.gz
gnunet-7648cde6cfb181f03df9e145a576430220234f5f.zip
-improve request cleanup handling
Diffstat (limited to 'src/reclaim/plugin_rest_reclaim.c')
-rw-r--r--src/reclaim/plugin_rest_reclaim.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/reclaim/plugin_rest_reclaim.c
index 0aeb0647a..870baa7f3 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/reclaim/plugin_rest_reclaim.c
@@ -154,6 +154,15 @@ struct EgoEntry
154 154
155struct RequestHandle 155struct RequestHandle
156{ 156{
157 /**
158 * DLL
159 */
160 struct RequestHandle *next;
161
162 /**
163 * DLL
164 */
165 struct RequestHandle *prev;
157 166
158 /** 167 /**
159 * Selected ego 168 * Selected ego
@@ -247,6 +256,17 @@ struct RequestHandle
247}; 256};
248 257
249/** 258/**
259 * DLL
260 */
261static struct RequestHandle *requests_head;
262
263/**
264 * DLL
265 */
266static struct RequestHandle *requests_tail;
267
268
269/**
250 * Cleanup lookup handle 270 * Cleanup lookup handle
251 * @param handle Handle to clean up 271 * @param handle Handle to clean up
252 */ 272 */
@@ -272,6 +292,9 @@ cleanup_handle (void *cls)
272 GNUNET_free (handle->emsg); 292 GNUNET_free (handle->emsg);
273 if (NULL != handle->attr_list) 293 if (NULL != handle->attr_list)
274 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list); 294 GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list);
295 GNUNET_CONTAINER_DLL_remove (requests_head,
296 requests_tail,
297 handle);
275 GNUNET_free (handle); 298 GNUNET_free (handle);
276} 299}
277 300
@@ -296,7 +319,7 @@ do_error (void *cls)
296 resp = GNUNET_REST_create_response (json_error); 319 resp = GNUNET_REST_create_response (json_error);
297 MHD_add_response_header (resp, "Content-Type", "application/json"); 320 MHD_add_response_header (resp, "Content-Type", "application/json");
298 handle->proc (handle->proc_cls, resp, handle->response_code); 321 handle->proc (handle->proc_cls, resp, handle->response_code);
299 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 322 cleanup_handle (handle);
300 GNUNET_free (json_error); 323 GNUNET_free (json_error);
301} 324}
302 325
@@ -319,7 +342,7 @@ do_timeout (void *cls)
319static void 342static void
320collect_error_cb (void *cls) 343collect_error_cb (void *cls)
321{ 344{
322 do_error (cls); 345 GNUNET_SCHEDULER_add_now (&do_error, cls);
323} 346}
324 347
325 348
@@ -329,6 +352,7 @@ finished_cont (void *cls, int32_t success, const char *emsg)
329 struct RequestHandle *handle = cls; 352 struct RequestHandle *handle = cls;
330 struct MHD_Response *resp; 353 struct MHD_Response *resp;
331 354
355 handle->idp_op = NULL;
332 resp = GNUNET_REST_create_response (emsg); 356 resp = GNUNET_REST_create_response (emsg);
333 MHD_add_response_header (resp, "Content-Type", "application/json"); 357 MHD_add_response_header (resp, "Content-Type", "application/json");
334 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); 358 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
@@ -1429,7 +1453,9 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
1429 handle->url[strlen (handle->url) - 1] = '\0'; 1453 handle->url[strlen (handle->url) - 1] = '\0';
1430 handle->timeout_task = 1454 handle->timeout_task =
1431 GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); 1455 GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
1432 1456 GNUNET_CONTAINER_DLL_insert (requests_head,
1457 requests_tail,
1458 handle);
1433 if (GNUNET_NO == 1459 if (GNUNET_NO ==
1434 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) 1460 GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
1435 { 1461 {
@@ -1489,10 +1515,13 @@ libgnunet_plugin_rest_reclaim_done (void *cls)
1489{ 1515{
1490 struct GNUNET_REST_Plugin *api = cls; 1516 struct GNUNET_REST_Plugin *api = cls;
1491 struct Plugin *plugin = api->cls; 1517 struct Plugin *plugin = api->cls;
1518 struct RequestHandle *request;
1492 struct EgoEntry *ego_entry; 1519 struct EgoEntry *ego_entry;
1493 struct EgoEntry *ego_tmp; 1520 struct EgoEntry *ego_tmp;
1494 1521
1495 plugin->cfg = NULL; 1522 plugin->cfg = NULL;
1523 while (NULL != (request = requests_head))
1524 do_error (request);
1496 if (NULL != idp) 1525 if (NULL != idp)
1497 GNUNET_RECLAIM_disconnect (idp); 1526 GNUNET_RECLAIM_disconnect (idp);
1498 if (NULL != identity_handle) 1527 if (NULL != identity_handle)