diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-11 21:21:56 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-11 21:21:56 +0000 |
commit | 3d7fefedc9ba60bd8e8448efe8b628446d958536 (patch) | |
tree | 61ce41a52cd6e7232cead77818ef265993b2427e /src/transport/plugin_transport_http_server.c | |
parent | 4a0398474db197abed243a123fb971fbeeffab4b (diff) | |
download | gnunet-3d7fefedc9ba60bd8e8448efe8b628446d958536.tar.gz gnunet-3d7fefedc9ba60bd8e8448efe8b628446d958536.zip |
changing time measurement from milliseconds to microseconds
Diffstat (limited to 'src/transport/plugin_transport_http_server.c')
-rw-r--r-- | src/transport/plugin_transport_http_server.c | 112 |
1 files changed, 66 insertions, 46 deletions
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 19833521a..17e39360c 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2002-2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -876,29 +876,42 @@ server_disconnect (struct Session *s) | |||
876 | return GNUNET_OK; | 876 | return GNUNET_OK; |
877 | } | 877 | } |
878 | 878 | ||
879 | |||
880 | |||
881 | /** | ||
882 | * Tell MHD that the connection should timeout after #to seconds. | ||
883 | * | ||
884 | * @param plugin our plugin | ||
885 | * @param s session for which the timeout changes | ||
886 | * @param to timeout in seconds | ||
887 | */ | ||
879 | static void | 888 | static void |
880 | server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, struct Session *s, int to) | 889 | server_mhd_connection_timeout (struct HTTP_Server_Plugin *plugin, |
890 | struct Session *s, | ||
891 | unsigned int to) | ||
881 | { | 892 | { |
882 | #if MHD_VERSION >= 0x00090E00 | 893 | #if MHD_VERSION >= 0x00090E00 |
883 | /* Setting timeouts for other connections */ | 894 | /* Setting timeouts for other connections */ |
884 | if (s->server_recv != NULL) | 895 | if (NULL != s->server_recv) |
885 | { | 896 | { |
886 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 897 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
887 | "Setting timeout for %p to %u sec.\n", s->server_recv, to); | 898 | "Setting timeout for %p to %u sec.\n", |
888 | MHD_set_connection_option (s->server_recv->mhd_conn, | 899 | s->server_recv, to); |
889 | MHD_CONNECTION_OPTION_TIMEOUT, | 900 | MHD_set_connection_option (s->server_recv->mhd_conn, |
890 | to); | 901 | MHD_CONNECTION_OPTION_TIMEOUT, |
891 | server_reschedule (plugin, s->server_recv->mhd_daemon, GNUNET_NO); | 902 | to); |
892 | } | 903 | server_reschedule (plugin, s->server_recv->mhd_daemon, GNUNET_NO); |
893 | if (s->server_send != NULL) | 904 | } |
894 | { | 905 | if (NULL != s->server_send) |
895 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 906 | { |
896 | "Setting timeout for %p to %u sec.\n", s->server_send, to); | 907 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
897 | MHD_set_connection_option (s->server_send->mhd_conn, | 908 | "Setting timeout for %p to %u sec.\n", |
898 | MHD_CONNECTION_OPTION_TIMEOUT, | 909 | s->server_send, to); |
899 | to); | 910 | MHD_set_connection_option (s->server_send->mhd_conn, |
900 | server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_NO); | 911 | MHD_CONNECTION_OPTION_TIMEOUT, |
901 | } | 912 | to); |
913 | server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_NO); | ||
914 | } | ||
902 | #endif | 915 | #endif |
903 | } | 916 | } |
904 | 917 | ||
@@ -1034,14 +1047,12 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
1034 | struct ServerConnection *sc = NULL; | 1047 | struct ServerConnection *sc = NULL; |
1035 | const union MHD_ConnectionInfo *conn_info; | 1048 | const union MHD_ConnectionInfo *conn_info; |
1036 | struct GNUNET_ATS_Information ats; | 1049 | struct GNUNET_ATS_Information ats; |
1037 | |||
1038 | struct HttpAddress *addr; | 1050 | struct HttpAddress *addr; |
1039 | size_t addr_len; | 1051 | size_t addr_len; |
1040 | |||
1041 | struct GNUNET_PeerIdentity target; | 1052 | struct GNUNET_PeerIdentity target; |
1042 | uint32_t tag = 0; | 1053 | uint32_t tag = 0; |
1043 | int direction = GNUNET_SYSERR; | 1054 | int direction = GNUNET_SYSERR; |
1044 | int to; | 1055 | unsigned int to; |
1045 | 1056 | ||
1046 | conn_info = MHD_get_connection_info (mhd_connection, | 1057 | conn_info = MHD_get_connection_info (mhd_connection, |
1047 | MHD_CONNECTION_INFO_CLIENT_ADDRESS); | 1058 | MHD_CONNECTION_INFO_CLIENT_ADDRESS); |
@@ -1169,8 +1180,9 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
1169 | #if MHD_VERSION >= 0x00090E00 | 1180 | #if MHD_VERSION >= 0x00090E00 |
1170 | if ((NULL == s->server_recv) || (NULL == s->server_send)) | 1181 | if ((NULL == s->server_recv) || (NULL == s->server_send)) |
1171 | { | 1182 | { |
1172 | to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value / 1000); | 1183 | to = (HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL); |
1173 | MHD_set_connection_option (mhd_connection, MHD_CONNECTION_OPTION_TIMEOUT, to); | 1184 | MHD_set_connection_option (mhd_connection, |
1185 | MHD_CONNECTION_OPTION_TIMEOUT, to); | ||
1174 | server_reschedule (plugin, sc->mhd_daemon, GNUNET_NO); | 1186 | server_reschedule (plugin, sc->mhd_daemon, GNUNET_NO); |
1175 | } | 1187 | } |
1176 | else | 1188 | else |
@@ -1178,7 +1190,7 @@ server_lookup_connection (struct HTTP_Server_Plugin *plugin, | |||
1178 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1190 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1179 | "Session %p for peer `%s' fully connected\n", | 1191 | "Session %p for peer `%s' fully connected\n", |
1180 | s, GNUNET_i2s (&target)); | 1192 | s, GNUNET_i2s (&target)); |
1181 | to = (SERVER_SESSION_TIMEOUT.rel_value / 1000); | 1193 | to = (SERVER_SESSION_TIMEOUT.rel_value_us / 1000LL / 1000LL); |
1182 | server_mhd_connection_timeout (plugin, s, to); | 1194 | server_mhd_connection_timeout (plugin, s, to); |
1183 | } | 1195 | } |
1184 | 1196 | ||
@@ -1325,13 +1337,14 @@ server_receive_mst_cb (void *cls, void *client, | |||
1325 | 1337 | ||
1326 | s->session_passed = GNUNET_YES; | 1338 | s->session_passed = GNUNET_YES; |
1327 | s->next_receive = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); | 1339 | s->next_receive = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay); |
1328 | if (delay.rel_value > 0) | 1340 | if (delay.rel_value_us > 0) |
1329 | { | 1341 | { |
1330 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1342 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1331 | "Peer `%s' address `%s' next read delayed for %llu ms\n", | 1343 | "Peer `%s' address `%s' next read delayed for %s\n", |
1332 | GNUNET_i2s (&s->target), | 1344 | GNUNET_i2s (&s->target), |
1333 | http_common_plugin_address_to_string (NULL, p->protocol, s->addr, s->addrlen), | 1345 | http_common_plugin_address_to_string (NULL, p->protocol, s->addr, s->addrlen), |
1334 | delay); | 1346 | GNUNET_STRINGS_relative_time_to_string (delay, |
1347 | GNUNET_YES)); | ||
1335 | } | 1348 | } |
1336 | server_reschedule_session_timeout (s); | 1349 | server_reschedule_session_timeout (s); |
1337 | return GNUNET_OK; | 1350 | return GNUNET_OK; |
@@ -1477,7 +1490,7 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
1477 | *upload_data_size); | 1490 | *upload_data_size); |
1478 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 1491 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
1479 | 1492 | ||
1480 | if ((s->next_receive.abs_value <= now.abs_value)) | 1493 | if ((s->next_receive.abs_value_us <= now.abs_value_us)) |
1481 | { | 1494 | { |
1482 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1495 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1483 | "PUT with %u bytes forwarded to MST\n", | 1496 | "PUT with %u bytes forwarded to MST\n", |
@@ -1488,16 +1501,17 @@ server_access_cb (void *cls, struct MHD_Connection *mhd_connection, | |||
1488 | } | 1501 | } |
1489 | GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, | 1502 | GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, |
1490 | *upload_data_size, GNUNET_NO, GNUNET_NO); | 1503 | *upload_data_size, GNUNET_NO, GNUNET_NO); |
1491 | #if MHD_VERSION >= 0x00090E00 | 1504 | server_mhd_connection_timeout (plugin, s, |
1492 | server_mhd_connection_timeout (plugin, s, GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value / 1000); | 1505 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value_us / 1000LL / 1000LL); |
1493 | #endif | ||
1494 | (*upload_data_size) = 0; | 1506 | (*upload_data_size) = 0; |
1495 | } | 1507 | } |
1496 | else | 1508 | else |
1497 | { | 1509 | { |
1498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1499 | "Session %p / Connection %p: no inbound bandwidth available! Next read was delayed by %llu ms\n", | 1511 | "Session %p / Connection %p: no inbound bandwidth available! Next read was delayed by %s\n", |
1500 | s, sc, now.abs_value - s->next_receive.abs_value); | 1512 | s, sc, |
1513 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (s->next_receive), | ||
1514 | GNUNET_YES)); | ||
1501 | } | 1515 | } |
1502 | return MHD_YES; | 1516 | return MHD_YES; |
1503 | } | 1517 | } |
@@ -1753,12 +1767,12 @@ server_schedule (struct HTTP_Server_Plugin *plugin, | |||
1753 | { | 1767 | { |
1754 | 1768 | ||
1755 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 1769 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
1756 | "SELECT Timeout changed from %llu to %llu\n", | 1770 | "SELECT Timeout changed from %llu to %llu (ms)\n", |
1757 | last_timeout, timeout); | 1771 | last_timeout, timeout); |
1758 | last_timeout = timeout; | 1772 | last_timeout = timeout; |
1759 | } | 1773 | } |
1760 | if (timeout <= GNUNET_TIME_UNIT_SECONDS.rel_value) | 1774 | if (timeout <= GNUNET_TIME_UNIT_SECONDS.rel_value_us / 1000LL) |
1761 | tv.rel_value = (uint64_t) timeout; | 1775 | tv.rel_value_us = (uint64_t) timeout * 1000LL; |
1762 | else | 1776 | else |
1763 | tv = GNUNET_TIME_UNIT_SECONDS; | 1777 | tv = GNUNET_TIME_UNIT_SECONDS; |
1764 | } | 1778 | } |
@@ -2007,12 +2021,12 @@ server_start (struct HTTP_Server_Plugin *plugin) | |||
2007 | 2021 | ||
2008 | 2022 | ||
2009 | #if MHD_VERSION >= 0x00090E00 | 2023 | #if MHD_VERSION >= 0x00090E00 |
2010 | timeout = HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value / 1000; | 2024 | timeout = HTTP_SERVER_NOT_VALIDATED_TIMEOUT.rel_value_us / 1000LL / 1000LL; |
2011 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | 2025 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
2012 | "MHD can set timeout per connection! Default time out %u sec.\n", | 2026 | "MHD can set timeout per connection! Default time out %u sec.\n", |
2013 | timeout); | 2027 | timeout); |
2014 | #else | 2028 | #else |
2015 | timeout = SERVER_SESSION_TIMEOUT.rel_value / 1000; | 2029 | timeout = SERVER_SESSION_TIMEOUT.rel_value_us / 1000LL / 1000LL; |
2016 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, | 2030 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, plugin->name, |
2017 | "MHD cannot set timeout per connection! Default time out %u sec.\n", | 2031 | "MHD cannot set timeout per connection! Default time out %u sec.\n", |
2018 | timeout); | 2032 | timeout); |
@@ -2870,8 +2884,10 @@ server_session_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc | |||
2870 | 2884 | ||
2871 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 2885 | s->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
2872 | GNUNET_log (TIMEOUT_LOG, | 2886 | GNUNET_log (TIMEOUT_LOG, |
2873 | "Session %p was idle for %llu ms, disconnecting\n", | 2887 | "Session %p was idle for %s, disconnecting\n", |
2874 | s, (unsigned long long) SERVER_SESSION_TIMEOUT.rel_value); | 2888 | s, |
2889 | GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, | ||
2890 | GNUNET_YES)); | ||
2875 | 2891 | ||
2876 | /* call session destroy function */ | 2892 | /* call session destroy function */ |
2877 | GNUNET_assert (GNUNET_OK == server_disconnect (s)); | 2893 | GNUNET_assert (GNUNET_OK == server_disconnect (s)); |
@@ -2892,8 +2908,10 @@ server_start_session_timeout (struct Session *s) | |||
2892 | &server_session_timeout, | 2908 | &server_session_timeout, |
2893 | s); | 2909 | s); |
2894 | GNUNET_log (TIMEOUT_LOG, | 2910 | GNUNET_log (TIMEOUT_LOG, |
2895 | "Timeout for session %p set to %llu ms\n", | 2911 | "Timeout for session %p set to %s\n", |
2896 | s, (unsigned long long) SERVER_SESSION_TIMEOUT.rel_value); | 2912 | s, |
2913 | GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, | ||
2914 | GNUNET_YES)); | ||
2897 | } | 2915 | } |
2898 | 2916 | ||
2899 | 2917 | ||
@@ -2913,8 +2931,10 @@ server_reschedule_session_timeout (struct Session *s) | |||
2913 | &server_session_timeout, | 2931 | &server_session_timeout, |
2914 | s); | 2932 | s); |
2915 | GNUNET_log (TIMEOUT_LOG, | 2933 | GNUNET_log (TIMEOUT_LOG, |
2916 | "Timeout rescheduled for session %p set to %llu ms\n", | 2934 | "Timeout rescheduled for session %p set to %s\n", |
2917 | s, (unsigned long long) SERVER_SESSION_TIMEOUT.rel_value); | 2935 | s, |
2936 | GNUNET_STRINGS_relative_time_to_string (SERVER_SESSION_TIMEOUT, | ||
2937 | GNUNET_YES)); | ||
2918 | } | 2938 | } |
2919 | 2939 | ||
2920 | 2940 | ||