[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r493 - in GNUnet/src/applications: fs/module gap sqstore_sq
From: |
grothoff |
Subject: |
[GNUnet-SVN] r493 - in GNUnet/src/applications: fs/module gap sqstore_sqlite |
Date: |
Sat, 26 Mar 2005 13:09:43 -0800 (PST) |
Author: grothoff
Date: 2005-03-26 13:09:41 -0800 (Sat, 26 Mar 2005)
New Revision: 493
Modified:
GNUnet/src/applications/fs/module/querymanager.c
GNUnet/src/applications/gap/gap.c
GNUnet/src/applications/gap/gaptest.c
GNUnet/src/applications/gap/peer1.conf
GNUnet/src/applications/gap/peer2.conf
GNUnet/src/applications/sqstore_sqlite/sqlite.c
Log:
fixes
Modified: GNUnet/src/applications/fs/module/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.c 2005-03-26 20:52:58 UTC
(rev 492)
+++ GNUnet/src/applications/fs/module/querymanager.c 2005-03-26 21:09:41 UTC
(rev 493)
@@ -135,14 +135,17 @@
const Datastore_Value * value) {
int i;
ReplyContent * rc;
+ unsigned int matchCount;
GNUNET_ASSERT(ntohl(value->size) > sizeof(Datastore_Value));
+ matchCount = 0;
MUTEX_LOCK(&queryManagerLock);
for (i=trackerCount-1;i>=0;i--) {
if ( (equalsHashCode512(&trackers[i]->query,
key)) &&
( (trackers[i]->type == ANY_BLOCK) ||
(trackers[i]->type == ntohl(value->type)) ) ) {
+ matchCount++;
rc = MALLOC(sizeof(ReplyContent) +
ntohl(value->size) - sizeof(Datastore_Value));
rc->header.size = htons(sizeof(ReplyContent) +
@@ -157,12 +160,12 @@
coreAPI->sendToClient(trackers[i]->client,
&rc->header);
FREE(rc);
- } else {
- LOG(LOG_DEBUG,
- "Reply did not match request %u\n",
- i);
}
}
+ if (matchCount == 0) {
+ LOG(LOG_DEBUG,
+ "Reply did not match any request.\n");
+ }
MUTEX_UNLOCK(&queryManagerLock);
}
Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c 2005-03-26 20:52:58 UTC (rev 492)
+++ GNUnet/src/applications/gap/gap.c 2005-03-26 21:09:41 UTC (rev 493)
@@ -43,7 +43,9 @@
#include "gnunet_traffic_service.h"
#include "gnunet_topology_service.h"
+#define EXTRA_CHECKS YES
+
/* ***************** policy constants **************** */
/**
@@ -783,10 +785,22 @@
*/
static void sendToSelected(const PeerIdentity * id,
const QueryRecord * qr) {
+ EncName encq;
+ EncName encp;
+
if (equalsHashCode512(&id->hashPubKey,
&qr->noTarget.hashPubKey))
return;
if (getBit(qr, getIndex(id)) == 1) {
+ IFLOG(LOG_DEBUG,
+ hash2enc(&id->hashPubKey,
+ &encp);
+ hash2enc(&qr->msg->queries[0],
+ &encq));
+ LOG(LOG_DEBUG,
+ "Sending query '%s' to '%s'\n",
+ &encq,
+ &encp);
coreAPI->unicast(id,
&qr->msg->header,
BASE_QUERY_PRIORITY
@@ -991,6 +1005,11 @@
*
* @param sender the next hop
* @param result the content that was found
+ * @param data is a DataContainer which
+ * wraps the content in the format that
+ * can be passed to the FS module (GapWrapper),
+ * which in turn wraps the DBlock (including
+ * the type ID).
*/
static void queueReply(const PeerIdentity * sender,
const HashCode512 * primaryKey,
@@ -999,6 +1018,13 @@
IndirectionTableEntry * ite;
unsigned int size;
+#if EXTRA_CHECKS
+ /* verify data is valid */
+ uri(data,
+ ANY_BLOCK,
+ primaryKey);
+#endif
+
ite = &ROUTING_indTable_[computeRoutingIndex(primaryKey)];
if (! equalsHashCode512(&ite->primaryKey,
primaryKey) ) {
@@ -1009,12 +1035,12 @@
the same query. Well, at least we should not also
queue the delayed reply twice... */
}
- ite->successful_local_lookup_in_delay_loop = YES;
size = sizeof(GAP_REPLY) + ntohl(data->size) - sizeof(DataContainer);
if (size >= MAX_BUFFER_SIZE) {
BREAK();
return;
}
+ ite->successful_local_lookup_in_delay_loop = YES;
pmsg = MALLOC(size);
pmsg->header.size
= htons(size);
@@ -1397,6 +1423,7 @@
unsigned int j;
unsigned int maxDelay;
cron_t now;
+ EncName enc;
cronTime(&now);
if (now < ite->ttl)
@@ -1404,13 +1431,20 @@
else
maxDelay = TTL_DECREMENT; /* for expired queries */
/* send to peers */
- for (j=0;j<ite->hostsWaiting;j++)
+ for (j=0;j<ite->hostsWaiting;j++) {
+ IFLOG(LOG_DEBUG,
+ hash2enc(&ite->destination[j].hashPubKey,
+ &enc));
+ LOG(LOG_DEBUG,
+ "GAP sending reply to '%s'\n",
+ &enc);
coreAPI->unicast(&ite->destination[j],
msg,
BASE_REPLY_PRIORITY *
(ite->priority+1),
/* weigh priority */
maxDelay);
+ }
}
struct qLRC {
@@ -1419,17 +1453,38 @@
unsigned int valueCount;
};
+/**
+ * Callback for processing local results.
+ * Inserts all results into the qLRC closure.
+ *
+ * @param primaryKey is the key needed to decrypt
+ * the block
+ * @param value is a DataContainer which
+ * wraps the content in the format that
+ * can be passed to the FS module (GapWrapper),
+ * which in turn wraps the DBlock (including
+ * the type ID).
+ */
static int
queryLocalResultCallback(const HashCode512 * primaryKey,
const DataContainer * value,
struct qLRC * cls) {
HashCode512 hc;
+ HashCode512 hc1;
int i;
IndirectionTableEntry * ite;
+#if EXTRA_CHECKS
+ /* verify data is valid */
+ uri(value,
+ ANY_BLOCK,
+ primaryKey);
+#endif
+
/* check seen */
ite = &ROUTING_indTable_[computeRoutingIndex(primaryKey)];
-
+ /* FIXME: this computation of the seen-ID
+ includes the timeout (bad!) */
hash(&value[1],
ntohl(value->size) - sizeof(DataContainer),
&hc);
@@ -1437,7 +1492,14 @@
if (equalsHashCode512(&hc,
&ite->seen[i]))
return OK; /* drop, duplicate result! */
-
+ for (i=0;i<cls->valueCount;i++) {
+ hash(&cls->values[i][1],
+ ntohl(cls->values[i]->size) - sizeof(DataContainer),
+ &hc1);
+ if (equalsHashCode512(&hc,
+ &hc1))
+ return OK; /* drop, duplicate entry in DB! */
+ }
GROW(cls->values,
cls->valueCount,
cls->valueCount+1);
@@ -1540,7 +1602,7 @@
if (max > cls.valueCount)
max = cls.valueCount; /* can't send more back then
what we have */
-
+
for (i=0;i<cls.valueCount;i++) {
if (i < max) {
if (cls.sender != NULL)
@@ -1556,9 +1618,8 @@
&query->queries[0],
cls.values[perm[i]],
ite->priority);
-
+
if (uri(cls.values[perm[i]],
- ntohl(cls.values[perm[i]]->size),
ite->type,
&query->queries[0]))
doForward = NO; /* we have the one and only answer,
@@ -1605,15 +1666,26 @@
unsigned int prio;
DataContainer * value;
double preference;
+ EncName enc;
+ IFLOG(LOG_DEBUG,
+ if (hostId != NULL)
+ hash2enc(&hostId->hashPubKey,
+ &enc));
+ LOG(LOG_DEBUG,
+ "GAP received content from '%s'\n",
+ (hostId != NULL) ? (const char*)&enc : "myself");
if (ntohs(msg->header.size) < sizeof(GAP_REPLY)) {
BREAK();
return SYSERR; /* invalid! */
}
ite = &ROUTING_indTable_[computeRoutingIndex(&msg->primaryKey)];
+ ite->successful_local_lookup_in_delay_loop = NO;
size = ntohs(msg->header.size) - sizeof(GAP_REPLY);
prio = 0;
+ /* FIXME: this computation of contentHC
+ includes the timeout, which is bad! */
hash(&msg[1],
size,
&contentHC);
@@ -1641,14 +1713,15 @@
0);
if (ret == SYSERR) {
FREE(value);
+ BREAK();
return SYSERR; /* invalid */
}
/* THIRD: compute content priority/value and
send remote reply (ITE processing) */
MUTEX_LOCK(&ite->lookup_exclusion);
- if (! equalsHashCode512(&ite->primaryKey,
- &msg->primaryKey) ) {
+ if (equalsHashCode512(&ite->primaryKey,
+ &msg->primaryKey) ) {
prio = ite->priority;
ite->priority = 0;
/* remove the sender from the waiting list
@@ -1670,8 +1743,7 @@
ite->seen[ite->seenIndex-1] = contentHC;
if (ite->seenIndex == 1) {
ite->seenReplyWasUnique
- = uri(&msg[1],
- size,
+ = uri(value,
ite->type,
&ite->primaryKey);
} else {
@@ -1682,7 +1754,6 @@
}
MUTEX_UNLOCK(&ite->lookup_exclusion);
prio += claimReward(&msg->primaryKey, hostId);
- FREE(value);
/* FOURTH: update content priority in local datastore */
if (prio > 0) {
@@ -1693,13 +1764,13 @@
}
/* FIFTH: if unique reply, stopy querying */
- if (uri(&msg[1],
- size,
+ if (uri(value,
ite->type,
&ite->primaryKey)) {
/* unique reply, stop forwarding! */
dequeueQuery(&ite->primaryKey);
}
+ FREE(value);
/* SIXTH: adjust traffic preferences */
if (hostId != NULL) { /* if we are the sender, hostId will be NULL */
Modified: GNUnet/src/applications/gap/gaptest.c
===================================================================
--- GNUnet/src/applications/gap/gaptest.c 2005-03-26 20:52:58 UTC (rev
492)
+++ GNUnet/src/applications/gap/gaptest.c 2005-03-26 21:09:41 UTC (rev
493)
@@ -265,6 +265,7 @@
"5B2Q58IEU1VF5FTR838449CSHVBOAHLDVQAOA33O77F"
"OPDA8F1VIKESLSNBO",
&peer2.hashPubKey));
+#if 0
daemon1 = fork();
if (daemon1 == 0) {
if (0 != execlp("gnunetd", /* what binary to execute, must be in $PATH! */
@@ -345,10 +346,10 @@
}
sleep(5);
-
ret = 0;
left = 5;
/* wait for connection or abort with error */
+#endif
initUtil(argc, argv, &parseOptions);
do {
sock = getClientSocket();
@@ -378,13 +379,13 @@
CHECK(NULL != uri);
CHECK(OK == searchFile(&uri));
setConfigurationInt("NETWORK",
- "PORT",
- 12087);
+ "PORT",
+ 12087);
CHECK(OK == downloadFile(12345, uri));
ECRS_freeUri(uri);
setConfigurationInt("NETWORK",
- "PORT",
- 2087);
+ "PORT",
+ 2087);
CHECK(OK == unindexFile(12345));
FAILURE:
Modified: GNUnet/src/applications/gap/peer1.conf
===================================================================
--- GNUnet/src/applications/gap/peer1.conf 2005-03-26 20:52:58 UTC (rev
492)
+++ GNUnet/src/applications/gap/peer1.conf 2005-03-26 21:09:41 UTC (rev
493)
@@ -64,7 +64,7 @@
[FS]
QUOTA = 1024
ACTIVEMIGRATION = NO
-DIR = /tmp/gnunet-ecrs-test/
+DIR = /tmp/gnunet-gap-test-1/
INDEX-DIRECTORY = $GNUNETD_HOME/data/shared/
INDEX-QUOTA = 8192
Modified: GNUnet/src/applications/gap/peer2.conf
===================================================================
--- GNUnet/src/applications/gap/peer2.conf 2005-03-26 20:52:58 UTC (rev
492)
+++ GNUnet/src/applications/gap/peer2.conf 2005-03-26 21:09:41 UTC (rev
493)
@@ -64,7 +64,7 @@
[FS]
QUOTA = 1024
ACTIVEMIGRATION = NO
-DIR = /tmp/gnunet-ecrs-test/
+DIR = /tmp/gnunet-gap-test-2/
INDEX-DIRECTORY = $GNUNETD_HOME/data/shared/
INDEX-QUOTA = 8192
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2005-03-26 20:52:58 UTC
(rev 492)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2005-03-26 21:09:41 UTC
(rev 493)
@@ -697,7 +697,7 @@
FREE(escapedBlock);
FREE(escapedHash);
sqlite3_reset(stmt);
- if(n != SQLITE_DONE) {
+ if (n != SQLITE_DONE) {
LOG_SQLITE(LOG_ERROR,
"sqlite_query");
MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r493 - in GNUnet/src/applications: fs/module gap sqstore_sqlite,
grothoff <=