#include <curl/curl.h>
-#define DEBUG_HTTP GNUNET_YES
-#define VERBOSE_SERVER GNUNET_YES
-#define VERBOSE_CLIENT GNUNET_YES
-#define VERBOSE_CURL GNUNET_YES
+#define DEBUG_HTTP GNUNET_NO
+#define VERBOSE_SERVER GNUNET_NO
+#define VERBOSE_CLIENT GNUNET_NO
+#define VERBOSE_CURL GNUNET_NO
#if BUILD_HTTPS
#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_https_init
void *server_recv;
void *server_send;
- struct GNUNET_TIME_Absolute delay;
+ struct GNUNET_TIME_Absolute next_receive;
GNUNET_SCHEDULER_TaskIdentifier recv_wakeup_task;
uint32_t tag;
if ((s != NULL) && (s->client_put_paused == GNUNET_YES))
{
+#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, s->plugin->name, "Client: %X was suspended, unpausing\n", s->client_put);
+#endif
s->client_put_paused = GNUNET_NO;
curl_easy_pause(s->client_put, CURLPAUSE_CONT);
}
struct GNUNET_TIME_Relative delay;
delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "CLIENT: CLIENT DELAY %llu ms\n",
+ delay.rel_value);
+
- s->delay = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
+ s->next_receive = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
- if (GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value)
+ if (GNUNET_TIME_absolute_get().abs_value < s->next_receive.abs_value)
{
#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: peer `%s' address `%s' next read delayed for %llu ms\n",
client_receive (void *stream, size_t size, size_t nmemb, void *cls)
{
struct Session *s = cls;
- struct Plugin *plugin = s->plugin;
struct GNUNET_TIME_Absolute now;
size_t len = size * nmemb;
#if VERBOSE_CLIENT
+ struct Plugin *plugin = s->plugin;
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: Received %Zu bytes from peer `%s'\n",
len,
GNUNET_i2s (&s->target));
#endif
now = GNUNET_TIME_absolute_get();
- if (now.abs_value < s->delay.abs_value)
+ if (now.abs_value < s->next_receive.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",
- s, GNUNET_TIME_absolute_get_difference(s->delay, GNUNET_TIME_absolute_get()).rel_value);
+ s, GNUNET_TIME_absolute_get_difference(s->next_receive, GNUNET_TIME_absolute_get()).rel_value);
#endif
+#if 0
if (s->recv_wakeup_task != GNUNET_SCHEDULER_NO_TASK)
{
GNUNET_SCHEDULER_cancel (s->recv_wakeup_task);
s->recv_wakeup_task = GNUNET_SCHEDULER_NO_TASK;
}
- s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed( GNUNET_TIME_absolute_get_difference(s->delay, now), &client_wake_up, s);
+ s->recv_wakeup_task = GNUNET_SCHEDULER_add_delayed( GNUNET_TIME_absolute_get_difference(s->next_receive, now), &client_wake_up, s);
return CURLPAUSE_ALL;
#endif
}
client_send_cb (void *stream, size_t size, size_t nmemb, void *cls)
{
struct Session *s = cls;
+#if VERBOSE_CLIENT
struct Plugin *plugin = s->plugin;
+#endif
size_t bytes_sent = 0;
size_t len;
struct HTTP_Message *msg = s->msg_head;
-/*
- if (s->put_paused == GNUNET_NO)
- return CURL_READFUNC_PAUSE;
- if ((s->msg_head == NULL) && (s->put_paused == GNUNET_YES))
- {
-#if VERBOSE_CLIENT
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Suspending handle `%s' `%s'\n",
- GNUNET_i2s (&s->target),GNUNET_a2s (s->addr, s->addrlen));
-#endif
- s->put_paused = GNUNET_NO;
- return CURL_READFUNC_PAUSE;
- }
-*/
+
if (msg == NULL)
{
+#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Client: %X Nothing to send! Suspending PUT handle!\n", s->client_put);
+#endif
s->client_put_paused = GNUNET_YES;
return CURL_READFUNC_PAUSE;
}
s->transmit_cont = cont;
s->transmit_cont_cls = cont_cls;
s->next = NULL;
- s->delay = GNUNET_TIME_absolute_get_forever();
+ s->next_receive = GNUNET_TIME_absolute_get_forever();
return s;
}
int res = GNUNET_SYSERR;
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Sending %u bytes to peer `%s' on address `%s' %X %i\n", msgbuf_size,
GNUNET_i2s (target), ((addr != NULL) && (addrlen != 0)) ? http_plugin_address_to_string(plugin, addr, addrlen) : "<inbound>", session, force_address);
#endif
/* look for existing connection */
s = lookup_session (plugin, target, session, addr, addrlen, 1);
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"%s existing session: %s\n", (s!=NULL) ? "Found" : "NOT Found", ((s != NULL) && (s->inbound == GNUNET_YES)) ? "inbound" : "outbound");
#endif
}
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Initiiating new connection to peer `%s'\n",
GNUNET_i2s (target));
#endif
if (s->inbound == GNUNET_NO)
{
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Using outbound client session to send to `%s'\n",
GNUNET_i2s (target));
#endif
server_send (s, msg);
res = msgbuf_size;
#if DEBUG_HTTP
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Using inbound server session to send to `%s'\n",
GNUNET_i2s (target));
#endif
socklen_t addrlen)
{
GNUNET_assert (cls != NULL);
+#if DEBUG_HTTP
struct Plugin *plugin = cls;
+#endif
static int limit;
#if DEBUG_HTTP
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
GNUNET_SERVICE_get_server_addresses (plugin->name, plugin->env->cfg,
&addrs, &addrlens);
#if 0
- GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
_("FOUND %u addresses\n"),res);
#endif
const struct GNUNET_MessageHeader *message)
{
struct Session *s = cls;
+#if VERBOSE_SERVER
struct Plugin *plugin = s->plugin;
+#endif
struct GNUNET_TIME_Relative delay;
delay = http_plugin_receive (s, &s->target, message, s, s->addr, s->addrlen);
- s->delay = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Server: SERVER DELAY %llu ms\n",
- delay.rel_value);
+ s->next_receive = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), delay);
- if (GNUNET_TIME_absolute_get().abs_value < s->delay.abs_value)
+ if (delay.rel_value > 0)
{
#if VERBOSE_CLIENT
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, "Server: peer `%s' address `%s' next read delayed for %llu ms\n",
server_send_callback (void *cls, uint64_t pos, char *buf, size_t max)
{
struct Session *s = cls;
- struct Plugin *plugin = s->plugin;
+
struct HTTP_Message *msg;
int bytes_read = 0;
//static int c = 0;
}
#if VERBOSE_CLIENT
+ struct Plugin *plugin = s->plugin;
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
"Server: %X: sent %u bytes\n",
s, bytes_read);
const char *upload_data, size_t * upload_data_size,
void **httpSessionCache)
{
+
struct Plugin *plugin = cls;
struct ServerConnection *sc = *httpSessionCache;
struct Session *s = NULL;
NULL);
s->inbound = GNUNET_YES;
- s->delay = GNUNET_TIME_absolute_get_zero();
+ s->next_receive = GNUNET_TIME_absolute_get_zero();
s->tag= tag;
if (0 == strcmp (MHD_HTTP_METHOD_PUT, method))
s->server_recv = s;
GNUNET_i2s (&s->target), GNUNET_a2s (s->addr, s->addrlen), *upload_data_size);
#endif
struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get();
- if (( s->delay.abs_value < now.abs_value))
+ if (( s->next_receive.abs_value <= now.abs_value))
{
#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
s->msg_tk = GNUNET_SERVER_mst_create (&server_receive_mst_cb, s);
}
res = GNUNET_SERVER_mst_receive (s->msg_tk, s, upload_data, *upload_data_size, GNUNET_NO, GNUNET_NO);
+#if VERBOSE_SERVER
GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
- "Server: Received %Zu bytes\n",
- *upload_data_size);
+ "Server: Received %Zu bytes\n", *upload_data_size);
+#endif
(*upload_data_size) = 0;
}
else
{
-
#if DEBUG_HTTP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Connection %X: no inbound bandwidth available! Next read was delayed by %llu ms\n", s, now.abs_value - s->delay.abs_value);
+ "Server: %X no inbound bandwidth available! Next read was delayed by %llu ms\n", s, now.abs_value - s->next_receive.abs_value);
#endif
-
}
return MHD_YES;
}