diff options
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 159b0853f..2c180c5ff 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -312,6 +312,7 @@ static ssize_t | |||
312 | 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) |
313 | { | 313 | { |
314 | struct Session *s = cls; | 314 | struct Session *s = cls; |
315 | |||
315 | #if VERBOSE_SERVER | 316 | #if VERBOSE_SERVER |
316 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, | 317 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, |
317 | "Server: %X can sent maximum %u \n", s, max); | 318 | "Server: %X can sent maximum %u \n", s, max); |
@@ -349,6 +350,7 @@ server_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
349 | 350 | ||
350 | #if VERBOSE_SERVER | 351 | #if VERBOSE_SERVER |
351 | struct Plugin *plugin = s->plugin; | 352 | struct Plugin *plugin = s->plugin; |
353 | |||
352 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 354 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
353 | "Server: %X: sent %u bytes\n", s, bytes_read); | 355 | "Server: %X: sent %u bytes\n", s, bytes_read); |
354 | #endif | 356 | #endif |
@@ -575,7 +577,8 @@ found: | |||
575 | #endif | 577 | #endif |
576 | MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); | 578 | MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); |
577 | 579 | ||
578 | struct MHD_Daemon * d = NULL; | 580 | struct MHD_Daemon *d = NULL; |
581 | |||
579 | if (s->addrlen == sizeof (struct IPv6HttpAddress)) | 582 | if (s->addrlen == sizeof (struct IPv6HttpAddress)) |
580 | d = plugin->server_v6; | 583 | d = plugin->server_v6; |
581 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) | 584 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) |
@@ -649,10 +652,10 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
649 | if ((sc->session->server_recv == NULL) || (sc->session->server_send == NULL)) | 652 | if ((sc->session->server_recv == NULL) || (sc->session->server_send == NULL)) |
650 | { | 653 | { |
651 | #if VERBOSE_SERVER | 654 | #if VERBOSE_SERVER |
652 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 655 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
653 | "Server: Delayed read from `%s' `%s' since not both semi-connections are connected\n", | 656 | "Server: Delayed read from `%s' `%s' since not both semi-connections are connected\n", |
654 | GNUNET_i2s (&s->target), | 657 | GNUNET_i2s (&s->target), |
655 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); | 658 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); |
656 | #endif | 659 | #endif |
657 | return MHD_YES; | 660 | return MHD_YES; |
658 | } | 661 | } |
@@ -674,7 +677,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
674 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 677 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
675 | "Server: Peer `%s' PUT on address `%s' connected\n", | 678 | "Server: Peer `%s' PUT on address `%s' connected\n", |
676 | GNUNET_i2s (&s->target), | 679 | GNUNET_i2s (&s->target), |
677 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); | 680 | http_plugin_address_to_string (NULL, s->addr, |
681 | s->addrlen)); | ||
678 | #endif | 682 | #endif |
679 | return MHD_YES; | 683 | return MHD_YES; |
680 | } | 684 | } |
@@ -686,7 +690,8 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
686 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 690 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
687 | "Server: peer `%s' PUT on address `%s' received %u bytes\n", | 691 | "Server: peer `%s' PUT on address `%s' received %u bytes\n", |
688 | GNUNET_i2s (&s->target), | 692 | GNUNET_i2s (&s->target), |
689 | http_plugin_address_to_string (NULL,s->addr, s->addrlen), | 693 | http_plugin_address_to_string (NULL, s->addr, |
694 | s->addrlen), | ||
690 | *upload_data_size); | 695 | *upload_data_size); |
691 | #endif | 696 | #endif |
692 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 697 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
@@ -739,6 +744,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
739 | to); | 744 | to); |
740 | } | 745 | } |
741 | struct MHD_Daemon *d = NULL; | 746 | struct MHD_Daemon *d = NULL; |
747 | |||
742 | if (s->addrlen == sizeof (struct IPv6HttpAddress)) | 748 | if (s->addrlen == sizeof (struct IPv6HttpAddress)) |
743 | d = plugin->server_v6; | 749 | d = plugin->server_v6; |
744 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) | 750 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) |
@@ -839,6 +845,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection, | |||
839 | plugin->cur_connections--; | 845 | plugin->cur_connections--; |
840 | 846 | ||
841 | struct MHD_Daemon *d = NULL; | 847 | struct MHD_Daemon *d = NULL; |
848 | |||
842 | if (s->addrlen == sizeof (struct IPv6HttpAddress)) | 849 | if (s->addrlen == sizeof (struct IPv6HttpAddress)) |
843 | d = plugin->server_v6; | 850 | d = plugin->server_v6; |
844 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) | 851 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) |
@@ -894,11 +901,11 @@ server_send (struct Session *s, struct HTTP_Message *msg) | |||
894 | 901 | ||
895 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) | 902 | if (s->addrlen == sizeof (struct IPv4HttpAddress)) |
896 | { | 903 | { |
897 | server_reschedule (s->plugin, s->plugin->server_v4 , GNUNET_YES); | 904 | server_reschedule (s->plugin, s->plugin->server_v4, GNUNET_YES); |
898 | } | 905 | } |
899 | else if (s->addrlen == sizeof (struct IPv6HttpAddress)) | 906 | else if (s->addrlen == sizeof (struct IPv6HttpAddress)) |
900 | { | 907 | { |
901 | server_reschedule (s->plugin, s->plugin->server_v6 , GNUNET_YES); | 908 | server_reschedule (s->plugin, s->plugin->server_v6, GNUNET_YES); |
902 | } | 909 | } |
903 | else | 910 | else |
904 | return GNUNET_SYSERR; | 911 | return GNUNET_SYSERR; |
@@ -926,7 +933,7 @@ server_v4_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
926 | return; | 933 | return; |
927 | #if VERBOSE_SERVER | 934 | #if VERBOSE_SERVER |
928 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 935 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
929 | "Running IPv4 server\n"); | 936 | "Running IPv4 server\n"); |
930 | #endif | 937 | #endif |
931 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); | 938 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v4)); |
932 | if (plugin->server_v4 != NULL) | 939 | if (plugin->server_v4 != NULL) |
@@ -954,7 +961,7 @@ server_v6_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
954 | return; | 961 | return; |
955 | #if VERBOSE_SERVER | 962 | #if VERBOSE_SERVER |
956 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 963 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
957 | "Running IPv6 server\n"); | 964 | "Running IPv6 server\n"); |
958 | #endif | 965 | #endif |
959 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); | 966 | GNUNET_assert (MHD_YES == MHD_run (plugin->server_v6)); |
960 | if (plugin->server_v6 != NULL) | 967 | if (plugin->server_v6 != NULL) |
@@ -1027,8 +1034,8 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, | |||
1027 | plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; | 1034 | plugin->server_v4_task = GNUNET_SCHEDULER_NO_TASK; |
1028 | } | 1035 | } |
1029 | #if VERBOSE_SERVER | 1036 | #if VERBOSE_SERVER |
1030 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1037 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
1031 | "Scheduling IPv4 server task in %llu ms\n", tv); | 1038 | "Scheduling IPv4 server task in %llu ms\n", tv); |
1032 | #endif | 1039 | #endif |
1033 | ret = | 1040 | ret = |
1034 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1041 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
@@ -1043,8 +1050,8 @@ server_schedule (struct Plugin *plugin, struct MHD_Daemon *daemon_handle, | |||
1043 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; | 1050 | plugin->server_v6_task = GNUNET_SCHEDULER_NO_TASK; |
1044 | } | 1051 | } |
1045 | #if VERBOSE_SERVER | 1052 | #if VERBOSE_SERVER |
1046 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1053 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, |
1047 | "Scheduling IPv6 server task in %llu ms\n", tv); | 1054 | "Scheduling IPv6 server task in %llu ms\n", tv); |
1048 | #endif | 1055 | #endif |
1049 | ret = | 1056 | ret = |
1050 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1057 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
@@ -1195,8 +1202,7 @@ server_stop (struct Plugin *plugin) | |||
1195 | struct Session *t = NULL; | 1202 | struct Session *t = NULL; |
1196 | 1203 | ||
1197 | #if VERBOSE_SERVER | 1204 | #if VERBOSE_SERVER |
1198 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 1205 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, "server_stop\n"); |
1199 | "server_stop\n"); | ||
1200 | #endif | 1206 | #endif |
1201 | 1207 | ||
1202 | struct MHD_Daemon *server_v4_tmp = plugin->server_v4; | 1208 | struct MHD_Daemon *server_v4_tmp = plugin->server_v4; |
@@ -1236,16 +1242,17 @@ server_stop (struct Plugin *plugin) | |||
1236 | "Deleting semi-sessions %p\n", s); | 1242 | "Deleting semi-sessions %p\n", s); |
1237 | #endif | 1243 | #endif |
1238 | t = s->next; | 1244 | t = s->next; |
1239 | struct HTTP_Message * msg = s->msg_head; | 1245 | struct HTTP_Message *msg = s->msg_head; |
1240 | struct HTTP_Message * tmp = s->msg_head; | 1246 | struct HTTP_Message *tmp = s->msg_head; |
1247 | |||
1241 | while (msg != NULL) | 1248 | while (msg != NULL) |
1242 | { | 1249 | { |
1243 | tmp = msg->next; | 1250 | tmp = msg->next; |
1244 | 1251 | ||
1245 | GNUNET_CONTAINER_DLL_remove(s->msg_head,s->msg_tail, msg); | 1252 | GNUNET_CONTAINER_DLL_remove (s->msg_head, s->msg_tail, msg); |
1246 | if (msg->transmit_cont != NULL) | 1253 | if (msg->transmit_cont != NULL) |
1247 | { | 1254 | { |
1248 | msg->transmit_cont(msg->transmit_cont_cls, &s->target, GNUNET_SYSERR); | 1255 | msg->transmit_cont (msg->transmit_cont_cls, &s->target, GNUNET_SYSERR); |
1249 | } | 1256 | } |
1250 | GNUNET_free (msg); | 1257 | GNUNET_free (msg); |
1251 | msg = tmp; | 1258 | msg = tmp; |