diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gns/plugin_rest_gns.c | 36 | ||||
-rw-r--r-- | src/identity/plugin_rest_identity.c | 33 | ||||
-rw-r--r-- | src/namestore/plugin_rest_namestore.c | 39 | ||||
-rw-r--r-- | src/peerinfo-tool/plugin_rest_peerinfo.c | 36 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_openid_connect.c | 58 | ||||
-rw-r--r-- | src/reclaim/plugin_rest_reclaim.c | 35 | ||||
-rw-r--r-- | src/rest/plugin_rest_config.c | 31 | ||||
-rw-r--r-- | src/rest/plugin_rest_copying.c | 28 |
8 files changed, 252 insertions, 44 deletions
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c index 1d560515c..6ec921f70 100644 --- a/src/gns/plugin_rest_gns.c +++ b/src/gns/plugin_rest_gns.c | |||
@@ -81,6 +81,16 @@ struct Plugin | |||
81 | struct RequestHandle | 81 | struct RequestHandle |
82 | { | 82 | { |
83 | /** | 83 | /** |
84 | * DLL | ||
85 | */ | ||
86 | struct RequestHandle *next; | ||
87 | |||
88 | /** | ||
89 | * DLL | ||
90 | */ | ||
91 | struct RequestHandle *prev; | ||
92 | |||
93 | /** | ||
84 | * Active GNS lookup | 94 | * Active GNS lookup |
85 | */ | 95 | */ |
86 | struct GNUNET_GNS_LookupWithTldRequest *gns_lookup; | 96 | struct GNUNET_GNS_LookupWithTldRequest *gns_lookup; |
@@ -136,6 +146,15 @@ struct RequestHandle | |||
136 | int response_code; | 146 | int response_code; |
137 | }; | 147 | }; |
138 | 148 | ||
149 | /** | ||
150 | * DLL | ||
151 | */ | ||
152 | static struct RequestHandle *requests_head; | ||
153 | |||
154 | /** | ||
155 | * DLL | ||
156 | */ | ||
157 | static struct RequestHandle *requests_tail; | ||
139 | 158 | ||
140 | /** | 159 | /** |
141 | * Cleanup lookup handle | 160 | * Cleanup lookup handle |
@@ -165,6 +184,9 @@ cleanup_handle (void *cls) | |||
165 | if (NULL != handle->emsg) | 184 | if (NULL != handle->emsg) |
166 | GNUNET_free (handle->emsg); | 185 | GNUNET_free (handle->emsg); |
167 | 186 | ||
187 | GNUNET_CONTAINER_DLL_remove (requests_head, | ||
188 | requests_tail, | ||
189 | handle); | ||
168 | GNUNET_free (handle); | 190 | GNUNET_free (handle); |
169 | } | 191 | } |
170 | 192 | ||
@@ -198,7 +220,7 @@ do_error (void *cls) | |||
198 | handle->proc (handle->proc_cls, resp, handle->response_code); | 220 | handle->proc (handle->proc_cls, resp, handle->response_code); |
199 | json_decref (json_error); | 221 | json_decref (json_error); |
200 | GNUNET_free (response); | 222 | GNUNET_free (response); |
201 | GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); | 223 | cleanup_handle(handle); |
202 | } | 224 | } |
203 | 225 | ||
204 | 226 | ||
@@ -374,8 +396,12 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
374 | handle->proc_cls = proc_cls; | 396 | handle->proc_cls = proc_cls; |
375 | handle->proc = proc; | 397 | handle->proc = proc; |
376 | handle->rest_handle = rest_handle; | 398 | handle->rest_handle = rest_handle; |
377 | |||
378 | handle->url = GNUNET_strdup (rest_handle->url); | 399 | handle->url = GNUNET_strdup (rest_handle->url); |
400 | handle->timeout_task = | ||
401 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
402 | GNUNET_CONTAINER_DLL_insert (requests_head, | ||
403 | requests_tail, | ||
404 | handle); | ||
379 | if (handle->url[strlen (handle->url) - 1] == '/') | 405 | if (handle->url[strlen (handle->url) - 1] == '/') |
380 | handle->url[strlen (handle->url) - 1] = '\0'; | 406 | handle->url[strlen (handle->url) - 1] = '\0'; |
381 | if (GNUNET_NO == | 407 | if (GNUNET_NO == |
@@ -386,8 +412,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
386 | } | 412 | } |
387 | 413 | ||
388 | 414 | ||
389 | handle->timeout_task = | ||
390 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
391 | return GNUNET_YES; | 415 | return GNUNET_YES; |
392 | } | 416 | } |
393 | 417 | ||
@@ -435,8 +459,12 @@ void * | |||
435 | libgnunet_plugin_rest_gns_done (void *cls) | 459 | libgnunet_plugin_rest_gns_done (void *cls) |
436 | { | 460 | { |
437 | struct GNUNET_REST_Plugin *api = cls; | 461 | struct GNUNET_REST_Plugin *api = cls; |
462 | struct RequestHandle *request; | ||
438 | struct Plugin *plugin; | 463 | struct Plugin *plugin; |
439 | 464 | ||
465 | while (NULL != (request = requests_head)) | ||
466 | do_error (request); | ||
467 | |||
440 | if (NULL != gns) | 468 | if (NULL != gns) |
441 | GNUNET_GNS_disconnect (gns); | 469 | GNUNET_GNS_disconnect (gns); |
442 | 470 | ||
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c index 5e7d719f0..4e32b73dd 100644 --- a/src/identity/plugin_rest_identity.c +++ b/src/identity/plugin_rest_identity.c | |||
@@ -191,6 +191,16 @@ struct EgoEntry | |||
191 | struct RequestHandle | 191 | struct RequestHandle |
192 | { | 192 | { |
193 | /** | 193 | /** |
194 | * DLL | ||
195 | */ | ||
196 | struct RequestHandle *next; | ||
197 | |||
198 | /** | ||
199 | * DLL | ||
200 | */ | ||
201 | struct RequestHandle *prev; | ||
202 | |||
203 | /** | ||
194 | * The data from the REST request | 204 | * The data from the REST request |
195 | */ | 205 | */ |
196 | const char *data; | 206 | const char *data; |
@@ -252,6 +262,16 @@ struct RequestHandle | |||
252 | }; | 262 | }; |
253 | 263 | ||
254 | /** | 264 | /** |
265 | * DLL | ||
266 | */ | ||
267 | static struct RequestHandle *requests_head; | ||
268 | |||
269 | /** | ||
270 | * DLL | ||
271 | */ | ||
272 | static struct RequestHandle *requests_tail; | ||
273 | |||
274 | /** | ||
255 | * Cleanup lookup handle | 275 | * Cleanup lookup handle |
256 | * @param handle Handle to clean up | 276 | * @param handle Handle to clean up |
257 | */ | 277 | */ |
@@ -273,7 +293,9 @@ cleanup_handle (void *cls) | |||
273 | GNUNET_free (handle->emsg); | 293 | GNUNET_free (handle->emsg); |
274 | if (NULL != handle->name) | 294 | if (NULL != handle->name) |
275 | GNUNET_free (handle->name); | 295 | GNUNET_free (handle->name); |
276 | 296 | GNUNET_CONTAINER_DLL_remove (requests_head, | |
297 | requests_tail, | ||
298 | handle); | ||
277 | GNUNET_free (handle); | 299 | GNUNET_free (handle); |
278 | } | 300 | } |
279 | 301 | ||
@@ -1310,6 +1332,11 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1310 | handle->url = GNUNET_strdup (rest_handle->url); | 1332 | handle->url = GNUNET_strdup (rest_handle->url); |
1311 | if (handle->url[strlen (handle->url) - 1] == '/') | 1333 | if (handle->url[strlen (handle->url) - 1] == '/') |
1312 | handle->url[strlen (handle->url) - 1] = '\0'; | 1334 | handle->url[strlen (handle->url) - 1] = '\0'; |
1335 | handle->timeout_task = | ||
1336 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle); | ||
1337 | GNUNET_CONTAINER_DLL_insert (requests_head, | ||
1338 | requests_tail, | ||
1339 | handle); | ||
1313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); | 1340 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); |
1314 | if (GNUNET_NO == | 1341 | if (GNUNET_NO == |
1315 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) | 1342 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) |
@@ -1318,8 +1345,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
1318 | return GNUNET_NO; | 1345 | return GNUNET_NO; |
1319 | } | 1346 | } |
1320 | 1347 | ||
1321 | handle->timeout_task = | ||
1322 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle); | ||
1323 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); | 1348 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); |
1324 | return GNUNET_YES; | 1349 | return GNUNET_YES; |
1325 | } | 1350 | } |
@@ -1376,6 +1401,8 @@ libgnunet_plugin_rest_identity_done (void *cls) | |||
1376 | struct EgoEntry *ego_tmp; | 1401 | struct EgoEntry *ego_tmp; |
1377 | 1402 | ||
1378 | plugin->cfg = NULL; | 1403 | plugin->cfg = NULL; |
1404 | while (NULL != requests_head) | ||
1405 | cleanup_handle (requests_head); | ||
1379 | if (NULL != identity_handle) | 1406 | if (NULL != identity_handle) |
1380 | GNUNET_IDENTITY_disconnect (identity_handle); | 1407 | GNUNET_IDENTITY_disconnect (identity_handle); |
1381 | 1408 | ||
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) |
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/peerinfo-tool/plugin_rest_peerinfo.c index 669330b39..99cec7e58 100644 --- a/src/peerinfo-tool/plugin_rest_peerinfo.c +++ b/src/peerinfo-tool/plugin_rest_peerinfo.c | |||
@@ -180,6 +180,16 @@ static struct PrintContext *pc_tail; | |||
180 | struct RequestHandle | 180 | struct RequestHandle |
181 | { | 181 | { |
182 | /** | 182 | /** |
183 | * DLL | ||
184 | */ | ||
185 | struct RequestHandle *next; | ||
186 | |||
187 | /** | ||
188 | * DLL | ||
189 | */ | ||
190 | struct RequestHandle *prev; | ||
191 | |||
192 | /** | ||
183 | * JSON temporary array | 193 | * JSON temporary array |
184 | */ | 194 | */ |
185 | json_t *temp_array; | 195 | json_t *temp_array; |
@@ -251,6 +261,15 @@ struct RequestHandle | |||
251 | int response_code; | 261 | int response_code; |
252 | }; | 262 | }; |
253 | 263 | ||
264 | /** | ||
265 | * DLL | ||
266 | */ | ||
267 | static struct RequestHandle *requests_head; | ||
268 | |||
269 | /** | ||
270 | * DLL | ||
271 | */ | ||
272 | static struct RequestHandle *requests_tail; | ||
254 | 273 | ||
255 | /** | 274 | /** |
256 | * Cleanup lookup handle | 275 | * Cleanup lookup handle |
@@ -300,7 +319,9 @@ cleanup_handle (void *cls) | |||
300 | GNUNET_PEERINFO_disconnect (peerinfo_handle); | 319 | GNUNET_PEERINFO_disconnect (peerinfo_handle); |
301 | peerinfo_handle = NULL; | 320 | peerinfo_handle = NULL; |
302 | } | 321 | } |
303 | 322 | GNUNET_CONTAINER_DLL_remove (requests_head, | |
323 | requests_tail, | ||
324 | handle); | ||
304 | GNUNET_free (handle); | 325 | GNUNET_free (handle); |
305 | } | 326 | } |
306 | 327 | ||
@@ -733,6 +754,13 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
733 | handle->url = GNUNET_strdup (rest_handle->url); | 754 | handle->url = GNUNET_strdup (rest_handle->url); |
734 | if (handle->url[strlen (handle->url) - 1] == '/') | 755 | if (handle->url[strlen (handle->url) - 1] == '/') |
735 | handle->url[strlen (handle->url) - 1] = '\0'; | 756 | handle->url[strlen (handle->url) - 1] = '\0'; |
757 | handle->timeout_task = | ||
758 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | ||
759 | &do_error, | ||
760 | handle); | ||
761 | GNUNET_CONTAINER_DLL_insert (requests_head, | ||
762 | requests_tail, | ||
763 | handle); | ||
736 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); | 764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n"); |
737 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle, | 765 | if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle, |
738 | handlers, | 766 | handlers, |
@@ -742,10 +770,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
742 | cleanup_handle (handle); | 770 | cleanup_handle (handle); |
743 | return GNUNET_NO; | 771 | return GNUNET_NO; |
744 | } | 772 | } |
745 | handle->timeout_task = | ||
746 | GNUNET_SCHEDULER_add_delayed (handle->timeout, | ||
747 | &do_error, | ||
748 | handle); | ||
749 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); | 773 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n"); |
750 | return GNUNET_YES; | 774 | return GNUNET_YES; |
751 | } | 775 | } |
@@ -800,6 +824,8 @@ libgnunet_plugin_rest_peerinfo_done (void *cls) | |||
800 | struct Plugin *plugin = api->cls; | 824 | struct Plugin *plugin = api->cls; |
801 | 825 | ||
802 | plugin->cfg = NULL; | 826 | plugin->cfg = NULL; |
827 | while (NULL != requests_head) | ||
828 | cleanup_handle (requests_head); | ||
803 | if (NULL != peerinfo_handle) | 829 | if (NULL != peerinfo_handle) |
804 | GNUNET_PEERINFO_disconnect (peerinfo_handle); | 830 | GNUNET_PEERINFO_disconnect (peerinfo_handle); |
805 | 831 | ||
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c index 0a6ed3b7f..6db494433 100644 --- a/src/reclaim/plugin_rest_openid_connect.c +++ b/src/reclaim/plugin_rest_openid_connect.c | |||
@@ -393,6 +393,15 @@ struct EgoEntry | |||
393 | 393 | ||
394 | struct RequestHandle | 394 | struct RequestHandle |
395 | { | 395 | { |
396 | /** | ||
397 | * DLL | ||
398 | */ | ||
399 | struct RequestHandle *next; | ||
400 | |||
401 | /** | ||
402 | * DLL | ||
403 | */ | ||
404 | struct RequestHandle *prev; | ||
396 | 405 | ||
397 | /** | 406 | /** |
398 | * Selected ego | 407 | * Selected ego |
@@ -528,6 +537,16 @@ struct RequestHandle | |||
528 | int public_client; | 537 | int public_client; |
529 | }; | 538 | }; |
530 | 539 | ||
540 | /** | ||
541 | * DLL | ||
542 | */ | ||
543 | static struct RequestHandle *requests_head; | ||
544 | |||
545 | /** | ||
546 | * DLL | ||
547 | */ | ||
548 | static struct RequestHandle *requests_tail; | ||
549 | |||
531 | 550 | ||
532 | /** | 551 | /** |
533 | * Cleanup lookup handle | 552 | * Cleanup lookup handle |
@@ -573,18 +592,13 @@ cleanup_handle (struct RequestHandle *handle) | |||
573 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_userinfo_list); | 592 | GNUNET_RECLAIM_attribute_list_destroy (handle->attr_userinfo_list); |
574 | if (NULL!=handle->attests_list) | 593 | if (NULL!=handle->attests_list) |
575 | GNUNET_RECLAIM_attestation_list_destroy (handle->attests_list); | 594 | GNUNET_RECLAIM_attestation_list_destroy (handle->attests_list); |
576 | 595 | GNUNET_CONTAINER_DLL_remove (requests_head, | |
596 | requests_tail, | ||
597 | handle); | ||
577 | GNUNET_free (handle); | 598 | GNUNET_free (handle); |
578 | } | 599 | } |
579 | 600 | ||
580 | 601 | ||
581 | static void | ||
582 | cleanup_handle_delayed (void *cls) | ||
583 | { | ||
584 | cleanup_handle (cls); | ||
585 | } | ||
586 | |||
587 | |||
588 | /** | 602 | /** |
589 | * Task run on error, sends error message. Cleans up everything. | 603 | * Task run on error, sends error message. Cleans up everything. |
590 | * | 604 | * |
@@ -613,7 +627,7 @@ do_error (void *cls) | |||
613 | MHD_HTTP_HEADER_CONTENT_TYPE, | 627 | MHD_HTTP_HEADER_CONTENT_TYPE, |
614 | "application/json"); | 628 | "application/json"); |
615 | handle->proc (handle->proc_cls, resp, handle->response_code); | 629 | handle->proc (handle->proc_cls, resp, handle->response_code); |
616 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 630 | cleanup_handle (handle); |
617 | GNUNET_free (json_error); | 631 | GNUNET_free (json_error); |
618 | } | 632 | } |
619 | 633 | ||
@@ -640,7 +654,7 @@ do_userinfo_error (void *cls) | |||
640 | resp = GNUNET_REST_create_response (""); | 654 | resp = GNUNET_REST_create_response (""); |
641 | MHD_add_response_header (resp, MHD_HTTP_HEADER_WWW_AUTHENTICATE, "Bearer"); | 655 | MHD_add_response_header (resp, MHD_HTTP_HEADER_WWW_AUTHENTICATE, "Bearer"); |
642 | handle->proc (handle->proc_cls, resp, handle->response_code); | 656 | handle->proc (handle->proc_cls, resp, handle->response_code); |
643 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 657 | cleanup_handle (handle); |
644 | GNUNET_free (error); | 658 | GNUNET_free (error); |
645 | } | 659 | } |
646 | 660 | ||
@@ -667,7 +681,7 @@ do_redirect_error (void *cls) | |||
667 | resp = GNUNET_REST_create_response (""); | 681 | resp = GNUNET_REST_create_response (""); |
668 | MHD_add_response_header (resp, "Location", redirect); | 682 | MHD_add_response_header (resp, "Location", redirect); |
669 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 683 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
670 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 684 | cleanup_handle (handle); |
671 | GNUNET_free (redirect); | 685 | GNUNET_free (redirect); |
672 | } | 686 | } |
673 | 687 | ||
@@ -897,7 +911,7 @@ login_redirect (void *cls) | |||
897 | } | 911 | } |
898 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 912 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
899 | GNUNET_free (new_redirect); | 913 | GNUNET_free (new_redirect); |
900 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 914 | cleanup_handle (handle); |
901 | } | 915 | } |
902 | 916 | ||
903 | 917 | ||
@@ -974,7 +988,7 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket) | |||
974 | resp = GNUNET_REST_create_response (""); | 988 | resp = GNUNET_REST_create_response (""); |
975 | MHD_add_response_header (resp, "Location", redirect_uri); | 989 | MHD_add_response_header (resp, "Location", redirect_uri); |
976 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 990 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
977 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 991 | cleanup_handle (handle); |
978 | GNUNET_free (redirect_uri); | 992 | GNUNET_free (redirect_uri); |
979 | GNUNET_free (ticket_str); | 993 | GNUNET_free (ticket_str); |
980 | GNUNET_free (code_string); | 994 | GNUNET_free (code_string); |
@@ -1337,7 +1351,7 @@ build_redirect (void *cls) | |||
1337 | resp = GNUNET_REST_create_response (""); | 1351 | resp = GNUNET_REST_create_response (""); |
1338 | MHD_add_response_header (resp, "Location", redirect_uri); | 1352 | MHD_add_response_header (resp, "Location", redirect_uri); |
1339 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); | 1353 | handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND); |
1340 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 1354 | cleanup_handle (handle); |
1341 | GNUNET_free (redirect_uri); | 1355 | GNUNET_free (redirect_uri); |
1342 | return; | 1356 | return; |
1343 | } | 1357 | } |
@@ -1714,7 +1728,7 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1714 | term_data); | 1728 | term_data); |
1715 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); | 1729 | handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST); |
1716 | json_decref (root); | 1730 | json_decref (root); |
1717 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 1731 | cleanup_handle (handle); |
1718 | return; | 1732 | return; |
1719 | } | 1733 | } |
1720 | GNUNET_asprintf (&cookie, "Identity=%s", json_string_value (identity)); | 1734 | GNUNET_asprintf (&cookie, "Identity=%s", json_string_value (identity)); |
@@ -1744,7 +1758,7 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle, | |||
1744 | GNUNET_free (cookie); | 1758 | GNUNET_free (cookie); |
1745 | GNUNET_free (header_val); | 1759 | GNUNET_free (header_val); |
1746 | json_decref (root); | 1760 | json_decref (root); |
1747 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 1761 | cleanup_handle (handle); |
1748 | } | 1762 | } |
1749 | 1763 | ||
1750 | 1764 | ||
@@ -2114,7 +2128,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle, | |||
2114 | GNUNET_free (access_token); | 2128 | GNUNET_free (access_token); |
2115 | GNUNET_free (json_response); | 2129 | GNUNET_free (json_response); |
2116 | GNUNET_free (id_token); | 2130 | GNUNET_free (id_token); |
2117 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 2131 | cleanup_handle (handle); |
2118 | } | 2132 | } |
2119 | 2133 | ||
2120 | 2134 | ||
@@ -2543,14 +2557,17 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle, | |||
2543 | handle->proc = proc; | 2557 | handle->proc = proc; |
2544 | handle->rest_handle = rest_handle; | 2558 | handle->rest_handle = rest_handle; |
2545 | handle->url = GNUNET_strdup (rest_handle->url); | 2559 | handle->url = GNUNET_strdup (rest_handle->url); |
2560 | handle->timeout_task = | ||
2561 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
2562 | GNUNET_CONTAINER_DLL_insert (requests_head, | ||
2563 | requests_tail, | ||
2564 | handle); | ||
2546 | if (handle->url[strlen (handle->url) - 1] == '/') | 2565 | if (handle->url[strlen (handle->url) - 1] == '/') |
2547 | handle->url[strlen (handle->url) - 1] = '\0'; | 2566 | handle->url[strlen (handle->url) - 1] = '\0'; |
2548 | if (GNUNET_NO == | 2567 | if (GNUNET_NO == |
2549 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) | 2568 | GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle)) |
2550 | return GNUNET_NO; | 2569 | return GNUNET_NO; |
2551 | 2570 | ||
2552 | handle->timeout_task = | ||
2553 | GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle); | ||
2554 | return GNUNET_YES; | 2571 | return GNUNET_YES; |
2555 | } | 2572 | } |
2556 | 2573 | ||
@@ -2615,7 +2632,8 @@ libgnunet_plugin_rest_openid_connect_done (void *cls) | |||
2615 | struct EgoEntry *ego_entry; | 2632 | struct EgoEntry *ego_entry; |
2616 | 2633 | ||
2617 | plugin->cfg = NULL; | 2634 | plugin->cfg = NULL; |
2618 | 2635 | while (NULL != requests_head) | |
2636 | cleanup_handle (requests_head); | ||
2619 | if (NULL != OIDC_cookie_jar_map) | 2637 | if (NULL != OIDC_cookie_jar_map) |
2620 | { | 2638 | { |
2621 | GNUNET_CONTAINER_multihashmap_iterate (OIDC_cookie_jar_map, | 2639 | GNUNET_CONTAINER_multihashmap_iterate (OIDC_cookie_jar_map, |
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) |
diff --git a/src/rest/plugin_rest_config.c b/src/rest/plugin_rest_config.c index e5d0fffb0..af833efff 100644 --- a/src/rest/plugin_rest_config.c +++ b/src/rest/plugin_rest_config.c | |||
@@ -45,6 +45,16 @@ const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
45 | struct RequestHandle | 45 | struct RequestHandle |
46 | { | 46 | { |
47 | /** | 47 | /** |
48 | * DLL | ||
49 | */ | ||
50 | struct RequestHandle *next; | ||
51 | |||
52 | /** | ||
53 | * DLL | ||
54 | */ | ||
55 | struct RequestHandle *prev; | ||
56 | |||
57 | /** | ||
48 | * Handle to rest request | 58 | * Handle to rest request |
49 | */ | 59 | */ |
50 | struct GNUNET_REST_RequestHandle *rest_handle; | 60 | struct GNUNET_REST_RequestHandle *rest_handle; |
@@ -70,6 +80,17 @@ struct RequestHandle | |||
70 | char *url; | 80 | char *url; |
71 | }; | 81 | }; |
72 | 82 | ||
83 | /** | ||
84 | * DLL | ||
85 | */ | ||
86 | static struct RequestHandle *requests_head; | ||
87 | |||
88 | /** | ||
89 | * DLL | ||
90 | */ | ||
91 | static struct RequestHandle *requests_tail; | ||
92 | |||
93 | |||
73 | 94 | ||
74 | /** | 95 | /** |
75 | * Cleanup request handle. | 96 | * Cleanup request handle. |
@@ -82,6 +103,9 @@ cleanup_handle (struct RequestHandle *handle) | |||
82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); | 103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n"); |
83 | if (NULL != handle->url) | 104 | if (NULL != handle->url) |
84 | GNUNET_free (handle->url); | 105 | GNUNET_free (handle->url); |
106 | GNUNET_CONTAINER_DLL_remove (requests_head, | ||
107 | requests_tail, | ||
108 | handle); | ||
85 | GNUNET_free (handle); | 109 | GNUNET_free (handle); |
86 | } | 110 | } |
87 | 111 | ||
@@ -367,7 +391,9 @@ rest_config_process_request (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
367 | handle->url = GNUNET_strdup (conndata_handle->url); | 391 | handle->url = GNUNET_strdup (conndata_handle->url); |
368 | if (handle->url[strlen (handle->url) - 1] == '/') | 392 | if (handle->url[strlen (handle->url) - 1] == '/') |
369 | handle->url[strlen (handle->url) - 1] = '\0'; | 393 | handle->url[strlen (handle->url) - 1] = '\0'; |
370 | 394 | GNUNET_CONTAINER_DLL_insert (requests_head, | |
395 | requests_tail, | ||
396 | handle); | ||
371 | if (GNUNET_NO == | 397 | if (GNUNET_NO == |
372 | GNUNET_REST_handle_request (conndata_handle, handlers, &err, handle)) | 398 | GNUNET_REST_handle_request (conndata_handle, handlers, &err, handle)) |
373 | { | 399 | { |
@@ -415,8 +441,9 @@ libgnunet_plugin_rest_config_done (void *cls) | |||
415 | struct GNUNET_REST_Plugin *api = cls; | 441 | struct GNUNET_REST_Plugin *api = cls; |
416 | struct Plugin *plugin; | 442 | struct Plugin *plugin; |
417 | 443 | ||
444 | while (NULL != requests_head) | ||
445 | cleanup_handle (requests_head); | ||
418 | plugin = api->cls; | 446 | plugin = api->cls; |
419 | |||
420 | plugin->cfg = NULL; | 447 | plugin->cfg = NULL; |
421 | GNUNET_free (api); | 448 | GNUNET_free (api); |
422 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONFIG REST plugin is finished\n"); | 449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONFIG REST plugin is finished\n"); |
diff --git a/src/rest/plugin_rest_copying.c b/src/rest/plugin_rest_copying.c index 1649da3bb..6d074d3d1 100644 --- a/src/rest/plugin_rest_copying.c +++ b/src/rest/plugin_rest_copying.c | |||
@@ -46,6 +46,16 @@ const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
46 | struct RequestHandle | 46 | struct RequestHandle |
47 | { | 47 | { |
48 | /** | 48 | /** |
49 | * DLL | ||
50 | */ | ||
51 | struct RequestHandle *next; | ||
52 | |||
53 | /** | ||
54 | * DLL | ||
55 | */ | ||
56 | struct RequestHandle *prev; | ||
57 | |||
58 | /** | ||
49 | * Handle to rest request | 59 | * Handle to rest request |
50 | */ | 60 | */ |
51 | struct GNUNET_REST_RequestHandle *rest_handle; | 61 | struct GNUNET_REST_RequestHandle *rest_handle; |
@@ -66,6 +76,15 @@ struct RequestHandle | |||
66 | int response_code; | 76 | int response_code; |
67 | }; | 77 | }; |
68 | 78 | ||
79 | /** | ||
80 | * DLL | ||
81 | */ | ||
82 | static struct RequestHandle *requests_head; | ||
83 | |||
84 | /** | ||
85 | * DLL | ||
86 | */ | ||
87 | static struct RequestHandle *requests_tail; | ||
69 | 88 | ||
70 | /** | 89 | /** |
71 | * Cleanup request handle. | 90 | * Cleanup request handle. |
@@ -77,6 +96,9 @@ cleanup_handle (struct RequestHandle *handle) | |||
77 | { | 96 | { |
78 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 97 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
79 | "Cleaning up\n"); | 98 | "Cleaning up\n"); |
99 | GNUNET_CONTAINER_DLL_remove (requests_head, | ||
100 | requests_tail, | ||
101 | handle); | ||
80 | GNUNET_free (handle); | 102 | GNUNET_free (handle); |
81 | } | 103 | } |
82 | 104 | ||
@@ -153,7 +175,9 @@ rest_copying_process_request (struct GNUNET_REST_RequestHandle *conndata_handle, | |||
153 | handle->proc_cls = proc_cls; | 175 | handle->proc_cls = proc_cls; |
154 | handle->proc = proc; | 176 | handle->proc = proc; |
155 | handle->rest_handle = conndata_handle; | 177 | handle->rest_handle = conndata_handle; |
156 | 178 | GNUNET_CONTAINER_DLL_insert (requests_head, | |
179 | requests_tail, | ||
180 | handle); | ||
157 | return GNUNET_REST_handle_request (conndata_handle, | 181 | return GNUNET_REST_handle_request (conndata_handle, |
158 | handlers, | 182 | handlers, |
159 | &err, | 183 | &err, |
@@ -201,6 +225,8 @@ libgnunet_plugin_rest_copying_done (void *cls) | |||
201 | struct GNUNET_REST_Plugin *api = cls; | 225 | struct GNUNET_REST_Plugin *api = cls; |
202 | struct Plugin *plugin = api->cls; | 226 | struct Plugin *plugin = api->cls; |
203 | 227 | ||
228 | while (NULL != requests_head) | ||
229 | cleanup_handle (requests_head); | ||
204 | plugin->cfg = NULL; | 230 | plugin->cfg = NULL; |
205 | GNUNET_free (api); | 231 | GNUNET_free (api); |
206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |