diff options
Diffstat (limited to 'src/reclaim/plugin_rest_reclaim.c')
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 35 |
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 | ||
155 | struct RequestHandle | 155 | struct 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 | */ | ||
261 | static struct RequestHandle *requests_head; | ||
262 | |||
263 | /** | ||
264 | * DLL | ||
265 | */ | ||
266 | static 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) | |||
319 | static void | 342 | static void |
320 | collect_error_cb (void *cls) | 343 | collect_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) |