diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-06 17:39:02 +0200 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2020-08-06 17:39:02 +0200 |
commit | b12644f83637c2508a11927490ae0b94d8ee4095 (patch) | |
tree | a035724a84aa3926cefbf1e4eb3d3be99a194e4a /src/rest/gnunet-rest-server.c | |
parent | 079beb884ac4236f993736c664660c3892560c9b (diff) | |
download | gnunet-b12644f83637c2508a11927490ae0b94d8ee4095.tar.gz gnunet-b12644f83637c2508a11927490ae0b94d8ee4095.zip |
-add state, close sockets
Diffstat (limited to 'src/rest/gnunet-rest-server.c')
-rw-r--r-- | src/rest/gnunet-rest-server.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c index 436b5b205..8a1c7e32f 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 | { |