diff options
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index d57ce88b9..4a6e8c18f 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -163,10 +163,8 @@ server_load_certificate (struct Plugin *plugin) | |||
163 | GNUNET_free_non_null (plugin->cert); | 163 | GNUNET_free_non_null (plugin->cert); |
164 | plugin->cert = NULL; | 164 | plugin->cert = NULL; |
165 | 165 | ||
166 | #if VERBOSE_SERVER | ||
167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
168 | "No usable TLS certificate found, creating certificate\n"); | 167 | "No usable TLS certificate found, creating certificate\n"); |
169 | #endif | ||
170 | errno = 0; | 168 | errno = 0; |
171 | cert_creation = | 169 | cert_creation = |
172 | GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, | 170 | GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, |
@@ -230,7 +228,6 @@ server_load_certificate (struct Plugin *plugin) | |||
230 | * @param now GNUNET_YES to schedule execution immediately, GNUNET_NO to wait | 228 | * @param now GNUNET_YES to schedule execution immediately, GNUNET_NO to wait |
231 | * until timeout | 229 | * until timeout |
232 | */ | 230 | */ |
233 | |||
234 | static void | 231 | static void |
235 | server_reschedule (struct Plugin *plugin, struct MHD_Daemon *server, int now) | 232 | server_reschedule (struct Plugin *plugin, struct MHD_Daemon *server, int now) |
236 | { | 233 | { |
@@ -302,6 +299,7 @@ server_receive_mst_cb (void *cls, void *client, | |||
302 | return GNUNET_OK; | 299 | return GNUNET_OK; |
303 | } | 300 | } |
304 | 301 | ||
302 | |||
305 | /** | 303 | /** |
306 | * Callback called by MHD when it needs data to send | 304 | * Callback called by MHD when it needs data to send |
307 | * @param cls current session | 305 | * @param cls current session |
@@ -314,44 +312,32 @@ static ssize_t | |||
314 | server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | 312 | server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) |
315 | { | 313 | { |
316 | struct Session *s = cls; | 314 | struct Session *s = cls; |
315 | ssize_t bytes_read = 0; | ||
316 | struct HTTP_Message *msg; | ||
317 | |||
317 | GNUNET_assert (NULL != p); | 318 | GNUNET_assert (NULL != p); |
318 | if (GNUNET_NO == exist_session(p, s)) | 319 | if (GNUNET_NO == exist_session(p, s)) |
319 | return 0; | 320 | return 0; |
320 | |||
321 | struct HTTP_Message *msg; | ||
322 | int bytes_read = 0; | ||
323 | |||
324 | //static int c = 0; | ||
325 | msg = s->msg_head; | 321 | msg = s->msg_head; |
326 | if (msg != NULL) | 322 | if (NULL != msg) |
327 | { | 323 | { |
328 | /* sending */ | 324 | /* sending */ |
329 | if ((msg->size - msg->pos) <= max) | 325 | bytes_read = GNUNET_MIN (msg->size - msg->pos, |
330 | { | 326 | max); |
331 | memcpy (buf, &msg->buf[msg->pos], (msg->size - msg->pos)); | 327 | memcpy (buf, &msg->buf[msg->pos], bytes_read); |
332 | bytes_read = msg->size - msg->pos; | 328 | msg->pos += bytes_read; |
333 | msg->pos += (msg->size - msg->pos); | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | memcpy (buf, &msg->buf[msg->pos], max); | ||
338 | msg->pos += max; | ||
339 | bytes_read = max; | ||
340 | } | ||
341 | 329 | ||
342 | /* removing message */ | 330 | /* removing message */ |
343 | if (msg->pos == msg->size) | 331 | if (msg->pos == msg->size) |
344 | { | 332 | { |
333 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); | ||
345 | if (NULL != msg->transmit_cont) | 334 | if (NULL != msg->transmit_cont) |
346 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); | 335 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_OK); |
347 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); | ||
348 | GNUNET_free (msg); | 336 | GNUNET_free (msg); |
349 | } | 337 | } |
350 | } | 338 | } |
351 | |||
352 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, | 339 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, |
353 | "Server: %X: sent %u bytes\n", s, bytes_read); | 340 | "Server: %p: sent %u bytes\n", s, bytes_read); |
354 | |||
355 | return bytes_read; | 341 | return bytes_read; |
356 | } | 342 | } |
357 | 343 | ||
@@ -585,7 +571,7 @@ found: | |||
585 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); | 571 | int to = (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); |
586 | 572 | ||
587 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 573 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
588 | "Server: Setting timeout for %X to %u sec.\n", sc, to); | 574 | "Server: Setting timeout for %p to %u sec.\n", sc, to); |
589 | MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); | 575 | MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); |
590 | 576 | ||
591 | struct MHD_Daemon *d = NULL; | 577 | struct MHD_Daemon *d = NULL; |
@@ -707,7 +693,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
707 | if ((s->next_receive.abs_value <= now.abs_value)) | 693 | if ((s->next_receive.abs_value <= now.abs_value)) |
708 | { | 694 | { |
709 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 695 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
710 | "Server: %X: PUT with %u bytes forwarded to MST\n", s, | 696 | "Server: %p: PUT with %u bytes forwarded to MST\n", s, |
711 | *upload_data_size); | 697 | *upload_data_size); |
712 | if (s->msg_tk == NULL) | 698 | if (s->msg_tk == NULL) |
713 | { | 699 | { |
@@ -727,7 +713,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
727 | { | 713 | { |
728 | t = s->server_recv; | 714 | t = s->server_recv; |
729 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 715 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
730 | "Server: Setting timeout for %X to %u sec.\n", t, | 716 | "Server: Setting timeout for %p to %u sec.\n", t, |
731 | to); | 717 | to); |
732 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, | 718 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, |
733 | to); | 719 | to); |
@@ -736,7 +722,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
736 | { | 722 | { |
737 | t = s->server_send; | 723 | t = s->server_send; |
738 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 724 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
739 | "Server: Setting timeout for %X to %u sec.\n", t, | 725 | "Server: Setting timeout for %p to %u sec.\n", t, |
740 | to); | 726 | to); |
741 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, | 727 | MHD_set_connection_option (t->mhd_conn, MHD_CONNECTION_OPTION_TIMEOUT, |
742 | to); | 728 | to); |
@@ -754,7 +740,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
754 | else | 740 | else |
755 | { | 741 | { |
756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 742 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
757 | "Server: %X no inbound bandwidth available! Next read was delayed by %llu ms\n", | 743 | "Server: %p no inbound bandwidth available! Next read was delayed by %llu ms\n", |
758 | s, now.abs_value - s->next_receive.abs_value); | 744 | s, now.abs_value - s->next_receive.abs_value); |
759 | } | 745 | } |
760 | return MHD_YES; | 746 | return MHD_YES; |
@@ -790,7 +776,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
790 | { | 776 | { |
791 | 777 | ||
792 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 778 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
793 | "Server: %X peer `%s' GET on address `%s' disconnected\n", | 779 | "Server: %p peer `%s' GET on address `%s' disconnected\n", |
794 | s->server_send, GNUNET_i2s (&s->target), | 780 | s->server_send, GNUNET_i2s (&s->target), |
795 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); | 781 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); |
796 | s->server_send = NULL; | 782 | s->server_send = NULL; |
@@ -807,7 +793,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
807 | if (sc->direction == _RECEIVE) | 793 | if (sc->direction == _RECEIVE) |
808 | { | 794 | { |
809 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 795 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
810 | "Server: %X peer `%s' PUT on address `%s' disconnected\n", | 796 | "Server: %p peer `%s' PUT on address `%s' disconnected\n", |
811 | s->server_recv, GNUNET_i2s (&s->target), | 797 | s->server_recv, GNUNET_i2s (&s->target), |
812 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); | 798 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); |
813 | s->server_recv = NULL; | 799 | s->server_recv = NULL; |