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