[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4892 - GNUnet/src/applications/fs/module
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4892 - GNUnet/src/applications/fs/module |
Date: |
Fri, 1 Jun 2007 23:40:11 -0600 (MDT) |
Author: grothoff
Date: 2007-06-01 23:40:11 -0600 (Fri, 01 Jun 2007)
New Revision: 4892
Modified:
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/fs/module/querymanager.c
Log:
more statistics, extra early check for expired content -- avoid routing content
that is already expired
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2007-06-02 05:39:06 UTC (rev
4891)
+++ GNUnet/src/applications/fs/module/fs.c 2007-06-02 05:40:11 UTC (rev
4892)
@@ -34,6 +34,7 @@
#include "gnunet_dht_service.h"
#include "gnunet_datastore_service.h"
#include "gnunet_traffic_service.h"
+#include "gnunet_stats_service.h"
#include "anonymity.h"
#include "dht_push.h"
#include "ecrs_core.h"
@@ -81,6 +82,15 @@
*/
static Traffic_ServiceAPI * traffic;
+/**
+ * Stats service.
+ */
+static Stats_ServiceAPI * stats;
+
+static int stat_expired_replies_dropped;
+
+static int stat_valid_replies_received;
+
static struct MUTEX * lock;
static int migration;
@@ -181,6 +191,8 @@
FREE(dv);
return SYSERR;
}
+ if (stats != NULL)
+ stats->change(stat_valid_replies_received, 1);
if (ntohll(dv->expirationTime) < get_time()) {
/* do not do anything with expired data
_except_ if it is pure content that one
@@ -188,6 +200,9 @@
should ignore expiration */
if (ntohl(dv->type) == D_BLOCK)
processResponse(query, dv);
+ else if (stats != NULL)
+ stats->change(stat_expired_replies_dropped, 1);
+
FREE(dv);
return NO;
}
@@ -695,6 +710,14 @@
"Converting reply for query `%s' for gap.\n",
&enc);
#endif
+ et = ntohll(value->expirationTime);
+ now = get_time();
+ if ( (et <= now) &&
+ (ntohl(value->type) != D_BLOCK) ) {
+ /* content expired and not just data -- drop! */
+ return OK;
+ }
+
if (ntohl(invalue->type) == ONDEMAND_BLOCK) {
if (OK != ONDEMAND_getIndexed(datastore,
invalue,
@@ -763,9 +786,7 @@
}
gw = MALLOC(size);
gw->dc.size = htonl(size);
- et = ntohll(value->expirationTime);
/* expiration time normalization and randomization */
- now = get_time();
if (et > now) {
et -= now;
et = et % MAX_MIGRATION_EXP;
@@ -1153,10 +1174,20 @@
return SYSERR;
}
traffic = capi->requestService("traffic");
+ stats = capi->requestService("stats");
+ if (stats != NULL) {
+ stat_expired_replies_dropped
+ = stats->create(gettext_noop("# FS expired replies dropped"));
+ stat_valid_replies_received
+ = stats->create(gettext_noop("# FS valid replies received"));
+ }
gap = capi->requestService("gap");
if (gap == NULL) {
GE_BREAK(ectx, 0);
capi->releaseService(datastore);
+ if (stats != NULL)
+ capi->releaseService(stats);
+ capi->releaseService(traffic);
return SYSERR;
}
dht = capi->requestService("dht");
@@ -1264,6 +1295,10 @@
&unused);
coreAPI->releaseService(datastore);
datastore = NULL;
+ if (stats != NULL) {
+ coreAPI->releaseService(stats);
+ stats = NULL;
+ }
coreAPI->releaseService(gap);
gap = NULL;
if (dht != NULL) {
Modified: GNUnet/src/applications/fs/module/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.c 2007-06-02 05:39:06 UTC
(rev 4891)
+++ GNUnet/src/applications/fs/module/querymanager.c 2007-06-02 05:40:11 UTC
(rev 4892)
@@ -25,11 +25,13 @@
*/
#include "platform.h"
+#include "gnunet_stats_service.h"
#include "gnunet_protocols.h"
#include "gnunet_core.h"
#include "fs.h"
#include "querymanager.h"
+
#define DEBUG_QUERYMANAGER NO
typedef struct {
@@ -38,7 +40,17 @@
struct ClientHandle * client;
} TrackRecord;
+
/**
+ * Stats service.
+ */
+static Stats_ServiceAPI * stats;
+
+static int stat_queries_tracked;
+
+static int stat_replies_transmitted;
+
+/**
* Array of the queries we are currently sending out.
*/
static TrackRecord ** trackers;
@@ -59,6 +71,8 @@
static void removeEntry(unsigned int off) {
GE_ASSERT(ectx, off < trackerCount);
FREE(trackers[off]);
+ if (stats != NULL)
+ stats->change(stat_queries_tracked, 1);
trackers[off] = trackers[--trackerCount];
trackers[trackerCount] = NULL;
if ( (trackerSize > 64) &&
@@ -85,17 +99,8 @@
void trackQuery(const HashCode512 * query,
unsigned int type,
struct ClientHandle * client) {
- int i;
-
GE_ASSERT(ectx, client != NULL);
MUTEX_LOCK(queryManagerLock);
- for (i=trackerCount-1;i>=0;i--)
- if ( (trackers[i]->client == client) &&
- (equalsHashCode512(&trackers[i]->query,
- query)) ) {
- MUTEX_UNLOCK(queryManagerLock);
- return;
- }
if (trackerSize == trackerCount)
GROW(trackers,
trackerSize,
@@ -105,6 +110,8 @@
trackers[trackerCount]->type = type;
trackers[trackerCount]->client = client;
trackerCount++;
+ if (stats != NULL)
+ stats->change(stat_queries_tracked, 1);
MUTEX_UNLOCK(queryManagerLock);
}
@@ -124,6 +131,8 @@
(equalsHashCode512(&trackers[i]->query,
query)) ) {
removeEntry(i);
+ if (stats != NULL)
+ stats->change(stat_queries_tracked, -1);
MUTEX_UNLOCK(queryManagerLock);
return;
}
@@ -182,6 +191,9 @@
&enc,
i);
#endif
+ if (stats != NULL)
+ stats->change(stat_replies_transmitted,
+ 1);
coreAPI->sendToClient(trackers[i]->client,
&rc->header);
FREE(rc);
@@ -209,11 +221,22 @@
trackerSize,
64);
queryManagerLock = MUTEX_CREATE(NO);
+ stats = capi->requestService("stats");
+ if (stats != NULL) {
+ stat_queries_tracked
+ = stats->create(gettext_noop("# FS currently tracked queries from
clients"));
+ stat_replies_transmitted
+ = stats->create(gettext_noop("# FS replies passed to clients"));
+ }
return OK;
}
void doneQueryManager() {
int i;
+ if (stats != NULL) {
+ coreAPI->releaseService(stats);
+ stats = NULL;
+ }
for (i=trackerCount-1;i>=0;i--)
FREE(trackers[i]);
GROW(trackers,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4892 - GNUnet/src/applications/fs/module,
gnunet <=