diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-09-09 12:29:39 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-09-09 12:29:39 +0000 |
commit | d1ae5250289e7119c921173489b72c408da9a7e8 (patch) | |
tree | 6cee334c745327c77994e69c8a28df83d07a36c2 /src/transport/plugin_transport_http.c | |
parent | 3020d7339962057bb2275a0522a8c660e1835820 (diff) | |
download | gnunet-d1ae5250289e7119c921173489b72c408da9a7e8.tar.gz gnunet-d1ae5250289e7119c921173489b72c408da9a7e8.zip |
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index c5d92eada..5c0708e38 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -2085,39 +2085,52 @@ http_plugin_send (void *cls, | |||
2085 | /* session not existing, but address forced -> creating new session */ | 2085 | /* session not existing, but address forced -> creating new session */ |
2086 | if (ps==NULL) | 2086 | if (ps==NULL) |
2087 | { | 2087 | { |
2088 | if ((addr==NULL) && (addrlen==0)) | 2088 | if ((addr!=NULL) && (addrlen!=0)) |
2089 | { | 2089 | { |
2090 | ps = GNUNET_malloc(sizeof (struct Session)); | ||
2091 | #if DEBUG_SESSION_SELECTION | ||
2092 | if (force_address == GNUNET_YES) | ||
2093 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing connection & forced address: creating new session %X to peer %s\n", ps, GNUNET_i2s(target)); | ||
2094 | if (force_address != GNUNET_YES) | ||
2095 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing connection: creating new session %X to peer %s\n", ps, GNUNET_i2s(target)); | ||
2096 | #endif | ||
2097 | if ((addrlen!=0) && (addr!=NULL)) | ||
2098 | { | ||
2099 | ps->addr = GNUNET_malloc(addrlen); | ||
2100 | memcpy(ps->addr,addr,addrlen); | ||
2101 | ps->addrlen = addrlen; | ||
2102 | } | ||
2103 | else | ||
2104 | { | ||
2105 | ps->addr = NULL; | ||
2106 | ps->addrlen = 0; | ||
2107 | } | ||
2108 | ps->direction=OUTBOUND; | ||
2109 | ps->recv_connected = GNUNET_NO; | ||
2110 | ps->recv_force_disconnect = GNUNET_NO; | ||
2111 | ps->send_connected = GNUNET_NO; | ||
2112 | ps->send_force_disconnect = GNUNET_NO; | ||
2113 | ps->pending_msgs_head = NULL; | ||
2114 | ps->pending_msgs_tail = NULL; | ||
2115 | ps->peercontext=pc; | ||
2116 | ps->session_id = pc->session_id_counter; | ||
2117 | pc->session_id_counter++; | ||
2118 | ps->url = create_url (plugin, ps->addr, ps->addrlen, ps->session_id); | ||
2119 | if (ps->msgtok == NULL) | ||
2120 | ps->msgtok = GNUNET_SERVER_mst_create (&curl_receive_mst_cb, ps); | ||
2121 | GNUNET_CONTAINER_DLL_insert(pc->head,pc->tail,ps); | ||
2122 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
2123 | gettext_noop ("# HTTP outbound sessions for peers active"), | ||
2124 | 1, | ||
2125 | GNUNET_NO); | ||
2126 | } | ||
2127 | else | ||
2128 | { | ||
2090 | #if DEBUG_HTTP | 2129 | #if DEBUG_HTTP |
2091 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing session found & and no address given: no way to send this message to peer `%s'!\n", GNUNET_i2s(target)); | 2130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing session found & and no address given: no way to send this message to peer `%s'!\n", GNUNET_i2s(target)); |
2092 | #endif | 2131 | #endif |
2093 | return GNUNET_SYSERR; | 2132 | return GNUNET_SYSERR; |
2094 | } | 2133 | } |
2095 | ps = GNUNET_malloc(sizeof (struct Session)); | ||
2096 | #if DEBUG_SESSION_SELECTION | ||
2097 | if (force_address == GNUNET_YES) | ||
2098 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing connection & forced address: creating new session %X to peer %s\n", ps, GNUNET_i2s(target)); | ||
2099 | if (force_address != GNUNET_YES) | ||
2100 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No existing connection: creating new session %X to peer %s\n", ps, GNUNET_i2s(target)); | ||
2101 | #endif | ||
2102 | ps->direction=OUTBOUND; | ||
2103 | ps->recv_connected = GNUNET_NO; | ||
2104 | ps->recv_force_disconnect = GNUNET_NO; | ||
2105 | ps->send_connected = GNUNET_NO; | ||
2106 | ps->send_force_disconnect = GNUNET_NO; | ||
2107 | ps->pending_msgs_head = NULL; | ||
2108 | ps->pending_msgs_tail = NULL; | ||
2109 | ps->peercontext=pc; | ||
2110 | ps->session_id = pc->session_id_counter; | ||
2111 | pc->session_id_counter++; | ||
2112 | ps->url = create_url (plugin, ps->addr, ps->addrlen, ps->session_id); | ||
2113 | if (ps->msgtok == NULL) | ||
2114 | ps->msgtok = GNUNET_SERVER_mst_create (&curl_receive_mst_cb, ps); | ||
2115 | GNUNET_CONTAINER_DLL_insert(pc->head,pc->tail,ps); | ||
2116 | |||
2117 | GNUNET_STATISTICS_update (plugin->env->stats, | ||
2118 | gettext_noop ("# HTTP outbound sessions for peers active"), | ||
2119 | 1, | ||
2120 | GNUNET_NO); | ||
2121 | } | 2134 | } |
2122 | 2135 | ||
2123 | /* create msg */ | 2136 | /* create msg */ |