[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4072 - in GNUnet/src: applications/dht/module applications
From: |
grothoff |
Subject: |
[GNUnet-SVN] r4072 - in GNUnet/src: applications/dht/module applications/dht/tools applications/dstore applications/fs/module applications/session applications/topology_default server transports util/boot |
Date: |
Wed, 27 Dec 2006 00:02:39 -0800 (PST) |
Author: grothoff
Date: 2006-12-27 00:02:31 -0800 (Wed, 27 Dec 2006)
New Revision: 4072
Modified:
GNUnet/src/applications/dht/module/cs.c
GNUnet/src/applications/dht/module/dstore.c
GNUnet/src/applications/dht/module/routing.c
GNUnet/src/applications/dht/module/routing.h
GNUnet/src/applications/dht/tools/dht-query.c
GNUnet/src/applications/dht/tools/dht_api.c
GNUnet/src/applications/dstore/dstore.c
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/session/connect.c
GNUnet/src/applications/topology_default/topology.c
GNUnet/src/server/connection.c
GNUnet/src/server/tcpserver.c
GNUnet/src/transports/tcp.c
GNUnet/src/util/boot/startup.c
Log:
commenting debug statements, fixing DHT bugs
Modified: GNUnet/src/applications/dht/module/cs.c
===================================================================
--- GNUnet/src/applications/dht/module/cs.c 2006-12-27 07:10:25 UTC (rev
4071)
+++ GNUnet/src/applications/dht/module/cs.c 2006-12-27 08:02:31 UTC (rev
4072)
@@ -33,7 +33,7 @@
#include "dht.h"
#include "gnunet_dht_service.h"
-#define DEBUG_CS YES
+#define DEBUG_CS NO
/**
* Global core API.
@@ -92,12 +92,12 @@
dhtAPI->put(&req->key,
ntohl(req->type),
size,
- ntohll(req->expire),
+ ntohll(req->expire) + get_time(), /* convert to absolute time */
(const char*) &req[1]);
return OK;
}
-static int get_result(const HashCode512 * key,
+ int get_result(const HashCode512 * key,
const DataContainer * value,
void * cls) {
DHT_CLIENT_GET_RECORD * record = cls;
@@ -227,8 +227,8 @@
coreAPI = capi;
GE_LOG(coreAPI->ectx,
GE_DEBUG | GE_REQUEST | GE_USER,
- "DHT registering client handlers: "
- "%d %d %d %d\n",
+ _("`%s' registering client handlers: %d %d\n"),
+ "dht",
CS_PROTO_dht_REQUEST_PUT,
CS_PROTO_dht_REQUEST_GET);
status = OK;
Modified: GNUnet/src/applications/dht/module/dstore.c
===================================================================
--- GNUnet/src/applications/dht/module/dstore.c 2006-12-27 07:10:25 UTC (rev
4071)
+++ GNUnet/src/applications/dht/module/dstore.c 2006-12-27 08:02:31 UTC (rev
4072)
@@ -28,6 +28,8 @@
#include "dstore.h"
#include "gnunet_blockstore.h"
+#define DEBUG_DSTORE NO
+
static Dstore_ServiceAPI * dstore;
static CoreAPIForApplication * coreAPI;
@@ -54,8 +56,16 @@
cron_t discard_time,
unsigned int size,
const char * data) {
- if (discard_time < get_time())
+ if (discard_time < get_time()) {
+#if DEBUG_DSTORE
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Content already expired (%llu < %llu), will not keep.\n",
+ discard_time,
+ get_time());
+#endif
return;
+ }
dstore->put(key,
type,
discard_time,
Modified: GNUnet/src/applications/dht/module/routing.c
===================================================================
--- GNUnet/src/applications/dht/module/routing.c 2006-12-27 07:10:25 UTC
(rev 4071)
+++ GNUnet/src/applications/dht/module/routing.c 2006-12-27 08:02:31 UTC
(rev 4072)
@@ -42,6 +42,8 @@
#include "gnunet_protocols.h"
#include "gnunet_stats_service.h"
+#define DEBUG_ROUTING NO
+
/**
* @brief record used for sending response back
*/
@@ -204,6 +206,8 @@
int found;
HashCode512 hc;
DHT_RESULT_MESSAGE * result;
+ unsigned int routed;
+ unsigned int tracked;
if (cls != NULL) {
result = cls;
@@ -220,11 +224,14 @@
hash(data,
size,
&hc);
+ routed = 0;
+ tracked = 0;
MUTEX_LOCK(lock);
for (i=0;i<rt_size;i++) {
q = records[i];
if (q == NULL)
continue;
+ tracked++;
if ( (ntohl(q->get->type) != type) ||
(0 != memcmp(key,
&q->get->key,
@@ -243,10 +250,16 @@
GROW(q->results,
q->result_count,
q->result_count + 1);
+ routed++;
q->results[q->result_count-1] = hc;
if (0 != memcmp(&q->source.source,
coreAPI->myIdentity,
sizeof(PeerIdentity))) {
+#if DEBUG_ROUTING
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Routing result to other peer\n");
+#endif
coreAPI->unicast(&q->source.source,
&result->header,
0, /* FIXME: priority */
@@ -254,6 +267,11 @@
if (stats != NULL)
stats->change(stat_replies_routed, 1);
} else if (q->source.receiver != NULL) {
+#if DEBUG_ROUTING
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Routing result to local client\n");
+#endif
q->source.receiver(key,
type,
size,
@@ -263,7 +281,14 @@
stats->change(stat_replies_routed, 1);
}
}
- MUTEX_UNLOCK(lock);
+ MUTEX_UNLOCK(lock);
+#if DEBUG_ROUTING
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Routed result to %u out of %u pending requests\n",
+ routed,
+ tracked);
+#endif
if (cls == NULL)
FREE(result);
}
@@ -297,6 +322,12 @@
q->source.source = *coreAPI->myIdentity;
q->source.receiver = handler;
q->source.receiver_closure = cls;
+#if DEBUG_ROUTING
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Tracking request in slot %u\n",
+ rt_pos);
+#endif
rt_pos = (rt_pos + 1) % rt_size;
MUTEX_UNLOCK(lock);
if (stats != NULL)
@@ -330,8 +361,16 @@
ntohl(get->type),
&routeResult,
NULL);
- if (total > 0)
+ if ( (total > GET_TRIES) &&
+ (sender != NULL) ) {
+#if DEBUG_ROUTING
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Found %d results locally, will not route GET any further\n",
+ total);
+#endif
return OK;
+ }
routed = 0;
for (i=0;i<GET_TRIES;i++) {
if (OK != select_dht_peer(&next[i],
@@ -373,6 +412,7 @@
const MESSAGE_HEADER * msg) {
PeerIdentity next[PUT_TRIES];
const DHT_PUT_MESSAGE * put;
+ cron_t now;
int store;
int i;
@@ -400,12 +440,31 @@
0, /* FIXME: priority */
5 * cronSECONDS); /* FIXME */
}
- if (store != 0)
+ if (store != 0) {
+ now = get_time();
+#if DEBUG_ROUTING
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Decided to cache data `%.*s' locally until %llu (for %llu ms)\n",
+ ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
+ &put[1],
+ ntohll(put->timeout) + now,
+ ntohll(put->timeout));
+#endif
dht_store_put(ntohl(put->type),
&put->key,
- ntohll(put->timeout) + get_time(),
+ ntohll(put->timeout) + now,
ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
(const char*) &put[1]);
+ } else {
+#if DEBUG_ROUTING
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "Decided NOT to cache data `%.*s' locally\n",
+ ntohs(put->header.size) - sizeof(DHT_PUT_MESSAGE),
+ &put[1]);
+#endif
+ }
return OK;
}
@@ -444,6 +503,10 @@
get.prio = htonl(0); /* FIXME */
get.reserved = htonl(0);
get.key = *key;
+ addRoute(NULL,
+ handler,
+ cls,
+ &get);
handleGet(NULL,
&get.header);
}
@@ -497,7 +560,7 @@
put->header.type = htons(P2P_PROTO_DHT_PUT);
put->key = *key;
put->type = htonl(type);
- put->timeout = htonll(expirationTime - get_time());
+ put->timeout = htonll(expirationTime - get_time()); /* convert to relative
time */
memcpy(&put[1],
data,
size);
@@ -523,6 +586,13 @@
stat_replies_routed = stats->create(gettext_noop("# dht replies routed"));
stat_requests_routed = stats->create(gettext_noop("# dht requests
routed"));
}
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ _("`%s' registering p2p handlers: %d %d %d\n"),
+ "dht",
+ P2P_PROTO_DHT_GET,
+ P2P_PROTO_DHT_PUT,
+ P2P_PROTO_DHT_RESULT);
coreAPI->registerHandler(P2P_PROTO_DHT_GET,
&handleGet);
coreAPI->registerHandler(P2P_PROTO_DHT_PUT,
Modified: GNUnet/src/applications/dht/module/routing.h
===================================================================
--- GNUnet/src/applications/dht/module/routing.h 2006-12-27 07:10:25 UTC
(rev 4071)
+++ GNUnet/src/applications/dht/module/routing.h 2006-12-27 08:02:31 UTC
(rev 4072)
@@ -31,6 +31,7 @@
#include "gnunet_core.h"
#include "dstore.h"
+
/**
* Start a DHT get operation.
*/
Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c 2006-12-27 07:10:25 UTC
(rev 4071)
+++ GNUnet/src/applications/dht/tools/dht-query.c 2006-12-27 08:02:31 UTC
(rev 4072)
@@ -112,7 +112,9 @@
+ strlen(value));
dc->size = htonl(strlen(value)
+ sizeof(DataContainer));
- memcpy(&dc[1], value, strlen(value));
+ memcpy(&dc[1],
+ value,
+ strlen(value));
GE_LOG(ectx,
GE_DEBUG | GE_REQUEST | GE_USER,
_("Issuing '%s(%s,%s)' command.\n"),
@@ -125,7 +127,7 @@
ectx,
&hc,
DHT_STRING2STRING_BLOCK,
- timeout,
+ timeout + get_time(), /* convert to absolute time */
dc)) {
printf(_("'%s(%s,%s)' succeeded\n"),
"put",
Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2006-12-27 07:10:25 UTC (rev
4071)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2006-12-27 08:02:31 UTC (rev
4072)
@@ -196,10 +196,9 @@
*
* @param table table to use for the lookup
* @param key the key to store
- * @param timeout how long to wait until this operation should
- * automatically time-out
+ * @param expire how long until the content should expire (absolute time)
* @param value what to store
- * @return OK on success, SYSERR on error (or timeout)
+ * @return OK on success, SYSERR on error
*/
int DHT_LIB_put(struct GC_Configuration * cfg,
struct GE_Context * ectx,
@@ -210,7 +209,13 @@
struct ClientServerConnection * sock;
CS_dht_request_put_MESSAGE * req;
int ret;
+ cron_t now;
+ now = get_time();
+ if (expire < now) {
+ GE_BREAK(ectx, 0); /* content already expired!? */
+ return SYSERR;
+ }
GE_LOG(ectx,
GE_DEBUG | GE_REQUEST | GE_USER,
"DHT_LIB_put called with value '%.*s'\n",
@@ -233,7 +238,7 @@
= htons(CS_PROTO_dht_REQUEST_PUT);
req->key = *key;
req->type = htonl(type);
- req->expire = htonll(expire);
+ req->expire = htonll(expire - now); /* convert to relative time */
memcpy(&req[1],
&value[1],
ntohl(value->size) - sizeof(DataContainer));
Modified: GNUnet/src/applications/dstore/dstore.c
===================================================================
--- GNUnet/src/applications/dstore/dstore.c 2006-12-27 07:10:25 UTC (rev
4071)
+++ GNUnet/src/applications/dstore/dstore.c 2006-12-27 08:02:31 UTC (rev
4072)
@@ -35,6 +35,8 @@
#include "gnunet_dstore_service.h"
#include <sqlite3.h>
+#define DEBUG_DSTORE NO
+
/**
* Maximum size for an individual item.
*/
@@ -151,6 +153,13 @@
MUTEX_UNLOCK(lock);
return SYSERR;
}
+#if DEBUG_DSTORE
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "dstore processes put `%.*s\n",
+ size,
+ data);
+#endif
db_init(dbh);
if (sq_prepare(dbh,
"INSERT INTO ds071 "
@@ -189,6 +198,11 @@
dstmt = NULL;
payload += size;
if (payload > quota) {
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "DStore above qutoa (have %llu, allowed %llu), will delete some
data.\n",
+ payload,
+ quota);
if ( (sq_prepare(dbh,
"SELECT size, type, puttime, expire, key, value FROM ds071
ORDER BY puttime ASC",
&stmt) == SQLITE_OK) &&
@@ -206,7 +220,6 @@
dcontent = MALLOC(MAX_CONTENT_SIZE);
while ( (payload > quota) &&
(sqlite3_step(stmt) == SQLITE_ROW) ) {
- sqlite3_reset(stmt);
dsize = sqlite3_column_int(stmt, 0);
dtype = sqlite3_column_int(stmt, 1);
dputtime = sqlite3_column_int64(stmt, 2);
@@ -298,6 +311,11 @@
MUTEX_UNLOCK(lock);
return SYSERR;
}
+#if DEBUG_DSTORE
+ GE_LOG(coreAPI->ectx,
+ GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
+ "dstore processes get\n");
+#endif
db_init(dbh);
now = get_time();
if (sq_prepare(dbh,
@@ -360,6 +378,7 @@
coreAPI = capi;
api.get = &d_get;
api.put = &d_put;
+ quota = 1024 * 1024; /* FIXME: allow user to configure */
return &api;
}
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2006-12-27 07:10:25 UTC (rev
4071)
+++ GNUnet/src/applications/fs/module/fs.c 2006-12-27 08:02:31 UTC (rev
4072)
@@ -41,7 +41,7 @@
#include "querymanager.h"
#include "fs.h"
-#define DEBUG_FS YES
+#define DEBUG_FS NO
typedef struct {
struct DHT_GET_RECORD * rec;
Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c 2006-12-27 07:10:25 UTC (rev
4071)
+++ GNUnet/src/applications/session/connect.c 2006-12-27 08:02:31 UTC (rev
4072)
@@ -37,7 +37,7 @@
#define hello_HELPER_TABLE_START_SIZE 64
-#define DEBUG_SESSION YES
+#define DEBUG_SESSION NO
#define EXTRA_CHECKS ALLOW_EXTRA_CHECKS
Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2006-12-27 07:10:25 UTC
(rev 4071)
+++ GNUnet/src/applications/topology_default/topology.c 2006-12-27 08:02:31 UTC
(rev 4072)
@@ -39,6 +39,8 @@
#include "gnunet_transport_service.h"
#include "gnunet_pingpong_service.h"
+#define DEBUG_TOPOLOGY NO
+
/**
* After 2 minutes on an inactive connection, probe the other
* node with a ping if we have achieved less than 50% of our
@@ -161,7 +163,9 @@
static void scanForHosts(unsigned int index) {
IndexMatch indexMatch;
cron_t now;
+#if DEBUG_TOPOLOGY
EncName enc;
+#endif
if (os_network_monitor_get_load(coreAPI->load_monitor,
Upload) > 100)
@@ -175,10 +179,12 @@
&scanHelperCount,
&indexMatch);
if (indexMatch.matchCount == 0) {
+#if DEBUG_TOPOLOGY
GE_LOG(coreAPI->ectx,
GE_DEBUG | GE_REQUEST | GE_DEVELOPER,
"No peers found for slot %u\n",
index);
+#endif
return; /* no matching peers found! */
}
if (indexMatch.costSelector > 0)
@@ -196,6 +202,7 @@
GE_BREAK(NULL, 0); /* should REALLY not happen */
return;
}
+#if DEBUG_TOPOLOGY
IF_GELOG(coreAPI->ectx,
GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
hash2enc(&indexMatch.match.hashPubKey,
@@ -204,6 +211,7 @@
GE_DEBUG | GE_REQUEST | GE_USER | GE_DEVELOPER,
"Trying to connect to peer `%s'\n",
&enc);
+#endif
coreAPI->unicast(&indexMatch.match,
NULL,
0,
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2006-12-27 07:10:25 UTC (rev 4071)
+++ GNUnet/src/server/connection.c 2006-12-27 08:02:31 UTC (rev 4072)
@@ -1914,12 +1914,12 @@
static void shutdownConnection(BufferEntry * be) {
P2P_hangup_MESSAGE hangup;
unsigned int i;
-#if DEBUG_CONNECTION || 1
+#if DEBUG_CONNECTION
EncName enc;
#endif
ENTRY();
-#if DEBUG_CONNECTION || 1
+#if DEBUG_CONNECTION
IF_GELOG(ectx,
GE_DEBUG | GE_REQUEST | GE_USER,
hash2enc(&be->session.sender.hashPubKey,
@@ -2466,7 +2466,9 @@
default: /* not up, not down - partial SETKEY exchange */
if ( (now > root->isAlive) &&
(now - root->isAlive > SECONDS_NOPINGPONG_DROP * cronSECONDS)) {
+#if DEBUG_CONNECTION
EncName enc;
+
IF_GELOG(ectx,
GE_DEBUG | GE_REQUEST | GE_USER,
hash2enc(&root->session.sender.hashPubKey,
@@ -2476,6 +2478,7 @@
"closing connection to %s: %s not answered.\n",
&enc,
(root->status == STAT_SETKEY_SENT) ? "SETKEY" : "PING");
+#endif
shutdownConnection(root);
}
break;
@@ -3114,7 +3117,11 @@
prev = NULL;
be = CONNECTION_buffer_[i];
while(be != NULL) {
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER, "Closing connection:
shutdown\n");
+#if DEBUG_CONNECTION
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Closing connection: shutdown\n");
+#endif
shutdownConnection(be);
prev = be;
be = be->overflowChain;
@@ -3526,12 +3533,14 @@
*/
void disconnectFromPeer(const PeerIdentity * node) {
BufferEntry *be;
- EncName enc;
ENTRY();
MUTEX_LOCK(lock);
be = lookForHost(node);
if(be != NULL) {
+#if DEBUG_CONNECTION
+ EncName enc;
+
IF_GELOG(ectx,
GE_DEBUG | GE_REQUEST | GE_USER,
hash2enc(&node->hashPubKey,
@@ -3540,6 +3549,7 @@
GE_DEBUG | GE_REQUEST | GE_USER,
"Closing connection to `%s' as requested by application.\n",
&enc);
+#endif
shutdownConnection(be);
}
MUTEX_UNLOCK(lock);
Modified: GNUnet/src/server/tcpserver.c
===================================================================
--- GNUnet/src/server/tcpserver.c 2006-12-27 07:10:25 UTC (rev 4071)
+++ GNUnet/src/server/tcpserver.c 2006-12-27 08:02:31 UTC (rev 4072)
@@ -185,10 +185,12 @@
*/
int sendToClient(struct ClientHandle * handle,
const MESSAGE_HEADER * message) {
+#if DEBUG_TCPHANDLER
GE_LOG(ectx,
GE_DEBUG | GE_DEVELOPER | GE_REQUEST,
"%s: sending reply to client\n",
__FUNCTION__);
+#endif
return select_write(selector,
handle->sock,
message,
Modified: GNUnet/src/transports/tcp.c
===================================================================
--- GNUnet/src/transports/tcp.c 2006-12-27 07:10:25 UTC (rev 4071)
+++ GNUnet/src/transports/tcp.c 2006-12-27 08:02:31 UTC (rev 4072)
@@ -264,10 +264,12 @@
_("Could not determine my public IP address.\n"));
return NULL;
}
+#if DEBUG_TCP
GE_LOG(ectx,
GE_DEBUG | GE_USER | GE_REQUEST,
"TCP uses IP address %u.%u.%u.%u.\n",
PRIP(ntohl(*(int*)&haddr->ip)));
+#endif
haddr->port = htons(port);
haddr->reserved = htons(0);
msg->senderAddressSize = htons(sizeof(HostAddress));
Modified: GNUnet/src/util/boot/startup.c
===================================================================
--- GNUnet/src/util/boot/startup.c 2006-12-27 07:10:25 UTC (rev 4071)
+++ GNUnet/src/util/boot/startup.c 2006-12-27 08:02:31 UTC (rev 4072)
@@ -30,7 +30,7 @@
#include "gnunet_util_error_loggers.h"
#include "platform.h"
-#define DO_REQUEST NO
+#define DO_REQUEST YES
static GE_KIND
convertLogLevel(const char * level) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4072 - in GNUnet/src: applications/dht/module applications/dht/tools applications/dstore applications/fs/module applications/session applications/topology_default server transports util/boot,
grothoff <=