aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-08-23 12:56:34 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-08-23 12:56:34 +0000
commit68a22fe2d7ae2bb53cc0b2a7b6546f0b41e15c0a (patch)
tree97594939df16b6eac7407f36677972ae58e97538 /src/transport
parent50a26de548ec58000ad6232a949dee62be521177 (diff)
downloadgnunet-68a22fe2d7ae2bb53cc0b2a7b6546f0b41e15c0a.tar.gz
gnunet-68a22fe2d7ae2bb53cc0b2a7b6546f0b41e15c0a.zip
Added MHD_EXTERNAL_LOGGER to log mhd messages with GNUnet logger
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_http.c10
-rw-r--r--src/transport/plugin_transport_https.c27
2 files changed, 29 insertions, 8 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 64ef8849b..9169af5d1 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -363,6 +363,7 @@ struct Plugin
363 char * bind_hostname; 363 char * bind_hostname;
364 int use_ipv6; 364 int use_ipv6;
365 int use_ipv4; 365 int use_ipv4;
366 void * mhd_log;
366}; 367};
367 368
368 369
@@ -638,6 +639,13 @@ process_interfaces (void *cls,
638 return GNUNET_OK; 639 return GNUNET_OK;
639} 640}
640 641
642void mhd_logger (void * arg, const char * fmt, va_list ap)
643{
644 char text[1024];
645 vsnprintf(text, 1024, fmt, ap);
646 va_end(ap);
647 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"MHD: %s \n", text);
648}
641 649
642/** 650/**
643 * Callback called by MHD when a connection is terminated 651 * Callback called by MHD when a connection is terminated
@@ -2459,6 +2467,7 @@ libgnunet_plugin_transport_http_init (void *cls)
2459 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout, 2467 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout,
2460 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024), 2468 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
2461 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL, 2469 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL,
2470 MHD_OPTION_EXTERNAL_LOGGER, mhd_logger, plugin->mhd_log,
2462 MHD_OPTION_END); 2471 MHD_OPTION_END);
2463 } 2472 }
2464 if ((plugin->http_server_daemon_v4 == NULL) && (plugin->use_ipv4 == GNUNET_YES) && (port != 0)) 2473 if ((plugin->http_server_daemon_v4 == NULL) && (plugin->use_ipv4 == GNUNET_YES) && (port != 0))
@@ -2477,6 +2486,7 @@ libgnunet_plugin_transport_http_init (void *cls)
2477 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout, 2486 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout,
2478 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024), 2487 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
2479 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL, 2488 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL,
2489 MHD_OPTION_EXTERNAL_LOGGER, mhd_logger, plugin->mhd_log,
2480 MHD_OPTION_END); 2490 MHD_OPTION_END);
2481 } 2491 }
2482 if (plugin->http_server_daemon_v4 != NULL) 2492 if (plugin->http_server_daemon_v4 != NULL)
diff --git a/src/transport/plugin_transport_https.c b/src/transport/plugin_transport_https.c
index ab39eb046..aa4adbf92 100644
--- a/src/transport/plugin_transport_https.c
+++ b/src/transport/plugin_transport_https.c
@@ -42,7 +42,7 @@
42#include <curl/curl.h> 42#include <curl/curl.h>
43 43
44#define DEBUG_HTTPS GNUNET_NO 44#define DEBUG_HTTPS GNUNET_NO
45#define VERBOSE GNUNET_NO 45#define VERBOSE GNUNET_YES
46#define DEBUG_CURL GNUNET_NO 46#define DEBUG_CURL GNUNET_NO
47#define DEBUG_CONNECTIONS GNUNET_NO 47#define DEBUG_CONNECTIONS GNUNET_NO
48#define DEBUG_SESSION_SELECTION GNUNET_NO 48#define DEBUG_SESSION_SELECTION GNUNET_NO
@@ -372,6 +372,8 @@ struct Plugin
372 char * key; 372 char * key;
373 373
374 char * crypto_init; 374 char * crypto_init;
375
376 void * mhd_log;
375}; 377};
376 378
377 379
@@ -647,6 +649,13 @@ process_interfaces (void *cls,
647 return GNUNET_OK; 649 return GNUNET_OK;
648} 650}
649 651
652void mhd_logger (void * arg, const char * fmt, va_list ap)
653{
654 char text[1024];
655 vsnprintf(text, 1024, fmt, ap);
656 va_end(ap);
657 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,"MHD: %s \n", text);
658}
650 659
651/** 660/**
652 * Callback called by MHD when a connection is terminated 661 * Callback called by MHD when a connection is terminated
@@ -1301,12 +1310,10 @@ static size_t curl_send_cb(void *stream, size_t size, size_t nmemb, void *ptr)
1301 1310
1302 if ( msg->pos == msg->size) 1311 if ( msg->pos == msg->size)
1303 { 1312 {
1304#if DEBUG_CONNECTIONS
1305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Message with %u bytes sent, removing message from queue \n",ps, msg->pos); 1313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: Message with %u bytes sent, removing message from queue \n",ps, msg->pos);
1306#endif
1307 /* Calling transmit continuation */ 1314 /* Calling transmit continuation */
1308 if (NULL != ps->pending_msgs_tail->transmit_cont) 1315 if (NULL != msg->transmit_cont)
1309 msg->transmit_cont (ps->pending_msgs_tail->transmit_cont_cls,&(ps->peercontext)->identity,GNUNET_OK); 1316 msg->transmit_cont (msg->transmit_cont_cls,&(ps->peercontext)->identity,GNUNET_OK);
1310 remove_http_message(ps, msg); 1317 remove_http_message(ps, msg);
1311 } 1318 }
1312 return bytes_sent; 1319 return bytes_sent;
@@ -2606,9 +2613,10 @@ libgnunet_plugin_transport_https_init (void *cls)
2606 { 2613 {
2607 struct sockaddr * tmp = (struct sockaddr *) plugin->bind6_address; 2614 struct sockaddr * tmp = (struct sockaddr *) plugin->bind6_address;
2608 plugin->http_server_daemon_v6 = MHD_start_daemon ( 2615 plugin->http_server_daemon_v6 = MHD_start_daemon (
2609#if DEBUG_CONNECTIONS 2616
2610 MHD_USE_DEBUG | 2617 MHD_USE_DEBUG |
2611#endif 2618#if DEBUG_CONNECTIONS
2619 #endif
2612 MHD_USE_IPv6 | MHD_USE_SSL, 2620 MHD_USE_IPv6 | MHD_USE_SSL,
2613 port, 2621 port,
2614 &mhd_accept_cb, 2622 &mhd_accept_cb,
@@ -2626,13 +2634,15 @@ libgnunet_plugin_transport_https_init (void *cls)
2626 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout, 2634 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout,
2627 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024), 2635 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
2628 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL, 2636 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL,
2637 MHD_OPTION_EXTERNAL_LOGGER, mhd_logger, plugin->mhd_log,
2629 MHD_OPTION_END); 2638 MHD_OPTION_END);
2630 } 2639 }
2631 if ((plugin->http_server_daemon_v4 == NULL) && (plugin->use_ipv4 == GNUNET_YES) && (port != 0)) 2640 if ((plugin->http_server_daemon_v4 == NULL) && (plugin->use_ipv4 == GNUNET_YES) && (port != 0))
2632 { 2641 {
2633 plugin->http_server_daemon_v4 = MHD_start_daemon ( 2642 plugin->http_server_daemon_v4 = MHD_start_daemon (
2634#if DEBUG_CONNECTIONS 2643
2635 MHD_USE_DEBUG | 2644 MHD_USE_DEBUG |
2645#if DEBUG_CONNECTIONS
2636#endif 2646#endif
2637 MHD_NO_FLAG | MHD_USE_SSL, 2647 MHD_NO_FLAG | MHD_USE_SSL,
2638 port, 2648 port,
@@ -2651,6 +2661,7 @@ libgnunet_plugin_transport_https_init (void *cls)
2651 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout, 2661 MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) timeout,
2652 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024), 2662 MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) (16 * 1024),
2653 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL, 2663 MHD_OPTION_NOTIFY_COMPLETED, &mhd_termination_cb, NULL,
2664 MHD_OPTION_EXTERNAL_LOGGER, mhd_logger, plugin->mhd_log,
2654 MHD_OPTION_END); 2665 MHD_OPTION_END);
2655 } 2666 }
2656 if (plugin->http_server_daemon_v4 != NULL) 2667 if (plugin->http_server_daemon_v4 != NULL)