aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http_client.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-07-10 13:35:28 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-07-10 13:35:28 +0000
commitf42ded3716ac792efe84e05cc6f1d5d5d8523e69 (patch)
tree8599e71f4ff9de1f1983cd46820d789b5e2ae1c3 /src/transport/plugin_transport_http_client.c
parent61b74e5d953a59b93d8e814c1e55965c015818aa (diff)
downloadgnunet-f42ded3716ac792efe84e05cc6f1d5d5d8523e69.tar.gz
gnunet-f42ded3716ac792efe84e05cc6f1d5d5d8523e69.zip
- improving client disconnect code to fix mantis 2486
Diffstat (limited to 'src/transport/plugin_transport_http_client.c')
-rw-r--r--src/transport/plugin_transport_http_client.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index 6355bb4e5..ff23da974 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -200,10 +200,9 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
200 struct Session *s = NULL; 200 struct Session *s = NULL;
201 char *d = (char *) s; 201 char *d = (char *) s;
202 202
203
204 //GNUNET_assert (easy_h != NULL);
205 if (easy_h == NULL) 203 if (easy_h == NULL)
206 { 204 {
205 GNUNET_break (0);
207 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 206 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
208 "Client: connection to ended with reason %i: `%s', %i handles running\n", 207 "Client: connection to ended with reason %i: `%s', %i handles running\n",
209 msg->data.result, 208 msg->data.result,
@@ -222,7 +221,6 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
222 } 221 }
223 222
224 GNUNET_assert (s != NULL); 223 GNUNET_assert (s != NULL);
225
226 if (msg->msg == CURLMSG_DONE) 224 if (msg->msg == CURLMSG_DONE)
227 { 225 {
228 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 226 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
@@ -233,13 +231,8 @@ client_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
233 msg->data.result, 231 msg->data.result,
234 curl_easy_strerror (msg->data.result)); 232 curl_easy_strerror (msg->data.result));
235 233
234 /* Disconnect other transmission direction and tell transport */
236 client_disconnect (s); 235 client_disconnect (s);
237 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
238 plugin->name,
239 "Notifying about ended session to peer `%s' `%s'\n",
240 GNUNET_i2s (&s->target),
241 http_plugin_address_to_string (plugin, s->addr, s->addrlen));
242 notify_session_end (plugin, &s->target, s);
243 } 236 }
244 } 237 }
245 } 238 }
@@ -266,13 +259,14 @@ client_disconnect (struct Session *s)
266 if (s->client_put != NULL) 259 if (s->client_put != NULL)
267 { 260 {
268 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 261 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
269 "Client: %p Deleting outbound PUT session to peer `%s'\n", 262 "Client: %p / %p Deleting outbound PUT session to peer `%s'\n",
270 s->client_put, GNUNET_i2s (&s->target)); 263 s, s->client_put, GNUNET_i2s (&s->target));
271 264
265 /* remove curl handle from multi handle */
272 mret = curl_multi_remove_handle (plugin->client_mh, s->client_put); 266 mret = curl_multi_remove_handle (plugin->client_mh, s->client_put);
273 if (mret != CURLM_OK) 267 if (mret != CURLM_OK)
274 { 268 {
275 curl_easy_cleanup (s->client_put); 269 /* clean up easy handle, handle is now invalid and free'd */
276 res = GNUNET_SYSERR; 270 res = GNUNET_SYSERR;
277 GNUNET_break (0); 271 GNUNET_break (0);
278 } 272 }
@@ -290,13 +284,15 @@ client_disconnect (struct Session *s)
290 if (s->client_get != NULL) 284 if (s->client_get != NULL)
291 { 285 {
292 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 286 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
293 "Client: %p Deleting outbound GET session to peer `%s'\n", 287 "Client: %p / %p Deleting outbound GET session to peer `%s'\n",
288 s,
294 s->client_get, GNUNET_i2s (&s->target)); 289 s->client_get, GNUNET_i2s (&s->target));
295 290
291 /* remove curl handle from multi handle */
296 mret = curl_multi_remove_handle (plugin->client_mh, s->client_get); 292 mret = curl_multi_remove_handle (plugin->client_mh, s->client_get);
297 if (mret != CURLM_OK) 293 if (mret != CURLM_OK)
298 { 294 {
299 curl_easy_cleanup (s->client_get); 295 /* clean up easy handle, handle is now invalid and free'd */
300 res = GNUNET_SYSERR; 296 res = GNUNET_SYSERR;
301 GNUNET_break (0); 297 GNUNET_break (0);
302 } 298 }
@@ -317,6 +313,8 @@ client_disconnect (struct Session *s)
317 313
318 plugin->cur_connections -= 2; 314 plugin->cur_connections -= 2;
319 315
316 notify_session_end (plugin, &s->target, s);
317
320 GNUNET_assert (plugin->outbound_sessions > 0); 318 GNUNET_assert (plugin->outbound_sessions > 0);
321 plugin->outbound_sessions --; 319 plugin->outbound_sessions --;
322 GNUNET_STATISTICS_set (plugin->env->stats, 320 GNUNET_STATISTICS_set (plugin->env->stats,
@@ -330,7 +328,6 @@ client_disconnect (struct Session *s)
330 GNUNET_SCHEDULER_cancel (plugin->client_perform_task); 328 GNUNET_SCHEDULER_cancel (plugin->client_perform_task);
331 plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK; 329 plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK;
332 } 330 }
333
334 client_schedule (plugin, GNUNET_YES); 331 client_schedule (plugin, GNUNET_YES);
335 332
336 return res; 333 return res;