aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo-tool
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/peerinfo-tool
parent19fe8e8ff74a9639fc075f5d974a01a977e1196a (diff)
downloadgnunet-7648cde6cfb181f03df9e145a576430220234f5f.tar.gz
gnunet-7648cde6cfb181f03df9e145a576430220234f5f.zip
-improve request cleanup handling
Diffstat (limited to 'src/peerinfo-tool')
-rw-r--r--src/peerinfo-tool/plugin_rest_peerinfo.c36
1 files changed, 31 insertions, 5 deletions
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;
180struct RequestHandle 180struct 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 */
267static struct RequestHandle *requests_head;
268
269/**
270 * DLL
271 */
272static 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