[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11202 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11202 - gnunet/src/transport |
Date: |
Wed, 5 May 2010 17:35:43 +0200 |
Author: wachs
Date: 2010-05-05 17:35:43 +0200 (Wed, 05 May 2010)
New Revision: 11202
Modified:
gnunet/src/transport/plugin_transport_http.c
gnunet/src/transport/test_plugin_transport_data_http.conf
gnunet/src/transport/test_plugin_transport_http.c
Log:
Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c 2010-05-05 13:54:52 UTC
(rev 11201)
+++ gnunet/src/transport/plugin_transport_http.c 2010-05-05 15:35:43 UTC
(rev 11202)
@@ -142,22 +142,22 @@
static struct Plugin *plugin;
/**
- * Daemon for listening for new connections.
+ * Daemon for listening for new IPv4 connections.
*/
static struct MHD_Daemon *http_daemon_v4;
/**
- * Daemon for listening for new connections.
+ * Daemon for listening for new IPv6connections.
*/
static struct MHD_Daemon *http_daemon_v6;
/**
- * Our primary task for http
+ * Our primary task for http daemon handling IPv4 connections
*/
static GNUNET_SCHEDULER_TaskIdentifier http_task_v4;
/**
- * Our primary task for http
+ * Our primary task for http daemon handling IPv6 connections
*/
static GNUNET_SCHEDULER_TaskIdentifier http_task_v6;
@@ -324,13 +324,12 @@
{
/* PUT method here */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Got PUT Request with size %u
\n",upload_data_size);
-
- // GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# PUT
requests"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# PUT
requests"), 1, GNUNET_NO);
}
if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Got GET Request with size\n");
- // GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# GET
requests"), 1, GNUNET_NO);
+ GNUNET_STATISTICS_update( plugin->env->stats , gettext_noop("# GET
requests"), 1, GNUNET_NO);
}
response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE),
@@ -368,7 +367,8 @@
GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
if (daemon_handle == http_daemon_v4)
http_task_v4 = prepare_daemon (daemon_handle);
-
+ if (daemon_handle == http_daemon_v6)
+ http_task_v6 = prepare_daemon (daemon_handle);
}
/**
@@ -463,7 +463,6 @@
curl_multi_cleanup (curl_multi);
curl_multi = NULL;
}
- /* GNUNET_SERVICE_stop (plugin->service); */
GNUNET_free (plugin);
GNUNET_free (api);
return NULL;
@@ -478,7 +477,6 @@
struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
struct GNUNET_TRANSPORT_PluginFunctions *api;
long long unsigned int port;
- /* struct GNUNET_SERVICE_Context *service; */
plugin = GNUNET_malloc (sizeof (struct Plugin));
plugin->env = env;
@@ -490,18 +488,7 @@
api->address_pretty_printer = &http_plugin_address_pretty_printer;
api->check_address = &http_plugin_address_suggested;
- /*
- service = GNUNET_SERVICE_start ("transport-http", env->sched, env->cfg);
- if (service == NULL)
- {
- GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG,
- "http",
- _("Failed to start service for `%s' transport
plugin.\n"),
- "http");
- return NULL;
- }
- plugin->service = service;
- */
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting http plugin...\n");
/* Reading port number from config file */
if ((GNUNET_OK !=
@@ -521,7 +508,6 @@
}
if ((http_daemon_v4 == NULL) && (http_daemon_v6 == NULL) && (port != 0))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD on port %u with IPv6
disabled\n",port);
http_daemon_v4 = MHD_start_daemon (MHD_NO_FLAG,
port,
&acceptPolicyCallback,
@@ -531,7 +517,6 @@
MHD_OPTION_CONNECTION_TIMEOUT, (unsigned
int) 16,
MHD_OPTION_CONNECTION_MEMORY_LIMIT,
(size_t) (16 * 1024),
MHD_OPTION_END);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD on port %u with IPv6
enabled\n",port);
http_daemon_v6 = MHD_start_daemon (MHD_USE_IPv6,
port,
&acceptPolicyCallback,
@@ -543,6 +528,14 @@
MHD_OPTION_END);
}
+
+ if ((http_daemon_v4 != NULL) && (http_daemon_v6 != NULL))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD on port %u with IPv4 and
IPv6 enabled\n",port);
+ if ((http_daemon_v4 != NULL) && (http_daemon_v6 == NULL))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD on port %u with IPv4
enabled\n",port);
+ if ((http_daemon_v4 == NULL) && (http_daemon_v6 != NULL))
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD on port %u with IPv6
enabled\n",port);
+
curl_multi = curl_multi_init ();
if (http_daemon_v4 != NULL)
@@ -550,14 +543,13 @@
if (http_daemon_v6 != NULL)
http_task_v6 = prepare_daemon (http_daemon_v6);
- /*
if (NULL == plugin->env->stats)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to retrieve statistics handle\n"));
libgnunet_plugin_transport_http_done (api);
return NULL;
- }*/
+ }
GNUNET_STATISTICS_set ( env->stats, "# PUT requests", 0, GNUNET_NO);
GNUNET_STATISTICS_set ( env->stats, "# GET requests", 0, GNUNET_NO);
Modified: gnunet/src/transport/test_plugin_transport_data_http.conf
===================================================================
--- gnunet/src/transport/test_plugin_transport_data_http.conf 2010-05-05
13:54:52 UTC (rev 11201)
+++ gnunet/src/transport/test_plugin_transport_data_http.conf 2010-05-05
15:35:43 UTC (rev 11202)
@@ -1,7 +1,28 @@
[PATHS]
-DEFAULTCONFIG = test_transport_api_tcp_peer1.conf
+DEFAULTCONFIG = test_plugin_transport_data_http.conf
SERVICEHOME = /tmp/test-gnunetd-transport-peer-1/
[transport-http]
PORT = 12389
-DEBUG = YES
\ No newline at end of file
+DEBUG = YES
+
+[statistics]
+ALLOW_SHUTDOWN = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-statistics
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 12367
+
+[arm]
+DEFAULTSERVICES = resolver transport core statistics topology hostlist
+ALLOW_SHUTDOWN = YES
+ACCEPT_FROM6 = ::1;
+ACCEPT_FROM = 127.0.0.1;
+BINARY = gnunet-service-arm
+CONFIG = $DEFAULTCONFIG
+HOME = $SERVICEHOME
+HOSTNAME = localhost
+PORT = 12366
\ No newline at end of file
Modified: gnunet/src/transport/test_plugin_transport_http.c
===================================================================
--- gnunet/src/transport/test_plugin_transport_http.c 2010-05-05 13:54:52 UTC
(rev 11201)
+++ gnunet/src/transport/test_plugin_transport_http.c 2010-05-05 15:35:43 UTC
(rev 11202)
@@ -33,6 +33,7 @@
#include "gnunet_protocols.h"
#include "gnunet_program_lib.h"
#include "gnunet_signatures.h"
+#include "gnunet_service_lib.h"
#include "plugin_transport.h"
#include "gnunet_statistics_service.h"
#include "transport.h"
@@ -84,13 +85,15 @@
/**
* Environment for this plugin.
*/
-struct GNUNET_TRANSPORT_PluginEnvironment env;
+static struct GNUNET_TRANSPORT_PluginEnvironment env;
/**
*handle for the api provided by this plugin
*/
-struct GNUNET_TRANSPORT_PluginFunctions *api;
+static struct GNUNET_TRANSPORT_PluginFunctions *api;
+static struct GNUNET_SERVICE_Context *service;
+
/**
* Did the test pass or fail?
*/
@@ -98,6 +101,8 @@
static GNUNET_SCHEDULER_TaskIdentifier timeout_task;
+pid_t pid;
+
/**
* Initialize Environment for this plugin
*/
@@ -152,6 +157,12 @@
{
if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel( sched, timeout_task );
+ if (NULL != service) GNUNET_SERVICE_stop (service);
+ if (0 != PLIBC_KILL (pid, SIGTERM))
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ fail = 1;
+ }
unload_plugins(env.cls, env.cfg);
}
@@ -184,6 +195,20 @@
env.max_connections = max_connect_per_transport;
}
+static int
+process_stat (void *cls,
+ const char *subsystem,
+ const char *name,
+ uint64_t value,
+ int is_persistent)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Value: %llums\n"),
+ (unsigned long long) value);
+ return GNUNET_OK;
+}
+
+
/**
* Runs the test.
*
@@ -222,9 +247,32 @@
return;
}
+ pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ "gnunet-service-statistics",
+ "-L", "DEBUG",
+ "-c", "test_plugin_transport_data_http.conf",
NULL);
- // stats = GNUNET_STATISTICS_create (sched, "http-transport", cfg);
+ if ( pid == -1)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Failed to start service for `%s' http transport plugin
test.\n"),
+ "statistics");
+ return;
+ }
+
+
+
+ stats = GNUNET_STATISTICS_create (sched, "http-transport", cfg);
+ env.stats = stats;
+
+ GNUNET_STATISTICS_get (stats,
+ "http-transport",
+ gettext_noop("# PUT requests"),
+ GNUNET_TIME_UNIT_MINUTES,
+ NULL,
+ &process_stat,
+ NULL);
/*
max_connect_per_transport = (uint32_t) tneigh;
my_private_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11202 - gnunet/src/transport,
gnunet <=