From: Sree Harsha Totakura Date: Sun, 18 Nov 2012 19:54:17 +0000 (+0000) Subject: use statistics X-Git-Tag: initial-import-from-subversion-38251~10778 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ff62b90718f62a2cf806da81c1b9602e97d18457;p=oweals%2Fgnunet.git use statistics --- diff --git a/src/stream/Makefile.am b/src/stream/Makefile.am index 8a5e141ab..16c4f78b2 100644 --- a/src/stream/Makefile.am +++ b/src/stream/Makefile.am @@ -16,6 +16,7 @@ libgnunetstream_la_SOURCES = \ libgnunetstream_la_LIBADD = \ $(top_builddir)/src/mesh/libgnunetmesh.la \ $(top_builddir)/src/lockmanager/libgnunetlockmanager.la \ + $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/util/libgnunetutil.la $(XLIB) libgnunetstream_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) \ diff --git a/src/stream/stream_api.c b/src/stream/stream_api.c index 1aec60285..05d09aced 100644 --- a/src/stream/stream_api.c +++ b/src/stream/stream_api.c @@ -39,6 +39,7 @@ #include "gnunet_common.h" #include "gnunet_crypto_lib.h" #include "gnunet_lockmanager_service.h" +#include "gnunet_statistics_service.h" #include "gnunet_stream_lib.h" #include "stream_protocol.h" @@ -175,29 +176,14 @@ struct MessageQueue struct GNUNET_STREAM_Socket { /** - * Retransmission timeout - */ - struct GNUNET_TIME_Relative retransmit_timeout; - - /** - * The Acknowledgement Bitmap - */ - GNUNET_STREAM_AckBitmap ack_bitmap; - - /** - * Time when the Acknowledgement was queued - */ - struct GNUNET_TIME_Absolute ack_time_registered; - - /** - * Queued Acknowledgement deadline + * The mesh handle */ - struct GNUNET_TIME_Relative ack_time_deadline; + struct GNUNET_MESH_Handle *mesh; /** - * The mesh handle + * Handle to statistics */ - struct GNUNET_MESH_Handle *mesh; + struct GNUNET_STATISTICS_Handle *stat_handle; /** * The mesh tunnel handle @@ -260,6 +246,11 @@ struct GNUNET_STREAM_Socket */ struct GNUNET_PeerIdentity other_peer; + /** + * The Acknowledgement Bitmap + */ + GNUNET_STREAM_AckBitmap ack_bitmap; + /** * Task identifier for retransmission task after timeout */ @@ -275,6 +266,21 @@ struct GNUNET_STREAM_Socket */ GNUNET_SCHEDULER_TaskIdentifier ack_task_id; + /** + * Retransmission timeout + */ + struct GNUNET_TIME_Relative retransmit_timeout; + + /** + * Time when the Acknowledgement was queued + */ + struct GNUNET_TIME_Absolute ack_time_registered; + + /** + * Queued Acknowledgement deadline + */ + struct GNUNET_TIME_Relative ack_time_deadline; + /** * The state of the protocol associated with this socket */ @@ -291,14 +297,14 @@ struct GNUNET_STREAM_Socket unsigned int retries; /** - * The application port number (type: uint32_t) + * Whether testing mode is active or not */ - GNUNET_MESH_ApplicationType app_port; + int testing_active; /** - * Whether testing mode is active or not + * The application port number (type: uint32_t) */ - int testing_active; + GNUNET_MESH_ApplicationType app_port; /** * The write sequence number to be set incase of testing @@ -363,6 +369,11 @@ struct GNUNET_STREAM_ListenSocket */ struct GNUNET_MESH_Handle *mesh; + /** + * Handle to statistics + */ + struct GNUNET_STATISTICS_Handle *stat_handle; + /** * Our configuration */ @@ -2738,6 +2749,7 @@ new_tunnel_notify (void *cls, socket->tunnel = tunnel; socket->state = STATE_INIT; socket->lsocket = lsocket; + socket->stat_handle = lsocket->stat_handle; socket->retransmit_timeout = lsocket->retransmit_timeout; socket->testing_active = lsocket->testing_active; socket->testing_set_write_sequence_number_value = @@ -2747,6 +2759,15 @@ new_tunnel_notify (void *cls, "%s: Peer %s initiated tunnel to us\n", GNUNET_i2s (&socket->other_peer), GNUNET_i2s (&socket->other_peer)); + if (NULL != socket->stat_handle) + { + GNUNET_STATISTICS_update (socket->stat_handle, + "total inbound connections received", + 1, GNUNET_NO); + GNUNET_STATISTICS_update (socket->stat_handle, + "inbound connections", 1, GNUNET_NO); + } + return socket; } @@ -2777,6 +2798,13 @@ tunnel_cleaner (void *cls, "%s: Peer %s has terminated connection abruptly\n", GNUNET_i2s (&socket->other_peer), GNUNET_i2s (&socket->other_peer)); + if (NULL != socket->stat_handle) + { + GNUNET_STATISTICS_update (socket->stat_handle, + "connections terminated abruptly", 1, GNUNET_NO); + GNUNET_STATISTICS_update (socket->stat_handle, + "inbound connections", -1, GNUNET_NO); + } socket->status = GNUNET_STREAM_SHUTDOWN; /* Clear Transmit handles */ if (NULL != socket->transmit_handle) @@ -2983,6 +3011,7 @@ GNUNET_STREAM_open (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_assert (NULL != socket->tunnel); GNUNET_MESH_peer_request_connect_add (socket->tunnel, &socket->other_peer); + socket->stat_handle = GNUNET_STATISTICS_create ("stream", cfg); LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__); return socket; } @@ -3138,11 +3167,14 @@ GNUNET_STREAM_close (struct GNUNET_STREAM_Socket *socket) socket->tunnel = NULL; } /* Close mesh connection */ - if (NULL != socket->mesh && NULL == socket->lsocket) + if ((NULL != socket->mesh) && (NULL == socket->lsocket)) { GNUNET_MESH_disconnect (socket->mesh); socket->mesh = NULL; - } + } + /* Close statistics connection */ + if ( (NULL != socket->stat_handle) && (NULL == socket->lsocket) ) + GNUNET_STATISTICS_destroy (socket->stat_handle, GNUNET_YES); /* Release receive buffer */ if (NULL != socket->receive_buffer) { @@ -3170,7 +3202,6 @@ GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, void *listen_cb_cls, ...) { - /* FIXME: Add variable args for passing configration options? */ struct GNUNET_STREAM_ListenSocket *lsocket; struct GNUNET_TIME_Relative listen_timeout; enum GNUNET_STREAM_Option option; @@ -3237,6 +3268,8 @@ GNUNET_STREAM_listen (const struct GNUNET_CONFIGURATION_Handle *cfg, lsocket->lockmanager_acquire_timeout_task = GNUNET_SCHEDULER_add_delayed (listen_timeout, &lockmanager_acquire_timeout, lsocket); + lsocket->stat_handle = GNUNET_STATISTICS_create ("stream", + lsocket->cfg); return lsocket; } @@ -3252,6 +3285,8 @@ GNUNET_STREAM_listen_close (struct GNUNET_STREAM_ListenSocket *lsocket) /* Close MESH connection */ if (NULL != lsocket->mesh) GNUNET_MESH_disconnect (lsocket->mesh); + if (NULL != lsocket->stat_handle) + GNUNET_STATISTICS_destroy (lsocket->stat_handle, GNUNET_YES); GNUNET_CONFIGURATION_destroy (lsocket->cfg); if (GNUNET_SCHEDULER_NO_TASK != lsocket->lockmanager_acquire_timeout_task) GNUNET_SCHEDULER_cancel (lsocket->lockmanager_acquire_timeout_task); diff --git a/src/stream/test_stream_local.conf b/src/stream/test_stream_local.conf index 5a517cb3f..d0daffaec 100644 --- a/src/stream/test_stream_local.conf +++ b/src/stream/test_stream_local.conf @@ -4,6 +4,11 @@ ACCEPT_FROM = 127.0.0.1; HOSTNAME = localhost PORT = 12101 +[statistics] +AUTOSTART = YES +ACCEPT_FROM = 127.0.0.1; +PORT = 12102 + [fs] AUTOSTART = NO