aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-04-27 13:14:57 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-04-27 13:14:57 +0000
commita689f1c66d2663ab1f3e6ec6347707612908d25c (patch)
treea89b351462ebcfef1829aa56005e999ecfc70f1b /src/transport
parent5ac41046becd09673549fb42f4b387ed847c507d (diff)
downloadgnunet-a689f1c66d2663ab1f3e6ec6347707612908d25c.tar.gz
gnunet-a689f1c66d2663ab1f3e6ec6347707612908d25c.zip
-stat counter for http
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/plugin_transport_http.c6
-rw-r--r--src/transport/plugin_transport_http.h15
-rw-r--r--src/transport/plugin_transport_http_client.c18
-rw-r--r--src/transport/plugin_transport_http_server.c29
4 files changed, 57 insertions, 11 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index fb06bd7f5..1078b541a 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -772,7 +772,7 @@ http_plugin_send (void *cls,
772 { 772 {
773#if DEBUG_HTTP 773#if DEBUG_HTTP
774 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 774 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
775 "Using outbound client session %p to send to `%session'\n", session, 775 "Using outbound client session %p to send to `%s'\n", session,
776 GNUNET_i2s (&session->target)); 776 GNUNET_i2s (&session->target));
777#endif 777#endif
778 778
@@ -783,7 +783,7 @@ http_plugin_send (void *cls,
783 { 783 {
784#if DEBUG_HTTP 784#if DEBUG_HTTP
785 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 785 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
786 "Using inbound server %p session to send to `%session'\n", session, 786 "Using inbound server %p session to send to `%s'\n", session,
787 GNUNET_i2s (&session->target)); 787 GNUNET_i2s (&session->target));
788#endif 788#endif
789 789
@@ -1477,6 +1477,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls)
1477 1477
1478 plugin = GNUNET_malloc (sizeof (struct Plugin)); 1478 plugin = GNUNET_malloc (sizeof (struct Plugin));
1479 plugin->env = env; 1479 plugin->env = env;
1480 plugin->outbound_sessions = 0;
1481 plugin->inbound_sessions = 0;
1480 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); 1482 api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
1481 api->cls = plugin; 1483 api->cls = plugin;
1482 api->disconnect = &http_plugin_disconnect; 1484 api->disconnect = &http_plugin_disconnect;
diff --git a/src/transport/plugin_transport_http.h b/src/transport/plugin_transport_http.h
index ab268e244..89fb86dd9 100644
--- a/src/transport/plugin_transport_http.h
+++ b/src/transport/plugin_transport_http.h
@@ -45,7 +45,7 @@
45#define DEBUG_HTTP GNUNET_EXTRA_LOGGING 45#define DEBUG_HTTP GNUNET_EXTRA_LOGGING
46#define VERBOSE_SERVER GNUNET_EXTRA_LOGGING 46#define VERBOSE_SERVER GNUNET_EXTRA_LOGGING
47#define VERBOSE_CLIENT GNUNET_EXTRA_LOGGING 47#define VERBOSE_CLIENT GNUNET_EXTRA_LOGGING
48#define VERBOSE_CURL GNUNET_EXTRA_LOGGING 48#define VERBOSE_CURL GNUNET_NO
49 49
50#if BUILD_HTTPS 50#if BUILD_HTTPS
51#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_https_init 51#define LIBGNUNET_PLUGIN_TRANSPORT_INIT libgnunet_plugin_transport_https_init
@@ -160,6 +160,16 @@ struct Plugin
160 int max_connections; 160 int max_connections;
161 161
162 /** 162 /**
163 * Number of outbound sessions
164 */
165 unsigned int outbound_sessions;
166
167 /**
168 * Number of inbound sessions
169 */
170 unsigned int inbound_sessions;
171
172 /**
163 * Plugin HTTPS SSL/TLS options 173 * Plugin HTTPS SSL/TLS options
164 * ---------------------------- 174 * ----------------------------
165 */ 175 */
@@ -453,6 +463,9 @@ struct HTTP_Message
453 void *transmit_cont_cls; 463 void *transmit_cont_cls;
454}; 464};
455 465
466int
467exist_session (struct Plugin *plugin, struct Session *s);
468
456void 469void
457delete_session (struct Session *s); 470delete_session (struct Session *s);
458 471
diff --git a/src/transport/plugin_transport_http_client.c b/src/transport/plugin_transport_http_client.c
index eefc98b2e..c64a594cd 100644
--- a/src/transport/plugin_transport_http_client.c
+++ b/src/transport/plugin_transport_http_client.c
@@ -264,11 +264,9 @@ client_disconnect (struct Session *s)
264 264
265 if (s->client_put != NULL) 265 if (s->client_put != NULL)
266 { 266 {
267#if DEBUG_HTTP
268 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 267 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
269 "Client: %X Deleting outbound PUT session to peer `%s'\n", 268 "Client: %X Deleting outbound PUT session to peer `%s'\n",
270 s->client_put, GNUNET_i2s (&s->target)); 269 s->client_put, GNUNET_i2s (&s->target));
271#endif
272 270
273 mret = curl_multi_remove_handle (plugin->client_mh, s->client_put); 271 mret = curl_multi_remove_handle (plugin->client_mh, s->client_put);
274 if (mret != CURLM_OK) 272 if (mret != CURLM_OK)
@@ -290,11 +288,9 @@ client_disconnect (struct Session *s)
290 288
291 if (s->client_get != NULL) 289 if (s->client_get != NULL)
292 { 290 {
293#if DEBUG_HTTP
294 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 291 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
295 "Client: %X Deleting outbound GET session to peer `%s'\n", 292 "Client: %X Deleting outbound GET session to peer `%s'\n",
296 s->client_get, GNUNET_i2s (&s->target)); 293 s->client_get, GNUNET_i2s (&s->target));
297#endif
298 294
299 mret = curl_multi_remove_handle (plugin->client_mh, s->client_get); 295 mret = curl_multi_remove_handle (plugin->client_mh, s->client_get);
300 if (mret != CURLM_OK) 296 if (mret != CURLM_OK)
@@ -319,6 +315,14 @@ client_disconnect (struct Session *s)
319 } 315 }
320 316
321 plugin->cur_connections -= 2; 317 plugin->cur_connections -= 2;
318
319 GNUNET_assert (plugin->outbound_sessions > 0);
320 plugin->outbound_sessions --;
321 GNUNET_STATISTICS_set (plugin->env->stats,
322 "# HTTP outbound sessions",
323 plugin->outbound_sessions,
324 GNUNET_NO);
325
322 /* Re-schedule since handles have changed */ 326 /* Re-schedule since handles have changed */
323 if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK) 327 if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK)
324 { 328 {
@@ -634,6 +638,12 @@ client_connect (struct Session *s)
634 /* Perform connect */ 638 /* Perform connect */
635 plugin->cur_connections += 2; 639 plugin->cur_connections += 2;
636 640
641 plugin->outbound_sessions ++;
642 GNUNET_STATISTICS_set (plugin->env->stats,
643 "# HTTP outbound sessions",
644 plugin->outbound_sessions,
645 GNUNET_NO);
646
637 /* Re-schedule since handles have changed */ 647 /* Re-schedule since handles have changed */
638 if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK) 648 if (plugin->client_perform_task != GNUNET_SCHEDULER_NO_TASK)
639 { 649 {
diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c
index 22196b218..1ce08435d 100644
--- a/src/transport/plugin_transport_http_server.c
+++ b/src/transport/plugin_transport_http_server.c
@@ -419,12 +419,12 @@ server_lookup_session (struct Plugin *plugin,
419 419
420 plugin->cur_connections++; 420 plugin->cur_connections++;
421 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 421 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
422 "Server: New inbound connection from %s with tag %u\n", 422 "Server: New %s connection from %s with tag %u\n",
423 method,
423 GNUNET_i2s (&target), tag); 424 GNUNET_i2s (&target), tag);
424 /* find duplicate session */
425 425
426 /* find duplicate session */
426 t = plugin->head; 427 t = plugin->head;
427
428 while (t != NULL) 428 while (t != NULL)
429 { 429 {
430 if ((t->inbound) && 430 if ((t->inbound) &&
@@ -480,6 +480,13 @@ server_lookup_session (struct Plugin *plugin,
480 "Server: Found matching semi-session, merging session for peer `%s'\n", 480 "Server: Found matching semi-session, merging session for peer `%s'\n",
481 GNUNET_i2s (&target)); 481 GNUNET_i2s (&target));
482 482
483 GNUNET_break (0);
484 plugin->inbound_sessions ++;
485 GNUNET_STATISTICS_set (plugin->env->stats,
486 "# HTTP inbound sessions",
487 plugin->inbound_sessions,
488 GNUNET_NO);
489
483 goto found; 490 goto found;
484 } 491 }
485 if ((direction == _RECEIVE) && (t->server_recv != NULL)) 492 if ((direction == _RECEIVE) && (t->server_recv != NULL))
@@ -498,6 +505,14 @@ server_lookup_session (struct Plugin *plugin,
498 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, 505 GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name,
499 "Server: Found matching semi-session, merging session for peer `%s'\n", 506 "Server: Found matching semi-session, merging session for peer `%s'\n",
500 GNUNET_i2s (&target)); 507 GNUNET_i2s (&target));
508
509 GNUNET_break (0);
510 plugin->inbound_sessions ++;
511 GNUNET_STATISTICS_set (plugin->env->stats,
512 "# HTTP inbound sessions",
513 plugin->inbound_sessions,
514 GNUNET_NO);
515
501 goto found; 516 goto found;
502 } 517 }
503 518
@@ -741,7 +756,7 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
741 struct Session *s = NULL; 756 struct Session *s = NULL;
742 struct Session *t = NULL; 757 struct Session *t = NULL;
743 struct Plugin *plugin = NULL; 758 struct Plugin *plugin = NULL;
744 759GNUNET_break (0);
745 if (sc == NULL) 760 if (sc == NULL)
746 return; 761 return;
747 762
@@ -829,6 +844,12 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
829 s->msg_tk = NULL; 844 s->msg_tk = NULL;
830 } 845 }
831 846
847 GNUNET_assert (plugin->inbound_sessions > 0);
848 plugin->inbound_sessions --;
849 GNUNET_STATISTICS_set (plugin->env->stats,
850 "# HTTP inbound sessions",
851 plugin->inbound_sessions, GNUNET_NO);
852
832 notify_session_end (s->plugin, &s->target, s); 853 notify_session_end (s->plugin, &s->target, s);
833 } 854 }
834} 855}