diff options
Diffstat (limited to 'src/util/test_connection_timeout.c')
-rw-r--r-- | src/util/test_connection_timeout.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/util/test_connection_timeout.c b/src/util/test_connection_timeout.c index 5a0bb7c3a..1700718b9 100644 --- a/src/util/test_connection_timeout.c +++ b/src/util/test_connection_timeout.c | |||
@@ -62,11 +62,10 @@ open_listen_socket () | |||
62 | GNUNET_assert (desc != NULL); | 62 | GNUNET_assert (desc != NULL); |
63 | if (GNUNET_NETWORK_socket_setsockopt | 63 | if (GNUNET_NETWORK_socket_setsockopt |
64 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) | 64 | (desc, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) != GNUNET_OK) |
65 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, | 65 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, "setsockopt"); |
66 | "setsockopt"); | ||
67 | GNUNET_assert (GNUNET_NETWORK_socket_bind | 66 | GNUNET_assert (GNUNET_NETWORK_socket_bind |
68 | (desc, (const struct sockaddr *) &sa, | 67 | (desc, (const struct sockaddr *) &sa, |
69 | sizeof (sa)) == GNUNET_OK); | 68 | sizeof (sa)) == GNUNET_OK); |
70 | GNUNET_NETWORK_socket_listen (desc, 5); | 69 | GNUNET_NETWORK_socket_listen (desc, 5); |
71 | return desc; | 70 | return desc; |
72 | } | 71 | } |
@@ -78,16 +77,16 @@ send_kilo (void *cls, size_t size, void *buf) | |||
78 | int *ok = cls; | 77 | int *ok = cls; |
79 | 78 | ||
80 | if (size == 0) | 79 | if (size == 0) |
81 | { | 80 | { |
82 | #if VERBOSE | 81 | #if VERBOSE |
83 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got the desired timeout!\n"); | 82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got the desired timeout!\n"); |
84 | #endif | 83 | #endif |
85 | GNUNET_assert (buf == NULL); | 84 | GNUNET_assert (buf == NULL); |
86 | *ok = 0; | 85 | *ok = 0; |
87 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); | 86 | GNUNET_CONNECTION_destroy (lsock, GNUNET_YES); |
88 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); | 87 | GNUNET_CONNECTION_destroy (csock, GNUNET_YES); |
89 | return 0; | 88 | return 0; |
90 | } | 89 | } |
91 | #if VERBOSE | 90 | #if VERBOSE |
92 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending kilo to fill buffer.\n"); | 91 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending kilo to fill buffer.\n"); |
93 | #endif | 92 | #endif |
@@ -95,9 +94,9 @@ send_kilo (void *cls, size_t size, void *buf) | |||
95 | memset (buf, 42, 1024); | 94 | memset (buf, 42, 1024); |
96 | 95 | ||
97 | GNUNET_assert (NULL != | 96 | GNUNET_assert (NULL != |
98 | GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, | 97 | GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, |
99 | GNUNET_TIME_UNIT_SECONDS, | 98 | GNUNET_TIME_UNIT_SECONDS, |
100 | &send_kilo, cls)); | 99 | &send_kilo, cls)); |
101 | return 1024; | 100 | return 1024; |
102 | } | 101 | } |
103 | 102 | ||
@@ -112,9 +111,9 @@ task_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
112 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); | 111 | csock = GNUNET_CONNECTION_create_from_connect (cfg, "localhost", PORT); |
113 | GNUNET_assert (csock != NULL); | 112 | GNUNET_assert (csock != NULL); |
114 | GNUNET_assert (NULL != | 113 | GNUNET_assert (NULL != |
115 | GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, | 114 | GNUNET_CONNECTION_notify_transmit_ready (csock, 1024, |
116 | GNUNET_TIME_UNIT_SECONDS, | 115 | GNUNET_TIME_UNIT_SECONDS, |
117 | &send_kilo, cls)); | 116 | &send_kilo, cls)); |
118 | } | 117 | } |
119 | 118 | ||
120 | 119 | ||
@@ -130,7 +129,7 @@ check_timeout () | |||
130 | ok = 1; | 129 | ok = 1; |
131 | cfg = GNUNET_CONFIGURATION_create (); | 130 | cfg = GNUNET_CONFIGURATION_create (); |
132 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 131 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
133 | "localhost"); | 132 | "localhost"); |
134 | GNUNET_SCHEDULER_run (&task_timeout, &ok); | 133 | GNUNET_SCHEDULER_run (&task_timeout, &ok); |
135 | GNUNET_CONFIGURATION_destroy (cfg); | 134 | GNUNET_CONFIGURATION_destroy (cfg); |
136 | return ok; | 135 | return ok; |
@@ -143,11 +142,11 @@ main (int argc, char *argv[]) | |||
143 | 142 | ||
144 | GNUNET_log_setup ("test_connection_timeout", | 143 | GNUNET_log_setup ("test_connection_timeout", |
145 | #if VERBOSE | 144 | #if VERBOSE |
146 | "DEBUG", | 145 | "DEBUG", |
147 | #else | 146 | #else |
148 | "WARNING", | 147 | "WARNING", |
149 | #endif | 148 | #endif |
150 | NULL); | 149 | NULL); |
151 | ret += check_timeout (); | 150 | ret += check_timeout (); |
152 | return ret; | 151 | return ret; |
153 | } | 152 | } |