aboutsummaryrefslogtreecommitdiff
path: root/src/rest/gnunet-rest-server.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rest/gnunet-rest-server.c')
-rw-r--r--src/rest/gnunet-rest-server.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index 436b5b205..e6e03b16d 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -208,6 +208,11 @@ struct AcceptedRequest
208 * Connection 208 * Connection
209 */ 209 */
210 struct MhdConnectionHandle *con_handle; 210 struct MhdConnectionHandle *con_handle;
211
212 /**
213 * State
214 */
215 int socket_with_mhd;
211}; 216};
212 217
213/** 218/**
@@ -310,7 +315,13 @@ cleanup_ar (struct AcceptedRequest *ar)
310 { 315 {
311 cleanup_handle (ar->con_handle); 316 cleanup_handle (ar->con_handle);
312 } 317 }
313 GNUNET_NETWORK_socket_free_memory_only_ (ar->sock); 318 if (GNUNET_YES == ar->socket_with_mhd)
319 {
320 GNUNET_NETWORK_socket_free_memory_only_ (ar->sock);
321 } else {
322 GNUNET_NETWORK_socket_close (ar->sock);
323 }
324 ar->sock = NULL;
314 GNUNET_CONTAINER_DLL_remove (req_list_head, 325 GNUNET_CONTAINER_DLL_remove (req_list_head,
315 req_list_tail, 326 req_list_tail,
316 ar); 327 ar);
@@ -529,7 +540,7 @@ create_response (void *cls,
529 MHD_suspend_connection (con_handle->con); 540 MHD_suspend_connection (con_handle->con);
530 return MHD_YES; 541 return MHD_YES;
531 } 542 }
532 MHD_resume_connection (con_handle->con); 543 //MHD_resume_connection (con_handle->con);
533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 544 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
534 "Queueing response from plugin with MHD\n"); 545 "Queueing response from plugin with MHD\n");
535 // Handle Preflights for extensions 546 // Handle Preflights for extensions
@@ -767,7 +778,7 @@ mhd_completed_cb (void *cls,
767 cleanup_handle (ar->con_handle); 778 cleanup_handle (ar->con_handle);
768 ar->con_handle = NULL; 779 ar->con_handle = NULL;
769 } 780 }
770 schedule_httpd (); 781 ar->socket_with_mhd = GNUNET_YES;
771 *con_cls = NULL; 782 *con_cls = NULL;
772} 783}
773 784
@@ -882,6 +893,7 @@ do_accept (void *cls)
882 else 893 else
883 GNUNET_assert (0); 894 GNUNET_assert (0);
884 ar = GNUNET_new (struct AcceptedRequest); 895 ar = GNUNET_new (struct AcceptedRequest);
896 ar->socket_with_mhd = GNUNET_YES;
885 ar->sock = GNUNET_NETWORK_socket_accept (lsock, NULL, NULL); 897 ar->sock = GNUNET_NETWORK_socket_accept (lsock, NULL, NULL);
886 if (NULL == ar->sock) 898 if (NULL == ar->sock)
887 { 899 {
@@ -925,7 +937,7 @@ do_shutdown (void *cls)
925 GNUNET_CONTAINER_DLL_remove (plugins_head, 937 GNUNET_CONTAINER_DLL_remove (plugins_head,
926 plugins_tail, 938 plugins_tail,
927 ple); 939 ple);
928 GNUNET_PLUGIN_unload (ple->libname, NULL); 940 GNUNET_PLUGIN_unload (ple->libname, ple->plugin);
929 GNUNET_free (ple->libname); 941 GNUNET_free (ple->libname);
930 GNUNET_free (ple); 942 GNUNET_free (ple);
931 } 943 }