[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23875 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23875 - gnunet/src/transport |
Date: |
Tue, 18 Sep 2012 13:08:57 +0200 |
Author: wachs
Date: 2012-09-18 13:08:57 +0200 (Tue, 18 Sep 2012)
New Revision: 23875
Modified:
gnunet/src/transport/plugin_transport_http_client.c
gnunet/src/transport/plugin_transport_http_server.c
Log:
- changes to http
Modified: gnunet/src/transport/plugin_transport_http_client.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_client.c 2012-09-18 11:08:20 UTC
(rev 23874)
+++ gnunet/src/transport/plugin_transport_http_client.c 2012-09-18 11:08:57 UTC
(rev 23875)
@@ -34,7 +34,7 @@
#define VERBOSE_CURL GNUNET_YES
-#define PUT_DISCONNECT_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 2)
+#define PUT_DISCONNECT_TIMEOUT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 1)
#define ENABLE_PUT GNUNET_YES
#define ENABLE_GET GNUNET_YES
@@ -694,6 +694,8 @@
client_schedule (s->plugin, GNUNET_YES);
}
+
+
/**
* Callback method used with libcurl
* Method is called when libcurl needs to read data during sending
@@ -800,14 +802,13 @@
struct HTTP_Client_Plugin *plugin;
struct GNUNET_TIME_Relative delay;
struct GNUNET_ATS_Information atsi[2];
- //GNUNET_break (0);
if (GNUNET_YES != client_exist_session(p, s))
{
GNUNET_break (0);
return GNUNET_OK;
}
plugin = s->plugin;
- //GNUNET_break (0);
+
atsi[0].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
atsi[0].value = htonl (1);
atsi[1].type = htonl (GNUNET_ATS_NETWORK_TYPE);
@@ -817,6 +818,7 @@
delay = s->plugin->env->receive (plugin->env->cls, &s->target, message,
(const struct GNUNET_ATS_Information *)
&atsi, 2,
s, s->addr, s->addrlen);
+
s->next_receive =
GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), delay);
@@ -833,10 +835,26 @@
}
+/**
+ * Callback method used with libcurl when data for a PUT connection are
+ * received. We do not expect data here, so we just dismiss it
+ *
+ * @param stream pointer where to write data
+ * @param size size of an individual element
+ * @param nmemb count of elements that can be written to the buffer
+ * @param cls destination pointer, passed to the libcurl handle
+ * @return bytes read from stream
+ */
+static size_t
+client_receive_put (void *stream, size_t size, size_t nmemb, void *cls)
+{
+ return size * nmemb;
+}
+
/**
- * Callback method used with libcurl
- * Method is called when libcurl needs to write data during sending
+ * Callback method used with libcurl when data for a GET connection are
+ * received. Forward to MST
*
* @param stream pointer where to write data
* @param size size of an individual element
@@ -875,9 +893,8 @@
}
if (NULL == s->msg_tk)
s->msg_tk = GNUNET_SERVER_mst_create (&client_receive_mst_cb, s);
- (void) GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO,
GNUNET_NO);
+ GNUNET_SERVER_mst_receive (s->msg_tk, s, stream, len, GNUNET_NO, GNUNET_NO);
return len;
-
}
@@ -1118,7 +1135,7 @@
//curl_easy_setopt (s->client_put, CURLOPT_WRITEHEADER, ps);
curl_easy_setopt (s->client_put, CURLOPT_READFUNCTION, client_send_cb);
curl_easy_setopt (s->client_put, CURLOPT_READDATA, s);
- curl_easy_setopt (s->client_put, CURLOPT_WRITEFUNCTION, client_receive);
+ curl_easy_setopt (s->client_put, CURLOPT_WRITEFUNCTION, client_receive_put);
curl_easy_setopt (s->client_put, CURLOPT_WRITEDATA, s);
/* No timeout by default, timeout done with session timeout */
curl_easy_setopt (s->client_put, CURLOPT_TIMEOUT, 0);
Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2012-09-18 11:08:20 UTC
(rev 23874)
+++ gnunet/src/transport/plugin_transport_http_server.c 2012-09-18 11:08:57 UTC
(rev 23875)
@@ -524,6 +524,11 @@
if (GNUNET_YES == session->server_send->disconnect)
return GNUNET_SYSERR;
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, session->plugin->name,
+ "Session %p/connection %p: Sending message with %u to peer
`%s' with \n",
+ session, session->server_send,
+ msgbuf_size, GNUNET_i2s (&session->target));
+
/* create new message and schedule */
bytes_sent = sizeof (struct HTTP_Message) + msgbuf_size;
msg = GNUNET_malloc (bytes_sent);
@@ -1167,7 +1172,8 @@
GNUNET_free (msg);
}
}
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name,
+ if (0 < bytes_read)
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name,
"Sent %u bytes to peer `%s' with session %p \n",
bytes_read, GNUNET_i2s (&s->target), s);
return bytes_read;
}
@@ -1248,10 +1254,10 @@
struct MHD_Response *response;
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- _("Access from connection %p (%u of %u) for %s %s url `%s'
\n"),
+ _("Access from connection %p (%u of %u) for `%s' `%s' url
`%s' with upload data size %u\n"),
sc,
plugin->cur_connections, plugin->max_connections,
- method, version, url);
+ method, version, url, (*upload_data_size));
GNUNET_assert (cls != NULL);
if (sc == NULL)
@@ -1259,7 +1265,9 @@
/* new connection */
sc = server_lookup_connection (plugin, mhd_connection, url, method);
if (sc != NULL)
+ {
(*httpSessionCache) = sc;
+ }
else
{
response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE),
HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO);
@@ -1281,7 +1289,6 @@
/* existing connection */
sc = (*httpSessionCache);
s = sc->session;
-
GNUNET_assert (NULL != s);
/* connection is to be disconnected */
if (sc->disconnect == GNUNET_YES)
@@ -1294,14 +1301,7 @@
MHD_destroy_response (response);
return MHD_YES;
}
-
GNUNET_assert (s != NULL);
- /* Check if both directions are connected */
- if ((sc->session->server_recv == NULL) || (sc->session->server_send == NULL))
- {
- /* Delayed read from since not both semi-connections are connected */
- return MHD_YES;
- }
if (sc->direction == _SEND)
{
@@ -1319,7 +1319,8 @@
{
/* (*upload_data_size == 0) first callback when header are passed */
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Peer `%s' PUT on address `%s' connected\n",
+ "Session %p / Connection %p: Peer `%s' PUT on address
`%s' connected\n",
+ s, sc,
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
s->addr,
@@ -1331,7 +1332,8 @@
{
/* (*upload_data_size == 0) when upload is complete */
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Peer `%s' PUT on address `%s' finished upload\n",
+ "Session %p / Connection %p: Peer `%s' PUT on address
`%s' finished upload\n",
+ s, sc,
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
s->addr,
@@ -1349,7 +1351,8 @@
{
/* (*upload_data_size > 0) for every segment received */
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Peer `%s' PUT on address `%s' received %u bytes\n",
+ "Session %p / Connection %p: Peer `%s' PUT on address
`%s' received %u bytes\n",
+ s, sc,
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
s->addr,
@@ -1376,8 +1379,8 @@
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%p no inbound bandwidth available! Next read was delayed
by %llu ms\n",
- s, now.abs_value - s->next_receive.abs_value);
+ "Session %p / Connection %p: no inbound bandwidth
available! Next read was delayed by %llu ms\n",
+ s, sc, now.abs_value - s->next_receive.abs_value);
}
return MHD_YES;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23875 - gnunet/src/transport,
gnunet <=