diff options
-rw-r--r-- | src/transport/plugin_transport_http.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 4f15a95a2..5dcdea400 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -534,6 +534,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
534 | GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) || | 534 | GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) || |
535 | (addrlen == sizeof (struct IPv6HttpAddress))); | 535 | (addrlen == sizeof (struct IPv6HttpAddress))); |
536 | 536 | ||
537 | |||
537 | /* look for existing connection */ | 538 | /* look for existing connection */ |
538 | s = lookup_session (plugin, target, session, addr, addrlen, 1); | 539 | s = lookup_session (plugin, target, session, addr, addrlen, 1); |
539 | #if DEBUG_HTTP | 540 | #if DEBUG_HTTP |
@@ -561,13 +562,36 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
561 | "Initiiating new connection to peer `%s'\n", | 562 | "Initiiating new connection to peer `%s'\n", |
562 | GNUNET_i2s (target)); | 563 | GNUNET_i2s (target)); |
563 | #endif | 564 | #endif |
564 | s = create_session (plugin, target, addr, addrlen, cont, cont_cls); | 565 | int res = GNUNET_OK; |
565 | GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); | 566 | |
566 | // initiate new connection | 567 | if (addrlen == sizeof (struct IPv4HttpAddress)) |
567 | if (GNUNET_SYSERR == (res = client_connect (s))) | ||
568 | { | 568 | { |
569 | GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s); | 569 | struct IPv4HttpAddress * a4 = (struct IPv4HttpAddress *) addr; |
570 | delete_session (s); | 570 | if (ntohs(a4->u4_port) == 0) |
571 | res = GNUNET_SYSERR; | ||
572 | } | ||
573 | if (addrlen == sizeof (struct IPv6HttpAddress)) | ||
574 | { | ||
575 | struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr; | ||
576 | if (ntohs(a6->u6_port) == 0) | ||
577 | res = GNUNET_SYSERR; | ||
578 | } | ||
579 | if (res == GNUNET_OK) | ||
580 | { | ||
581 | s = create_session (plugin, target, addr, addrlen, cont, cont_cls); | ||
582 | GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s); | ||
583 | // initiate new connection | ||
584 | res = client_connect (s); | ||
585 | } | ||
586 | if (res == GNUNET_SYSERR) | ||
587 | { | ||
588 | if (s != NULL) | ||
589 | { | ||
590 | GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s); | ||
591 | delete_session (s); | ||
592 | } | ||
593 | if (cont != NULL) | ||
594 | cont (cont_cls, target, GNUNET_SYSERR); | ||
571 | return GNUNET_SYSERR; | 595 | return GNUNET_SYSERR; |
572 | } | 596 | } |
573 | } | 597 | } |