diff options
Diffstat (limited to 'src/rest/plugin_rest_config.c')
-rw-r--r-- | src/rest/plugin_rest_config.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/rest/plugin_rest_config.c b/src/rest/plugin_rest_config.c index d9ae57acd..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 | { |
@@ -392,15 +418,13 @@ libgnunet_plugin_rest_config_init (void *cls) | |||
392 | cfg = cls; | 418 | cfg = cls; |
393 | struct GNUNET_REST_Plugin *api; | 419 | struct GNUNET_REST_Plugin *api; |
394 | 420 | ||
395 | if (NULL != plugin.cfg) | ||
396 | return NULL; /* can only initialize once! */ | ||
397 | memset (&plugin, 0, sizeof(struct Plugin)); | 421 | memset (&plugin, 0, sizeof(struct Plugin)); |
398 | plugin.cfg = cfg; | 422 | plugin.cfg = cfg; |
399 | api = GNUNET_new (struct GNUNET_REST_Plugin); | 423 | api = GNUNET_new (struct GNUNET_REST_Plugin); |
400 | api->cls = &plugin; | 424 | api->cls = &plugin; |
401 | api->name = GNUNET_REST_API_NS_CONFIG; | 425 | api->name = GNUNET_REST_API_NS_CONFIG; |
402 | api->process_request = &rest_config_process_request; | 426 | api->process_request = &rest_config_process_request; |
403 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("CONFIG REST API initialized\n")); | 427 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("CONFIG REST API initialized\n")); |
404 | return api; | 428 | return api; |
405 | } | 429 | } |
406 | 430 | ||
@@ -415,8 +439,11 @@ void * | |||
415 | libgnunet_plugin_rest_config_done (void *cls) | 439 | libgnunet_plugin_rest_config_done (void *cls) |
416 | { | 440 | { |
417 | struct GNUNET_REST_Plugin *api = cls; | 441 | struct GNUNET_REST_Plugin *api = cls; |
418 | struct Plugin *plugin = api->cls; | 442 | struct Plugin *plugin; |
419 | 443 | ||
444 | while (NULL != requests_head) | ||
445 | cleanup_handle (requests_head); | ||
446 | plugin = api->cls; | ||
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"); |