summaryrefslogtreecommitdiff
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
parent19fe8e8ff74a9639fc075f5d974a01a977e1196a (diff)
-improve request cleanup handling
-rw-r--r--src/gns/plugin_rest_gns.c36
-rw-r--r--src/identity/plugin_rest_identity.c33
-rw-r--r--src/namestore/plugin_rest_namestore.c39
-rw-r--r--src/peerinfo-tool/plugin_rest_peerinfo.c36
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c58
-rw-r--r--src/reclaim/plugin_rest_reclaim.c35
-rw-r--r--src/rest/plugin_rest_config.c31
-rw-r--r--src/rest/plugin_rest_copying.c28
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
struct RequestHandle
{
/**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
+
+ /**
* Active GNS lookup
*/
struct GNUNET_GNS_LookupWithTldRequest *gns_lookup;
@@ -136,6 +146,15 @@ struct RequestHandle
int response_code;
};
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
/**
* Cleanup lookup handle
@@ -165,6 +184,9 @@ cleanup_handle (void *cls)
if (NULL != handle->emsg)
GNUNET_free (handle->emsg);
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
@@ -198,7 +220,7 @@ do_error (void *cls)
handle->proc (handle->proc_cls, resp, handle->response_code);
json_decref (json_error);
GNUNET_free (response);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+ cleanup_handle(handle);
}
@@ -374,8 +396,12 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
handle->proc_cls = proc_cls;
handle->proc = proc;
handle->rest_handle = rest_handle;
-
handle->url = GNUNET_strdup (rest_handle->url);
+ handle->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
if (handle->url[strlen (handle->url) - 1] == '/')
handle->url[strlen (handle->url) - 1] = '\0';
if (GNUNET_NO ==
@@ -386,8 +412,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
}
- handle->timeout_task =
- GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
return GNUNET_YES;
}
@@ -435,8 +459,12 @@ void *
libgnunet_plugin_rest_gns_done (void *cls)
{
struct GNUNET_REST_Plugin *api = cls;
+ struct RequestHandle *request;
struct Plugin *plugin;
+ while (NULL != (request = requests_head))
+ do_error (request);
+
if (NULL != gns)
GNUNET_GNS_disconnect (gns);
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
struct RequestHandle
{
/**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
+
+ /**
* The data from the REST request
*/
const char *data;
@@ -252,6 +262,16 @@ struct RequestHandle
};
/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
+
+/**
* Cleanup lookup handle
* @param handle Handle to clean up
*/
@@ -273,7 +293,9 @@ cleanup_handle (void *cls)
GNUNET_free (handle->emsg);
if (NULL != handle->name)
GNUNET_free (handle->name);
-
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
@@ -1310,6 +1332,11 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
handle->url = GNUNET_strdup (rest_handle->url);
if (handle->url[strlen (handle->url) - 1] == '/')
handle->url[strlen (handle->url) - 1] = '\0';
+ handle->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle);
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
if (GNUNET_NO ==
GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
@@ -1318,8 +1345,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
return GNUNET_NO;
}
- handle->timeout_task =
- GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
return GNUNET_YES;
}
@@ -1376,6 +1401,8 @@ libgnunet_plugin_rest_identity_done (void *cls)
struct EgoEntry *ego_tmp;
plugin->cfg = NULL;
+ while (NULL != requests_head)
+ cleanup_handle (requests_head);
if (NULL != identity_handle)
GNUNET_IDENTITY_disconnect (identity_handle);
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
struct RequestHandle
{
/**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
+
+ /**
* Records to store
*/
char *record_name;
@@ -258,6 +268,17 @@ struct RequestHandle
};
/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
+
+
+/**
* Cleanup lookup handle
* @param handle Handle to clean up
*/
@@ -298,7 +319,9 @@ cleanup_handle (void *cls)
{
json_decref (handle->resp_object);
}
-
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
@@ -329,7 +352,7 @@ do_error (void *cls)
handle->proc (handle->proc_cls, resp, handle->response_code);
json_decref (json_error);
GNUNET_free (response);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+ cleanup_handle (handle);
}
@@ -1024,10 +1047,14 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
handle->proc = proc;
handle->rest_handle = rest_handle;
handle->zone_pkey = NULL;
-
+ handle->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle);
handle->url = GNUNET_strdup (rest_handle->url);
if (handle->url[strlen (handle->url) - 1] == '/')
handle->url[strlen (handle->url) - 1] = '\0';
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
if (GNUNET_NO ==
GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
@@ -1036,9 +1063,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
return GNUNET_NO;
}
- handle->timeout_task =
- GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_error, handle);
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
return GNUNET_YES;
}
@@ -1092,10 +1116,13 @@ libgnunet_plugin_rest_namestore_done (void *cls)
{
struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
+ struct RequestHandle *request;
struct EgoEntry *ego_entry;
struct EgoEntry *ego_tmp;
plugin->cfg = NULL;
+ while (NULL != (request = requests_head))
+ do_error (request);
if (NULL != identity_handle)
GNUNET_IDENTITY_disconnect (identity_handle);
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;
struct RequestHandle
{
/**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
+
+ /**
* JSON temporary array
*/
json_t *temp_array;
@@ -251,6 +261,15 @@ struct RequestHandle
int response_code;
};
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
/**
* Cleanup lookup handle
@@ -300,7 +319,9 @@ cleanup_handle (void *cls)
GNUNET_PEERINFO_disconnect (peerinfo_handle);
peerinfo_handle = NULL;
}
-
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
@@ -733,6 +754,13 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
handle->url = GNUNET_strdup (rest_handle->url);
if (handle->url[strlen (handle->url) - 1] == '/')
handle->url[strlen (handle->url) - 1] = '\0';
+ handle->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (handle->timeout,
+ &do_error,
+ handle);
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
if (GNUNET_NO == GNUNET_REST_handle_request (handle->rest_handle,
handlers,
@@ -742,10 +770,6 @@ rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
cleanup_handle (handle);
return GNUNET_NO;
}
- handle->timeout_task =
- GNUNET_SCHEDULER_add_delayed (handle->timeout,
- &do_error,
- handle);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected\n");
return GNUNET_YES;
}
@@ -800,6 +824,8 @@ libgnunet_plugin_rest_peerinfo_done (void *cls)
struct Plugin *plugin = api->cls;
plugin->cfg = NULL;
+ while (NULL != requests_head)
+ cleanup_handle (requests_head);
if (NULL != peerinfo_handle)
GNUNET_PEERINFO_disconnect (peerinfo_handle);
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
struct RequestHandle
{
+ /**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
/**
* Selected ego
@@ -528,6 +537,16 @@ struct RequestHandle
int public_client;
};
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
+
/**
* Cleanup lookup handle
@@ -573,18 +592,13 @@ cleanup_handle (struct RequestHandle *handle)
GNUNET_RECLAIM_attribute_list_destroy (handle->attr_userinfo_list);
if (NULL!=handle->attests_list)
GNUNET_RECLAIM_attestation_list_destroy (handle->attests_list);
-
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
-static void
-cleanup_handle_delayed (void *cls)
-{
- cleanup_handle (cls);
-}
-
-
/**
* Task run on error, sends error message. Cleans up everything.
*
@@ -613,7 +627,7 @@ do_error (void *cls)
MHD_HTTP_HEADER_CONTENT_TYPE,
"application/json");
handle->proc (handle->proc_cls, resp, handle->response_code);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
GNUNET_free (json_error);
}
@@ -640,7 +654,7 @@ do_userinfo_error (void *cls)
resp = GNUNET_REST_create_response ("");
MHD_add_response_header (resp, MHD_HTTP_HEADER_WWW_AUTHENTICATE, "Bearer");
handle->proc (handle->proc_cls, resp, handle->response_code);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
GNUNET_free (error);
}
@@ -667,7 +681,7 @@ do_redirect_error (void *cls)
resp = GNUNET_REST_create_response ("");
MHD_add_response_header (resp, "Location", redirect);
handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
GNUNET_free (redirect);
}
@@ -897,7 +911,7 @@ login_redirect (void *cls)
}
handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
GNUNET_free (new_redirect);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
}
@@ -974,7 +988,7 @@ oidc_ticket_issue_cb (void *cls, const struct GNUNET_RECLAIM_Ticket *ticket)
resp = GNUNET_REST_create_response ("");
MHD_add_response_header (resp, "Location", redirect_uri);
handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
GNUNET_free (redirect_uri);
GNUNET_free (ticket_str);
GNUNET_free (code_string);
@@ -1337,7 +1351,7 @@ build_redirect (void *cls)
resp = GNUNET_REST_create_response ("");
MHD_add_response_header (resp, "Location", redirect_uri);
handle->proc (handle->proc_cls, resp, MHD_HTTP_FOUND);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
GNUNET_free (redirect_uri);
return;
}
@@ -1714,7 +1728,7 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle,
term_data);
handle->proc (handle->proc_cls, resp, MHD_HTTP_BAD_REQUEST);
json_decref (root);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
return;
}
GNUNET_asprintf (&cookie, "Identity=%s", json_string_value (identity));
@@ -1744,7 +1758,7 @@ login_cont (struct GNUNET_REST_RequestHandle *con_handle,
GNUNET_free (cookie);
GNUNET_free (header_val);
json_decref (root);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
}
@@ -2114,7 +2128,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle *con_handle,
GNUNET_free (access_token);
GNUNET_free (json_response);
GNUNET_free (id_token);
- GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle);
+ cleanup_handle (handle);
}
@@ -2543,14 +2557,17 @@ rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
handle->proc = proc;
handle->rest_handle = rest_handle;
handle->url = GNUNET_strdup (rest_handle->url);
+ handle->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
if (handle->url[strlen (handle->url) - 1] == '/')
handle->url[strlen (handle->url) - 1] = '\0';
if (GNUNET_NO ==
GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
return GNUNET_NO;
- handle->timeout_task =
- GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
return GNUNET_YES;
}
@@ -2615,7 +2632,8 @@ libgnunet_plugin_rest_openid_connect_done (void *cls)
struct EgoEntry *ego_entry;
plugin->cfg = NULL;
-
+ while (NULL != requests_head)
+ cleanup_handle (requests_head);
if (NULL != OIDC_cookie_jar_map)
{
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
struct RequestHandle
{
+ /**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
/**
* Selected ego
@@ -247,6 +256,17 @@ struct RequestHandle
};
/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
+
+
+/**
* Cleanup lookup handle
* @param handle Handle to clean up
*/
@@ -272,6 +292,9 @@ cleanup_handle (void *cls)
GNUNET_free (handle->emsg);
if (NULL != handle->attr_list)
GNUNET_RECLAIM_attribute_list_destroy (handle->attr_list);
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
@@ -296,7 +319,7 @@ do_error (void *cls)
resp = GNUNET_REST_create_response (json_error);
MHD_add_response_header (resp, "Content-Type", "application/json");
handle->proc (handle->proc_cls, resp, handle->response_code);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+ cleanup_handle (handle);
GNUNET_free (json_error);
}
@@ -319,7 +342,7 @@ do_timeout (void *cls)
static void
collect_error_cb (void *cls)
{
- do_error (cls);
+ GNUNET_SCHEDULER_add_now (&do_error, cls);
}
@@ -329,6 +352,7 @@ finished_cont (void *cls, int32_t success, const char *emsg)
struct RequestHandle *handle = cls;
struct MHD_Response *resp;
+ handle->idp_op = NULL;
resp = GNUNET_REST_create_response (emsg);
MHD_add_response_header (resp, "Content-Type", "application/json");
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,
handle->url[strlen (handle->url) - 1] = '\0';
handle->timeout_task =
GNUNET_SCHEDULER_add_delayed (handle->timeout, &do_timeout, handle);
-
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
if (GNUNET_NO ==
GNUNET_REST_handle_request (handle->rest_handle, handlers, &err, handle))
{
@@ -1489,10 +1515,13 @@ libgnunet_plugin_rest_reclaim_done (void *cls)
{
struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
+ struct RequestHandle *request;
struct EgoEntry *ego_entry;
struct EgoEntry *ego_tmp;
plugin->cfg = NULL;
+ while (NULL != (request = requests_head))
+ do_error (request);
if (NULL != idp)
GNUNET_RECLAIM_disconnect (idp);
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;
struct RequestHandle
{
/**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
+
+ /**
* Handle to rest request
*/
struct GNUNET_REST_RequestHandle *rest_handle;
@@ -70,6 +80,17 @@ struct RequestHandle
char *url;
};
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
+
+
/**
* Cleanup request handle.
@@ -82,6 +103,9 @@ cleanup_handle (struct RequestHandle *handle)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Cleaning up\n");
if (NULL != handle->url)
GNUNET_free (handle->url);
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
@@ -367,7 +391,9 @@ rest_config_process_request (struct GNUNET_REST_RequestHandle *conndata_handle,
handle->url = GNUNET_strdup (conndata_handle->url);
if (handle->url[strlen (handle->url) - 1] == '/')
handle->url[strlen (handle->url) - 1] = '\0';
-
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
if (GNUNET_NO ==
GNUNET_REST_handle_request (conndata_handle, handlers, &err, handle))
{
@@ -415,8 +441,9 @@ libgnunet_plugin_rest_config_done (void *cls)
struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin;
+ while (NULL != requests_head)
+ cleanup_handle (requests_head);
plugin = api->cls;
-
plugin->cfg = NULL;
GNUNET_free (api);
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;
struct RequestHandle
{
/**
+ * DLL
+ */
+ struct RequestHandle *next;
+
+ /**
+ * DLL
+ */
+ struct RequestHandle *prev;
+
+ /**
* Handle to rest request
*/
struct GNUNET_REST_RequestHandle *rest_handle;
@@ -66,6 +76,15 @@ struct RequestHandle
int response_code;
};
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_head;
+
+/**
+ * DLL
+ */
+static struct RequestHandle *requests_tail;
/**
* Cleanup request handle.
@@ -77,6 +96,9 @@ cleanup_handle (struct RequestHandle *handle)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cleaning up\n");
+ GNUNET_CONTAINER_DLL_remove (requests_head,
+ requests_tail,
+ handle);
GNUNET_free (handle);
}
@@ -153,7 +175,9 @@ rest_copying_process_request (struct GNUNET_REST_RequestHandle *conndata_handle,
handle->proc_cls = proc_cls;
handle->proc = proc;
handle->rest_handle = conndata_handle;
-
+ GNUNET_CONTAINER_DLL_insert (requests_head,
+ requests_tail,
+ handle);
return GNUNET_REST_handle_request (conndata_handle,
handlers,
&err,
@@ -201,6 +225,8 @@ libgnunet_plugin_rest_copying_done (void *cls)
struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
+ while (NULL != requests_head)
+ cleanup_handle (requests_head);
plugin->cfg = NULL;
GNUNET_free (api);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,