[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r17017 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r17017 - gnunet/src/transport |
Date: |
Mon, 26 Sep 2011 17:58:11 +0200 |
Author: wachs
Date: 2011-09-26 17:58:11 +0200 (Mon, 26 Sep 2011)
New Revision: 17017
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:
fixed:
- session matching
- curl send handle suspending
Modified: gnunet/src/transport/plugin_transport_http.h
===================================================================
--- gnunet/src/transport/plugin_transport_http.h 2011-09-26 15:56:52 UTC
(rev 17016)
+++ gnunet/src/transport/plugin_transport_http.h 2011-09-26 15:58:11 UTC
(rev 17017)
@@ -244,7 +244,7 @@
void *client_put;
void *client_get;
- int put_paused;
+ int client_put_paused;
void *server_recv;
void *server_send;
Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2011-09-26 15:56:52 UTC
(rev 17016)
+++ gnunet/src/transport/plugin_transport_http_client.c 2011-09-26 15:58:11 UTC
(rev 17017)
@@ -61,15 +61,6 @@
}
#endif
-int
-client_send (struct Session *s, struct HTTP_Message *msg)
-{
- GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg);
- if (s != NULL)
- curl_easy_pause(s->client_put, CURLPAUSE_CONT);
- return GNUNET_OK;
-}
-
/**
* Task performing curl operations
* @param cls plugin as closure
@@ -148,6 +139,25 @@
}
+int
+client_send (struct Session *s, struct HTTP_Message *msg)
+{
+ GNUNET_CONTAINER_DLL_insert (s->msg_head, s->msg_tail, msg);
+
+ if ((s != NULL) && (s->client_put_paused == GNUNET_YES))
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, "Client: %X was
suspended, unpausing\n", s->client_put);
+ s->client_put_paused = GNUNET_NO;
+ curl_easy_pause(s->client_put, CURLPAUSE_CONT);
+ }
+
+ client_schedule (s->plugin);
+
+ return GNUNET_OK;
+}
+
+
+
/**
* Task performing curl operations
* @param cls plugin as closure
@@ -335,16 +345,19 @@
struct Session *s = cls;
struct Plugin *plugin = s->plugin;
struct GNUNET_TIME_Absolute now;
+ size_t len = size * nmemb;
+
#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: Received
%Zu bytes from peer `%s'\n",
- size * nmemb,
+ len,
GNUNET_i2s (&s->target));
#endif
now = GNUNET_TIME_absolute_get();
if (now.abs_value < s->delay.abs_value)
{
+#if 0
#if DEBUG_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No inbound bandwidth available! Next read was delayed for
%llu ms\n",
@@ -357,16 +370,19 @@
}
s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed(
GNUNET_TIME_absolute_get_difference(s->delay, now), &client_wake_up, s);
return CURLPAUSE_ALL;
+#endif
}
if (s->msg_tk == NULL)
s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s);
- GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, size * nmemb, GNUNET_NO,
+ GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO,
GNUNET_NO);
- return (size * nmemb);
+ return len;
+
+ client_wake_up (NULL, NULL);
}
/**
@@ -376,7 +392,7 @@
* @param size size of an individual element
* @param nmemb count of elements that can be written to the buffer
* @param ptr source pointer, passed to the libcurl handle
- * @return bytes written to stream
+ * @return bytes written to stream, returning 0 will terminate connection!
*/
static size_t
client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
@@ -401,7 +417,12 @@
}
*/
if (msg == NULL)
- return bytes_sent;
+ {
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: %X
Nothing to send! Suspending PUT handle!\n", s->client_put);
+ s->client_put_paused = GNUNET_YES;
+ return CURL_READFUNC_PAUSE;
+ }
+
GNUNET_assert (msg != NULL);
/* data to send */
if (msg->pos < msg->size)
Modified: gnunet/src/transport/plugin_transport_http_new.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_new.c 2011-09-26 15:56:52 UTC
(rev 17016)
+++ gnunet/src/transport/plugin_transport_http_new.c 2011-09-26 15:58:11 UTC
(rev 17017)
@@ -340,6 +340,12 @@
return NULL;
while (t != NULL)
{
+#if 0
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ "Comparing peer `%s' address `%s' len %i session %X to
\n", GNUNET_i2s(target), GNUNET_a2s(addr,addrlen), addrlen, session);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"peer `%s' address
`%s' len %i session %X \n\n", GNUNET_i2s(&t->target),
GNUNET_a2s(t->addr,t->addrlen), t->addrlen, t);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,"memcmp %i \n",
memcmp (addr, t->addr, addrlen));
+#endif
e_peer = GNUNET_NO;
e_addr = GNUNET_NO;
@@ -348,7 +354,7 @@
e_peer = GNUNET_YES;
if (addrlen == t->addrlen)
{
- if (0 == memcmp (addr, &t->addr, addrlen))
+ if (0 == memcmp (addr, t->addr, addrlen))
{
e_addr = GNUNET_YES;
}
@@ -492,7 +498,7 @@
s = lookup_session (plugin, target, session, addr, addrlen, 1);
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
- "%s exisiting session\n", (s!=NULL) ? "Found" : "NOT
Found");
+ "%s existing session: %s\n", (s!=NULL) ? "Found" : "NOT
Found", ((s != NULL) && (s->inbound == GNUNET_YES)) ? "inbound" : "outbound");
#endif
/* create new outbound connection */
@@ -749,7 +755,7 @@
{
GNUNET_assert (cls != NULL);
struct Plugin *plugin = cls;
- //static int limit;
+ static int limit;
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"NPMC called %s to address `%s'\n",
@@ -761,9 +767,9 @@
{
case GNUNET_YES:
// FIXME DEBUGGING
- //if (limit < 1)
+ if (limit < 1)
nat_add_address (cls, add_remove, addr, addrlen);
- //limit++;
+ limit++;
// FIXME END
break;
case GNUNET_NO:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r17017 - gnunet/src/transport,
gnunet <=