diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-15 12:31:32 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2011-09-15 12:31:32 +0000 |
commit | 5d4332d1f19f435eecbb6976416e26d5aee30410 (patch) | |
tree | 6f9bcdbac5bc09eee5f3c0514de54b241ca287f7 /src/transport/plugin_transport_http_client.c | |
parent | 12c5d5b026fae9066ad279298197fd5ca407479d (diff) | |
download | gnunet-5d4332d1f19f435eecbb6976416e26d5aee30410.tar.gz gnunet-5d4332d1f19f435eecbb6976416e26d5aee30410.zip |
implemented disconnect notifications for outbound connections
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r-- | src/transport/plugin_transport_http_client.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c index 312d5a78d..ea8a55614 100644 --- a/src/transport/plugin_transport_http_client.c +++ b/src/transport/plugin_transport_http_client.c | |||
@@ -158,15 +158,34 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
158 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; | 158 | plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; |
159 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 159 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
160 | return; | 160 | return; |
161 | |||
161 | do | 162 | do |
162 | { | 163 | { |
163 | running = 0; | 164 | running = 0; |
164 | mret = curl_multi_perform (plugin->client_mh, &running); | 165 | mret = curl_multi_perform (plugin->client_mh, &running); |
165 | if ((running < handles_last_run) && (running > 0)) | ||
166 | { | ||
167 | 166 | ||
168 | } | 167 | CURLMsg * msg; |
169 | //curl_handle_finished (plugin); | 168 | int msgs_left; |
169 | while ((msg = curl_multi_info_read(plugin->client_mh, &msgs_left))) | ||
170 | { | ||
171 | CURL *easy_h = msg->easy_handle; | ||
172 | struct Session *s; | ||
173 | GNUNET_assert (easy_h != NULL); | ||
174 | |||
175 | GNUNET_assert (CURLE_OK == curl_easy_getinfo(easy_h, CURLINFO_PRIVATE, &s)); | ||
176 | GNUNET_assert (s != NULL); | ||
177 | |||
178 | if (msg->msg == CURLMSG_DONE) | ||
179 | { | ||
180 | #if DEBUG_HTTP | ||
181 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | ||
182 | "Connection to '%s' %s ended\n", GNUNET_i2s(&s->target), http_plugin_address_to_string(s->plugin, s->addr, s->addrlen)); | ||
183 | #endif | ||
184 | client_disconnect(s); | ||
185 | notify_session_end (s->plugin, &s->target, s); | ||
186 | } | ||
187 | } | ||
188 | |||
170 | handles_last_run = running; | 189 | handles_last_run = running; |
171 | } | 190 | } |
172 | while (mret == CURLM_CALL_MULTI_PERFORM); | 191 | while (mret == CURLM_CALL_MULTI_PERFORM); |
@@ -181,8 +200,8 @@ client_disconnect (struct Session *s) | |||
181 | struct Plugin *plugin = s->plugin; | 200 | struct Plugin *plugin = s->plugin; |
182 | 201 | ||
183 | #if DEBUG_HTTP | 202 | #if DEBUG_HTTP |
184 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, | 203 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, |
185 | "Deleting outbound session peer `%s'\n", | 204 | "Deleting outbound PUT session to peer `%s'\n", |
186 | GNUNET_i2s (&s->target)); | 205 | GNUNET_i2s (&s->target)); |
187 | #endif | 206 | #endif |
188 | 207 | ||
@@ -195,6 +214,12 @@ client_disconnect (struct Session *s) | |||
195 | } | 214 | } |
196 | curl_easy_cleanup (s->client_put); | 215 | curl_easy_cleanup (s->client_put); |
197 | 216 | ||
217 | #if DEBUG_HTTP | ||
218 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, | ||
219 | "Deleting outbound GET session to peer `%s'\n", | ||
220 | GNUNET_i2s (&s->target)); | ||
221 | #endif | ||
222 | |||
198 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_get); | 223 | mret = curl_multi_remove_handle (plugin->client_mh, s->client_get); |
199 | if (mret != CURLM_OK) | 224 | if (mret != CURLM_OK) |
200 | { | 225 | { |
@@ -225,7 +250,7 @@ client_connect (struct Session *s) | |||
225 | CURLMcode mret; | 250 | CURLMcode mret; |
226 | 251 | ||
227 | #if DEBUG_HTTP | 252 | #if DEBUG_HTTP |
228 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, | 253 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, |
229 | "Initiating outbound session peer `%s'\n", | 254 | "Initiating outbound session peer `%s'\n", |
230 | GNUNET_i2s (&s->target)); | 255 | GNUNET_i2s (&s->target)); |
231 | #endif | 256 | #endif |
@@ -233,12 +258,7 @@ client_connect (struct Session *s) | |||
233 | s->inbound = GNUNET_NO; | 258 | s->inbound = GNUNET_NO; |
234 | 259 | ||
235 | /* create url */ | 260 | /* create url */ |
236 | GNUNET_asprintf (&url, "%s://%s/", s->plugin->protocol, | 261 | GNUNET_asprintf (&url, "%s", http_plugin_address_to_string (s->plugin, s->addr, s->addrlen)); |
237 | http_plugin_address_to_string (NULL, s->addr, s->addrlen)); | ||
238 | |||
239 | #if DEBUG_HTTP | ||
240 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, "URL `%s'\n", url); | ||
241 | #endif | ||
242 | 262 | ||
243 | /* create get connection */ | 263 | /* create get connection */ |
244 | s->client_get = curl_easy_init (); | 264 | s->client_get = curl_easy_init (); |
@@ -261,7 +281,7 @@ client_connect (struct Session *s) | |||
261 | //curl_easy_setopt (s->client_get, CURLOPT_WRITEDATA, ps); | 281 | //curl_easy_setopt (s->client_get, CURLOPT_WRITEDATA, ps); |
262 | curl_easy_setopt (s->client_get, CURLOPT_TIMEOUT_MS, | 282 | curl_easy_setopt (s->client_get, CURLOPT_TIMEOUT_MS, |
263 | (long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 283 | (long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
264 | //curl_easy_setopt (s->client_get, CURLOPT_PRIVATE, ps); | 284 | curl_easy_setopt (s->client_get, CURLOPT_PRIVATE, s); |
265 | curl_easy_setopt (s->client_get, CURLOPT_CONNECTTIMEOUT_MS, | 285 | curl_easy_setopt (s->client_get, CURLOPT_CONNECTTIMEOUT_MS, |
266 | (long) HTTP_NOT_VALIDATED_TIMEOUT.rel_value); | 286 | (long) HTTP_NOT_VALIDATED_TIMEOUT.rel_value); |
267 | curl_easy_setopt (s->client_get, CURLOPT_BUFFERSIZE, | 287 | curl_easy_setopt (s->client_get, CURLOPT_BUFFERSIZE, |
@@ -292,7 +312,7 @@ client_connect (struct Session *s) | |||
292 | //curl_easy_setopt (s->client_put, CURLOPT_WRITEDATA, ps); | 312 | //curl_easy_setopt (s->client_put, CURLOPT_WRITEDATA, ps); |
293 | curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT_MS, | 313 | curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT_MS, |
294 | (long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); | 314 | (long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value); |
295 | //curl_easy_setopt (s->client_put, CURLOPT_PRIVATE, ps); | 315 | curl_easy_setopt (s->client_put, CURLOPT_PRIVATE, s); |
296 | curl_easy_setopt (s->client_put, CURLOPT_CONNECTTIMEOUT_MS, | 316 | curl_easy_setopt (s->client_put, CURLOPT_CONNECTTIMEOUT_MS, |
297 | (long) HTTP_NOT_VALIDATED_TIMEOUT.rel_value); | 317 | (long) HTTP_NOT_VALIDATED_TIMEOUT.rel_value); |
298 | curl_easy_setopt (s->client_put, CURLOPT_BUFFERSIZE, | 318 | curl_easy_setopt (s->client_put, CURLOPT_BUFFERSIZE, |