[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23862 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23862 - gnunet/src/transport |
Date: |
Mon, 17 Sep 2012 16:04:59 +0200 |
Author: wachs
Date: 2012-09-17 16:04:59 +0200 (Mon, 17 Sep 2012)
New Revision: 23862
Modified:
gnunet/src/transport/plugin_transport_http_server.c
Log:
- refactored access_cb
Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2012-09-17 14:01:16 UTC
(rev 23861)
+++ gnunet/src/transport/plugin_transport_http_server.c 2012-09-17 14:04:59 UTC
(rev 23862)
@@ -153,6 +153,9 @@
/* Should this connection get disconnected? GNUNET_YES/NO */
int disconnect;
+ /* For PUT connections: Is this the first or last callback with size 0 */
+ int connected;
+
/* The session this server connection belongs to */
struct Session *session;
@@ -511,7 +514,7 @@
GNUNET_break (0);
return GNUNET_SYSERR;
}
- if ((NULL == session->server_send) || (NULL == session->server_recv))
+ if (NULL == session->server_send)
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -1055,6 +1058,7 @@
sc->mhd_daemon = plugin->server_v6;
sc->mhd_conn = mhd_connection;
sc->direction = direction;
+ sc->connected = GNUNET_NO;
sc->session = s;
if (direction == _SEND)
s->server_send = sc;
@@ -1165,9 +1169,6 @@
}
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;
}
@@ -1285,7 +1286,7 @@
/* connection is to be disconnected */
if (sc->disconnect == GNUNET_YES)
{
- /* Sent HTTP/1.1: 200 OK as PUT Response\ */
+ /* Sent HTTP/1.1: 200 OK as response */
response = MHD_create_response_from_data (strlen ("Thank you!"),
"Thank you!",
MHD_NO, MHD_NO);
@@ -1314,21 +1315,40 @@
}
if (sc->direction == _RECEIVE)
{
- if (*upload_data_size == 0)
+ if ((*upload_data_size == 0) && (sc->connected == GNUNET_NO))
{
+ /* (*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",
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
s->addr,
s->addrlen));
+ sc->connected = GNUNET_YES;
return MHD_YES;
}
-
- /* Receiving data */
- if ((*upload_data_size > 0))
+ else if ((*upload_data_size == 0) && (sc->connected == GNUNET_YES))
{
+ /* (*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",
+ GNUNET_i2s (&s->target),
+ http_common_plugin_address_to_string (NULL,
+ s->addr,
+ s->addrlen));
+ sc->connected = GNUNET_NO;
+ /* Sent HTTP/1.1: 200 OK as PUT Response\ */
+ response = MHD_create_response_from_data (strlen ("Thank you!"),
+ "Thank you!",
+ MHD_NO, MHD_NO);
+ res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
+ MHD_destroy_response (response);
+ return MHD_YES;
+ }
+ else if ((*upload_data_size > 0) && (sc->connected == GNUNET_YES))
+ {
+ /* (*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",
GNUNET_i2s (&s->target),
http_common_plugin_address_to_string (NULL,
@@ -1362,7 +1382,10 @@
return MHD_YES;
}
else
+ {
+ GNUNET_break (0);
return MHD_NO;
+ }
}
return res;
}
@@ -1429,6 +1452,7 @@
GNUNET_i2s (&s->target), s->server_recv,
http_common_plugin_address_to_string (NULL, s->addr,
s->addrlen));
s->server_recv = NULL;
+ /* Do not terminate session when PUT disconnects
if (NULL != (s->server_send))
{
s->server_send->disconnect = GNUNET_YES;
@@ -1438,7 +1462,7 @@
1);
#endif
server_reschedule (plugin, s->server_send->mhd_daemon, GNUNET_NO);
- }
+ }*/
if (s->msg_tk != NULL)
{
GNUNET_SERVER_mst_destroy (s->msg_tk);
@@ -1612,7 +1636,10 @@
last_timeout, timeout);
last_timeout = timeout;
}
- tv.rel_value = (uint64_t) timeout;
+ if (timeout <= GNUNET_TIME_UNIT_SECONDS.rel_value)
+ tv.rel_value = (uint64_t) timeout;
+ else
+ tv = GNUNET_TIME_UNIT_SECONDS;
}
else
tv = GNUNET_TIME_UNIT_SECONDS;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23862 - gnunet/src/transport,
gnunet <=