[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3774 - in GNUnet/src: applications/datastore applications/
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3774 - in GNUnet/src: applications/datastore applications/fs/ecrs applications/fs/module applications/sqstore_sqlite include server |
Date: |
Tue, 14 Nov 2006 21:17:20 -0800 (PST) |
Author: grothoff
Date: 2006-11-14 21:17:13 -0800 (Tue, 14 Nov 2006)
New Revision: 3774
Modified:
GNUnet/src/applications/datastore/prefetch.c
GNUnet/src/applications/fs/ecrs/tree.h
GNUnet/src/applications/fs/module/migration.c
GNUnet/src/applications/fs/module/ondemand.c
GNUnet/src/applications/sqstore_sqlite/sqlite.c
GNUnet/src/include/gnunet_gap_service.h
GNUnet/src/server/connection.c
Log:
fixing rest of 1152
Modified: GNUnet/src/applications/datastore/prefetch.c
===================================================================
--- GNUnet/src/applications/datastore/prefetch.c 2006-11-15 04:34:20 UTC
(rev 3773)
+++ GNUnet/src/applications/datastore/prefetch.c 2006-11-15 05:17:13 UTC
(rev 3774)
@@ -27,6 +27,7 @@
#include "platform.h"
#include "prefetch.h"
+#include "gnunet_protocols.h"
#define DEBUG_PREFETCH NO
@@ -40,7 +41,9 @@
* Buffer with pre-fetched, encoded random content for migration.
*/
typedef struct {
+
HashCode512 key;
+
Datastore_Value * value;
/**
* 0 if we have never used this content with any peer. Otherwise
@@ -65,7 +68,10 @@
*/
static struct SEMAPHORE * acquireMoreSignal;
-static struct SEMAPHORE * doneSignal;
+/**
+ * Set to YES to shutdown the module.
+ */
+static int doneSignal;
/**
* Lock for the RCB buffer.
@@ -89,10 +95,15 @@
void * closure) {
int load;
- if (doneSignal != NULL)
+ GE_LOG(ectx,
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Prefetch: got block of type %u\n",
+ ntohl(value->type));
+
+ if (doneSignal)
return SYSERR;
SEMAPHORE_DOWN(acquireMoreSignal, YES);
- if (doneSignal != NULL)
+ if (doneSignal)
return SYSERR;
MUTEX_LOCK(lock);
load = 0;
@@ -106,9 +117,10 @@
}
}
#if DEBUG_PREFETCH
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Adding content to prefetch buffer (%u)\n",
- rCBPos);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Adding content to prefetch buffer (%u)\n",
+ rCBPos);
#endif
randomContentBuffer[rCBPos].key = *key;
randomContentBuffer[rCBPos].used = 0;
@@ -125,11 +137,11 @@
if (load > 100)
load = 100; /* never sleep longer than 5 seconds since that
might show up badly in the shutdown sequence... */
- if (doneSignal != NULL)
+ if (doneSignal)
return SYSERR;
/* the higher the load, the longer the sleep */
PTHREAD_SLEEP(50 * cronMILLIS * load);
- if (doneSignal != NULL)
+ if (doneSignal)
return SYSERR;
return OK;
}
@@ -139,7 +151,7 @@
*/
static void * rcbAcquire(void * unused) {
int load;
- while (doneSignal == NULL) {
+ while (doneSignal == NO) {
sq->iterateExpirationTime(0,
&aquire,
NULL);
@@ -154,7 +166,6 @@
might show up badly in the shutdown sequence... */
PTHREAD_SLEEP(50 * cronMILLIS * load);
}
- SEMAPHORE_UP(doneSignal);
return NULL;
}
@@ -186,6 +197,9 @@
(type != 0) ) ) ||
(sizeLimit < ntohl(randomContentBuffer[i].value->size)) )
continue;
+ if ( (ntohl(randomContentBuffer[i].value->type) == ONDEMAND_BLOCK) &&
+ (sizeLimit < 32768) )
+ continue; /* 32768 == ecrs/tree.h: DBLOCK_SIZE */
dist = distanceHashCode512(&randomContentBuffer[i].key,
receiver);
if (dist < minDist) {
@@ -196,15 +210,17 @@
if (minIdx == -1) {
MUTEX_UNLOCK(lock);
#if DEBUG_PREFETCH
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Failed to find content in prefetch buffer\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Failed to find content in prefetch buffer\n");
#endif
return SYSERR;
}
#if DEBUG_PREFETCH
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Found content in prefetch buffer (%u)\n",
- minIdx);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Found content in prefetch buffer (%u)\n",
+ minIdx);
#endif
*key = randomContentBuffer[minIdx].key;
*value = randomContentBuffer[minIdx].value;
@@ -236,7 +252,7 @@
0,
sizeof(ContentBuffer *)*RCB_SIZE);
acquireMoreSignal = SEMAPHORE_CREATE(RCB_SIZE);
- doneSignal = NULL;
+ doneSignal = NO;
lock = MUTEX_CREATE(NO);
gather_thread = PTHREAD_CREATE(&rcbAcquire,
NULL,
@@ -249,12 +265,10 @@
int i;
void * unused;
- doneSignal = SEMAPHORE_CREATE(0);
+ doneSignal = YES;
PTHREAD_STOP_SLEEP(gather_thread);
SEMAPHORE_UP(acquireMoreSignal);
- SEMAPHORE_DOWN(doneSignal, YES);
SEMAPHORE_DESTROY(acquireMoreSignal);
- SEMAPHORE_DESTROY(doneSignal);
PTHREAD_JOIN(gather_thread, &unused);
for (i=0;i<RCB_SIZE;i++)
FREENONNULL(randomContentBuffer[i].value);
Modified: GNUnet/src/applications/fs/ecrs/tree.h
===================================================================
--- GNUnet/src/applications/fs/ecrs/tree.h 2006-11-15 04:34:20 UTC (rev
3773)
+++ GNUnet/src/applications/fs/ecrs/tree.h 2006-11-15 05:17:13 UTC (rev
3774)
@@ -24,8 +24,7 @@
#include "ecrs_core.h"
/**
- * Size of a DBlock. Currently set for debugging.
- * Should be a multiple of 8 and larger than
+ * Size of a DBlock. Should be a multiple of 8 and larger than
* sizeof(CHK).
*/
#define DBLOCK_SIZE 32768
Modified: GNUnet/src/applications/fs/module/migration.c
===================================================================
--- GNUnet/src/applications/fs/module/migration.c 2006-11-15 04:34:20 UTC
(rev 3773)
+++ GNUnet/src/applications/fs/module/migration.c 2006-11-15 05:17:13 UTC
(rev 3774)
@@ -127,15 +127,23 @@
0)) {
MUTEX_UNLOCK(lock);
#if DEBUG_MIGRATION
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Migration: random lookup in datastore failed.\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Migration: random lookup in datastore failed.\n");
#endif
return 0;
}
}
+ GE_LOG(ectx,
+ GE_DEBUG | GE_BULK | GE_USER,
+ "Migration: got block of type %u\n",
+ ntohl(content->type));
if (ntohl(content->type) == ONDEMAND_BLOCK) {
- if (ONDEMAND_getIndexed(datastore, content, &key, &enc) != OK) {
+ if (ONDEMAND_getIndexed(datastore,
+ content,
+ &key,
+ &enc) != OK) {
FREE(content);
content = NULL;
MUTEX_UNLOCK(lock);
@@ -152,10 +160,11 @@
if (size > padding) {
MUTEX_UNLOCK(lock);
#if DEBUG_MIGRATION
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Available content of size %u too big for available space (%u)\n",
- size,
- padding);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Available content of size %u too big for available space (%u)\n",
+ size,
+ padding);
#endif
return 0;
}
@@ -187,14 +196,16 @@
padding);
FREE(gw);
#if DEBUG_MIGRATION
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "gap's tryMigrate returned %u\n",
- ret);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "gap's tryMigrate returned %u\n",
+ ret);
#endif
} else {
#if DEBUG_MIGRATION
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Migration: anonymity requirements not satisfied.\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Migration: anonymity requirements not satisfied.\n");
#endif
}
if (ret > 0) {
@@ -221,18 +232,20 @@
gap = g;
dht = d;
traffic = t;
- coreAPI->registerSendCallback(512,
+ coreAPI->registerSendCallback(GAP_ESTIMATED_DATA_SIZE,
&activeMigrationCallback);
stats = capi->requestService("stats");
if (stats != NULL) {
- stat_migration_count = stats->create(gettext_noop("# blocks migrated"));
- stat_on_demand_migration_attempts = stats->create(gettext_noop("#
on-demand block migration attempts"));
+ stat_migration_count
+ = stats->create(gettext_noop("# blocks migrated"));
+ stat_on_demand_migration_attempts
+ = stats->create(gettext_noop("# on-demand block migration attempts"));
}
}
void doneMigration() {
- coreAPI->unregisterSendCallback(512,
+ coreAPI->unregisterSendCallback(GAP_ESTIMATED_DATA_SIZE,
&activeMigrationCallback);
if (stats != NULL) {
coreAPI->releaseService(stats);
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2006-11-15 04:34:20 UTC
(rev 3773)
+++ GNUnet/src/applications/fs/module/ondemand.c 2006-11-15 05:17:13 UTC
(rev 3774)
@@ -470,6 +470,7 @@
fn);
FREE(fn);
CLOSE(fileHandle);
+ asyncDelete(datastore, dbv, query);
return SYSERR;
}
db = MALLOC(sizeof(DBlock) + ntohl(odb->blockSize));
@@ -486,6 +487,7 @@
FREE(fn);
FREE(db);
CLOSE(fileHandle);
+ asyncDelete(datastore, dbv, query);
return SYSERR;
}
CLOSE(fileHandle);
Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c 2006-11-15 04:34:20 UTC
(rev 3773)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c 2006-11-15 05:17:13 UTC
(rev 3774)
@@ -559,7 +559,7 @@
else
strcat(scratch,
"(prio > :4 AND expire == :5) OR expire > :6)");
- if (type)
+ if (type != 0)
strcat(scratch, " AND type = :7");
else
SNPRINTF(&scratch[strlen(scratch)],
Modified: GNUnet/src/include/gnunet_gap_service.h
===================================================================
--- GNUnet/src/include/gnunet_gap_service.h 2006-11-15 04:34:20 UTC (rev
3773)
+++ GNUnet/src/include/gnunet_gap_service.h 2006-11-15 05:17:13 UTC (rev
3774)
@@ -41,6 +41,11 @@
#endif
#endif
+/**
+ * Estimated size of most blocks transported with
+ * the GAP protocol. 32k DBlocks plus overhead.
+ */
+#define GAP_ESTIMATED_DATA_SIZE (33*1024)
/**
* Function that helps the routing code to find out if
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2006-11-15 04:34:20 UTC (rev 3773)
+++ GNUnet/src/server/connection.c 2006-11-15 05:17:13 UTC (rev 3774)
@@ -208,11 +208,11 @@
* implement a round-robbin invocation chain).
*/
typedef struct SendCallbackList__ {
+
/**
- * Minimum number of bytes that must be available
- * to call this callback.
+ * Did we say that this is a linked list?
*/
- unsigned int minimumPadding;
+ struct SendCallbackList__ *next;
/**
* The callback method.
@@ -220,9 +220,10 @@
BufferFillCallback callback;
/**
- * Did we say that this is a linked list?
+ * Minimum number of bytes that must be available
+ * to call this callback.
*/
- struct SendCallbackList__ *next;
+ unsigned int minimumPadding;
} SendCallbackList;
@@ -1447,8 +1448,8 @@
/* still room left? try callbacks! */
pos = scl_nextHead;
- while(pos != NULL) {
- if(pos->minimumPadding + p <= totalMessageSize) {
+ while (pos != NULL) {
+ if (pos->minimumPadding + p <= totalMessageSize) {
p += pos->callback(&be->session.sender,
&plaintextMsg[p],
be->session.mtu - p);
@@ -3087,7 +3088,7 @@
/**
* Register a callback method that should be invoked whenever a
* message is about to be send that has more than minimumPadding bytes
- * left before maxing out the MTU. The callback method can then be
+ * left before maxing out the MTU. The callback method can then be
* used to add additional content to the message (instead of the
* random noise that is added by otherwise). Note that if the MTU is 0
* (for streams), the callback method will always be called with
@@ -3148,7 +3149,8 @@
MUTEX_LOCK(lock);
pos = scl_nextHead;
while(pos != NULL) {
- if((pos->callback == callback) && (pos->minimumPadding == minimumPadding))
{
+ if ( (pos->callback == callback) &&
+ (pos->minimumPadding == minimumPadding) ) {
if(prev == NULL)
scl_nextHead = pos->next;
else
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3774 - in GNUnet/src: applications/datastore applications/fs/ecrs applications/fs/module applications/sqstore_sqlite include server,
grothoff <=