[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16862 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16862 - gnunet/src/transport |
Date: |
Thu, 15 Sep 2011 14:31:33 +0200 |
Author: wachs
Date: 2011-09-15 14:31:32 +0200 (Thu, 15 Sep 2011)
New Revision: 16862
Modified:
gnunet/src/transport/plugin_transport_http.h
gnunet/src/transport/plugin_transport_http_client.c
gnunet/src/transport/plugin_transport_http_new.c
Log:
implemented disconnect notifications for outbound connections
Modified: gnunet/src/transport/plugin_transport_http.h
===================================================================
--- gnunet/src/transport/plugin_transport_http.h 2011-09-15 12:30:50 UTC
(rev 16861)
+++ gnunet/src/transport/plugin_transport_http.h 2011-09-15 12:31:32 UTC
(rev 16862)
@@ -252,4 +252,9 @@
void
server_stop (struct Plugin *plugin);
+void
+notify_session_end (void *cls,
+ const struct GNUNET_PeerIdentity *
+ peer, struct Session * s);
+
/* end of plugin_transport_http.h */
Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2011-09-15 12:30:50 UTC
(rev 16861)
+++ gnunet/src/transport/plugin_transport_http_client.c 2011-09-15 12:31:32 UTC
(rev 16862)
@@ -158,15 +158,34 @@
plugin->client_perform_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
+
do
{
running = 0;
mret = curl_multi_perform (plugin->client_mh, &running);
- if ((running < handles_last_run) && (running > 0))
- {
- }
- //curl_handle_finished (plugin);
+ CURLMsg * msg;
+ int msgs_left;
+ while ((msg = curl_multi_info_read(plugin->client_mh, &msgs_left)))
+ {
+ CURL *easy_h = msg->easy_handle;
+ struct Session *s;
+ GNUNET_assert (easy_h != NULL);
+
+ GNUNET_assert (CURLE_OK == curl_easy_getinfo(easy_h, CURLINFO_PRIVATE,
&s));
+ GNUNET_assert (s != NULL);
+
+ if (msg->msg == CURLMSG_DONE)
+ {
+#if DEBUG_HTTP
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Connection to '%s' %s ended\n", GNUNET_i2s(&s->target),
http_plugin_address_to_string(s->plugin, s->addr, s->addrlen));
+#endif
+ client_disconnect(s);
+ notify_session_end (s->plugin, &s->target, s);
+ }
+ }
+
handles_last_run = running;
}
while (mret == CURLM_CALL_MULTI_PERFORM);
@@ -181,8 +200,8 @@
struct Plugin *plugin = s->plugin;
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "Deleting outbound session peer `%s'\n",
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Deleting outbound PUT session to peer `%s'\n",
GNUNET_i2s (&s->target));
#endif
@@ -195,6 +214,12 @@
}
curl_easy_cleanup (s->client_put);
+#if DEBUG_HTTP
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
+ "Deleting outbound GET session to peer `%s'\n",
+ GNUNET_i2s (&s->target));
+#endif
+
mret = curl_multi_remove_handle (plugin->client_mh, s->client_get);
if (mret != CURLM_OK)
{
@@ -225,7 +250,7 @@
CURLMcode mret;
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name,
"Initiating outbound session peer `%s'\n",
GNUNET_i2s (&s->target));
#endif
@@ -233,13 +258,8 @@
s->inbound = GNUNET_NO;
/* create url */
- GNUNET_asprintf (&url, "%s://%s/", s->plugin->protocol,
- http_plugin_address_to_string (NULL, s->addr, s->addrlen));
+ GNUNET_asprintf (&url, "%s", http_plugin_address_to_string (s->plugin,
s->addr, s->addrlen));
-#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, s->plugin->name, "URL `%s'\n",
url);
-#endif
-
/* create get connection */
s->client_get = curl_easy_init ();
#if VERBOSE_CLIENT
@@ -261,7 +281,7 @@
//curl_easy_setopt (s->client_get, CURLOPT_WRITEDATA, ps);
curl_easy_setopt (s->client_get, CURLOPT_TIMEOUT_MS,
(long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value);
- //curl_easy_setopt (s->client_get, CURLOPT_PRIVATE, ps);
+ curl_easy_setopt (s->client_get, CURLOPT_PRIVATE, s);
curl_easy_setopt (s->client_get, CURLOPT_CONNECTTIMEOUT_MS,
(long) HTTP_NOT_VALIDATED_TIMEOUT.rel_value);
curl_easy_setopt (s->client_get, CURLOPT_BUFFERSIZE,
@@ -292,7 +312,7 @@
//curl_easy_setopt (s->client_put, CURLOPT_WRITEDATA, ps);
curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT_MS,
(long) GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.rel_value);
- //curl_easy_setopt (s->client_put, CURLOPT_PRIVATE, ps);
+ curl_easy_setopt (s->client_put, CURLOPT_PRIVATE, s);
curl_easy_setopt (s->client_put, CURLOPT_CONNECTTIMEOUT_MS,
(long) HTTP_NOT_VALIDATED_TIMEOUT.rel_value);
curl_easy_setopt (s->client_put, CURLOPT_BUFFERSIZE,
Modified: gnunet/src/transport/plugin_transport_http_new.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_new.c 2011-09-15 12:30:50 UTC
(rev 16861)
+++ gnunet/src/transport/plugin_transport_http_new.c 2011-09-15 12:31:32 UTC
(rev 16862)
@@ -306,6 +306,8 @@
const char *
http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
{
+ struct Plugin *plugin = cls;
+
const struct IPv4HttpAddress *t4;
const struct IPv6HttpAddress *t6;
struct sockaddr_in a4;
@@ -315,6 +317,8 @@
uint16_t port;
int res;
+ GNUNET_assert (plugin != NULL);
+
if (addrlen == sizeof (struct IPv6HttpAddress))
{
address = GNUNET_malloc (INET6_ADDRSTRLEN);
@@ -338,9 +342,11 @@
}
GNUNET_assert (strlen (address) + 7 < (INET6_ADDRSTRLEN + 13));
+ if (addrlen == sizeof (struct IPv6HttpAddress))
+ res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://[%s]:%u/",
plugin->protocol, address, port);
+ else if (addrlen == sizeof (struct IPv4HttpAddress))
+ res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s://%s:%u/",
plugin->protocol, address, port);
- res = GNUNET_snprintf (rbuf, sizeof (rbuf), "%s:%u", address, port);
-
GNUNET_free (address);
GNUNET_assert (res != 0);
return rbuf;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16862 - gnunet/src/transport,
gnunet <=