[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r3223 - in GNUnet: . src/applications/chat src/applications
From: |
grothoff |
Subject: |
[GNUnet-SVN] r3223 - in GNUnet: . src/applications/chat src/applications/dht/module src/applications/dht/tools src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/lib src/applications/fs/tools src/applications/gap src/applications/rpc src/applications/session src/applications/tbench src/applications/topology_f2f src/applications/vpn src/include src/util/network_client |
Date: |
Sat, 12 Aug 2006 20:46:05 -0700 (PDT) |
Author: grothoff
Date: 2006-08-12 20:45:47 -0700 (Sat, 12 Aug 2006)
New Revision: 3223
Modified:
GNUnet/src/applications/chat/gnunet-chat.c
GNUnet/src/applications/dht/module/datastore_dht_master.c
GNUnet/src/applications/dht/module/dht.c
GNUnet/src/applications/dht/tools/dht-query.c
GNUnet/src/applications/dht/tools/dht_api.c
GNUnet/src/applications/dht/tools/dhttest2.c
GNUnet/src/applications/fs/ecrs/Makefile.am
GNUnet/src/applications/fs/ecrs/directory.c
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/ecrs/ecrs.c
GNUnet/src/applications/fs/ecrs/ecrstest.c
GNUnet/src/applications/fs/ecrs/indexinfo.c
GNUnet/src/applications/fs/ecrs/keyspace.c
GNUnet/src/applications/fs/ecrs/meta.c
GNUnet/src/applications/fs/ecrs/namespace.c
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/ecrs/searchtest.c
GNUnet/src/applications/fs/ecrs/tree.c
GNUnet/src/applications/fs/ecrs/unindex.c
GNUnet/src/applications/fs/ecrs/upload.c
GNUnet/src/applications/fs/ecrs/uri.c
GNUnet/src/applications/fs/fsui/namespace_info.c
GNUnet/src/applications/fs/fsui/upload.c
GNUnet/src/applications/fs/lib/fslibtest.c
GNUnet/src/applications/fs/tools/gnunet-delete.c
GNUnet/src/applications/fs/tools/gnunet-insert.c
GNUnet/src/applications/gap/gaptest.c
GNUnet/src/applications/rpc/rpc.c
GNUnet/src/applications/session/sessiontest.c
GNUnet/src/applications/tbench/tbenchtest.c
GNUnet/src/applications/tbench/tbenchtest_udp.c
GNUnet/src/applications/topology_f2f/topology.c
GNUnet/src/applications/vpn/gnunet-vpn.c
GNUnet/src/include/gnunet_ecrs_lib.h
GNUnet/src/include/gnunet_util_threads.h
GNUnet/src/util/network_client/tcpiotest.c
GNUnet/todo
Log:
fixing ecrs
Modified: GNUnet/src/applications/chat/gnunet-chat.c
===================================================================
--- GNUnet/src/applications/chat/gnunet-chat.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/chat/gnunet-chat.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -194,7 +194,7 @@
SEMAPHORE_DOWN(doneSem);
SEMAPHORE_DESTROY(doneSem);
PTHREAD_JOIN(&messageReceiveThread, &unused);
- releaseClientSocket(sock);
+ connection_destroy(sock);
doneUtil();
return 0;
Modified: GNUnet/src/applications/dht/module/datastore_dht_master.c
===================================================================
--- GNUnet/src/applications/dht/module/datastore_dht_master.c 2006-08-13
02:45:10 UTC (rev 3222)
+++ GNUnet/src/applications/dht/module/datastore_dht_master.c 2006-08-13
03:45:47 UTC (rev 3223)
@@ -330,7 +330,7 @@
prev = NULL;
MUTEX_LOCK(&store->lock);
- cronTime(&now);
+ now = get_time();
pos = store->first;
while (pos != NULL) {
for (i=pos->count-1;i>=0;i--) {
Modified: GNUnet/src/applications/dht/module/dht.c
===================================================================
--- GNUnet/src/applications/dht/module/dht.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/dht/module/dht.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -949,7 +949,7 @@
return;
}
tables = (DHT_TableId*) data;
- cronTime(&now);
+ now = get_time();
#if DEBUG_DHT
IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
@@ -1187,7 +1187,7 @@
&enc);
#endif
ENTER();
- cronTime(&now);
+ now = get_time();
param = RPC_paramNew();
MUTEX_LOCK(&fnc->lock);
if (equalsHashCode512(&fnc->key,
@@ -1314,7 +1314,7 @@
MUTEX_LOCK(lock);
/* test if this peer is already in buckets */
pos = findPeerInfo(identity);
- cronTime(&now);
+ now = get_time();
if (pos != NULL)
pos->lastTimePingSend = now;
MUTEX_UNLOCK(lock);
@@ -1489,7 +1489,7 @@
peer,
record->keys))
return OK; /* refuse! */
- cronTime(&now);
+ now = get_time();
if (record->timeout > now)
delta = (record->timeout - now) / 2;
else
@@ -2242,7 +2242,7 @@
peer,
&record->key))
return OK;
- cronTime(&now);
+ now = get_time();
if (record->timeout > now)
delta = (record->timeout - now) / 2;
else
@@ -2543,7 +2543,7 @@
peer,
&record->key))
return OK; /* refuse! */
- cronTime(&now);
+ now = get_time();
if (record->timeout > now)
delta = (record->timeout - now) / 2;
else
@@ -3358,7 +3358,7 @@
"`%s' stops async requests from last cron round.\n",
__FUNCTION__);
#endif
- cronTime(&now);
+ now = get_time();
for (i=putRecordsSize-1;i>=0;i--) {
if ( (shutdownFlag != NULL) ||
(putTimes[i] + DHT_MAINTAIN_BUCKET_FREQUENCY < now)) {
Modified: GNUnet/src/applications/dht/tools/dht-query.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht-query.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/dht/tools/dht-query.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -280,7 +280,7 @@
commands[i]);
break;
}
- releaseClientSocket(handle);
+ connection_destroy(handle);
for (i=0;i<count;i++)
FREE(commands[i]);
FREE(commands);
Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -127,7 +127,7 @@
_("Failed to send `%s'. Closing connection.\n"),
"CS_dht_reply_results_MESSAGE");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
FREE(reply);
@@ -177,7 +177,7 @@
}
if (ok == NO) {
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
continue; /* retry... */
@@ -202,7 +202,7 @@
"GET",
ntohs(buffer->size));
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
FREE(buffer);
@@ -214,7 +214,7 @@
_("Received invalid `%s' request (wrong table)\n"),
"GET");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
break;
@@ -236,7 +236,7 @@
_("Failed to send `%s'. Closing connection.\n"),
"ACK");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
}
@@ -254,7 +254,7 @@
"PUT",
ntohs(buffer->size));
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
break;
@@ -266,7 +266,7 @@
_("Received invalid `%s' request (wrong table)\n"),
"PUT");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
break;
@@ -289,7 +289,7 @@
_("Failed to send `%s'. Closing connection.\n"),
"ACK");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
}
@@ -308,7 +308,7 @@
"REMOVE",
ntohs(buffer->size));
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
break;
@@ -320,7 +320,7 @@
_("Received invalid `%s' request (wrong table)\n"),
"REMOVE");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
break;
@@ -343,7 +343,7 @@
_("Failed to send `%s'. Closing connection.\n"),
"ACK");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
}
@@ -361,7 +361,7 @@
"ITERATE",
ntohs(buffer->size));
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
FREE(buffer);
@@ -377,7 +377,7 @@
_("Failed to send `%s'. Closing connection.\n"),
"ACK");
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
}
@@ -391,7 +391,7 @@
ntohs(buffer->type),
__FILE__, __LINE__);
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
} /* end of switch */
@@ -399,7 +399,7 @@
buffer = NULL;
}
MUTEX_LOCK(&list->lock);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
list->sock = NULL;
MUTEX_UNLOCK(&list->lock);
}
@@ -447,7 +447,7 @@
list,
16 * 1024)) {
LOG_STRERROR(LOG_ERROR, "pthread_create");
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
MUTEX_DESTROY(&list->lock);
FREE(list);
MUTEX_UNLOCK(&lock);
@@ -530,7 +530,7 @@
_("Failed to send `%s' message to gnunetd\n"),
"CS_dht_request_leave_MESSAGE");
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
}
MUTEX_LOCK(&list->lock);
if (list->sock != NULL)
@@ -538,7 +538,7 @@
MUTEX_UNLOCK(&list->lock);
unused = NULL;
PTHREAD_JOIN(&list->processor, &unused);
- releaseClientSocket(list->sock);
+ connection_destroy(list->sock);
MUTEX_DESTROY(&list->lock);
FREE(list);
return ret;
@@ -598,7 +598,7 @@
keyCount * sizeof(HashCode512));
if (OK != connection_write(sock,
&req->header)) {
- releaseClientSocket(sock);
+ connection_destroy(sock);
return SYSERR;
}
FREE(req);
@@ -606,12 +606,12 @@
reply = NULL;
if (OK != connection_read(sock,
&reply)) {
- releaseClientSocket(sock);
+ connection_destroy(sock);
return SYSERR;
}
if ( (sizeof(CS_dht_reply_ack_MESSAGE) == ntohs(reply->size)) &&
(CS_PROTO_dht_REPLY_ACK == ntohs(reply->type)) ) {
- releaseClientSocket(sock);
+ connection_destroy(sock);
ret = checkACK(reply);
FREE(reply);
break; /* termination message, end loop! */
@@ -621,7 +621,7 @@
GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
_("Unexpected reply to `%s' operation.\n"),
"GET");
- releaseClientSocket(sock);
+ connection_destroy(sock);
FREE(reply);
return SYSERR;
}
@@ -641,7 +641,7 @@
closure);
FREE(result);
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
return ret;
}
@@ -700,7 +700,7 @@
ret = OK;
FREE(reply);
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
return ret;
}
@@ -751,7 +751,7 @@
ret = OK;
FREE(reply);
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
return ret;
}
Modified: GNUnet/src/applications/dht/tools/dhttest2.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest2.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/dht/tools/dhttest2.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -143,7 +143,7 @@
left--;
CHECK(left > 0);
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
printf("Peers connected. Running actual test.\n");
memset(&table, 33, sizeof(DHT_TableId));
Modified: GNUnet/src/applications/fs/ecrs/Makefile.am
===================================================================
--- GNUnet/src/applications/fs/ecrs/Makefile.am 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/Makefile.am 2006-08-13 03:45:47 UTC (rev
3223)
@@ -22,6 +22,8 @@
$(top_builddir)/src/applications/fs/libecrs_core.la \
$(top_builddir)/src/applications/fs/lib/libgnunetfs.la \
$(top_builddir)/src/applications/getoption/libgnunetgetoption_api.la \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
+ $(top_builddir)/src/util/crypto/libgnunetutil_crypto.la \
$(top_builddir)/src/util/libgnunetutil.la
Modified: GNUnet/src/applications/fs/ecrs/directory.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/directory.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/directory.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -49,7 +49,8 @@
* @return number of entries on success, SYSERR if the
* directory is malformed
*/
-int ECRS_listDirectory(const char * data,
+int ECRS_listDirectory(struct GE_Context * ectx,
+ const char * data,
unsigned long long len,
struct ECRS_MetaData ** md,
ECRS_SearchProgressCallback spcb,
@@ -72,7 +73,8 @@
mdSize = ntohl(mdSize);
if (mdSize > len - 8 - sizeof(unsigned int) )
return SYSERR; /* invalid size */
- *md = ECRS_deserializeMetaData(&data[8 + sizeof(unsigned int)],
+ *md = ECRS_deserializeMetaData(ectx,
+ &data[8 + sizeof(unsigned int)],
mdSize);
if (*md == NULL)
return SYSERR; /* malformed !*/
@@ -98,7 +100,8 @@
return SYSERR; /* malformed */
}
- fi.uri = ECRS_stringToUri(&data[pos]);
+ fi.uri = ECRS_stringToUri(ectx,
+ &data[pos]);
pos = epos+1;
if (fi.uri == NULL)
return SYSERR; /* malformed! */
@@ -119,7 +122,8 @@
return SYSERR; /* malformed! */
}
- fi.meta = ECRS_deserializeMetaData(&data[pos],
+ fi.meta = ECRS_deserializeMetaData(ectx,
+ &data[pos],
mdSize);
if (fi.meta == NULL) {
ECRS_freeUri(fi.uri);
@@ -159,7 +163,8 @@
* is extended with the mime-type for a GNUnet directory.
* @return OK on success, SYSERR on error
*/
-int ECRS_createDirectory(char ** data,
+int ECRS_createDirectory(struct GE_Context * ectx,
+ char ** data,
unsigned long long * len,
unsigned int count,
const ECRS_FileInfo * fis,
@@ -208,7 +213,8 @@
GNUNET_DIRECTORY_MAGIC,
8);
- ret = ECRS_serializeMetaData(meta,
+ ret = ECRS_serializeMetaData(ectx,
+ meta,
&(*data)[pos + sizeof(unsigned int)],
size - pos - sizeof(unsigned int),
ECRS_SERIALIZE_FULL);
@@ -238,7 +244,8 @@
pos += strlen(ucs[i]) + 1;
FREE(ucs[i]);
- ret = ECRS_serializeMetaData(fis[i].meta,
+ ret = ECRS_serializeMetaData(ectx,
+ fis[i].meta,
&(*data)[pos + sizeof(unsigned int)],
size - pos - sizeof(unsigned int),
ECRS_SERIALIZE_FULL);
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/download.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -65,15 +65,12 @@
*/
typedef struct IOContext {
- /**
- * The depth of the file-tree.
- */
- unsigned int treedepth;
+ struct GE_Context * ectx;
/**
* A lock for synchronizing access.
*/
- Mutex lock;
+ struct MUTEX * lock;
/**
* The file handles for each level in the tree.
@@ -85,6 +82,11 @@
*/
char * filename;
+ /**
+ * The depth of the file-tree.
+ */
+ unsigned int treedepth;
+
} IOContext;
/**
@@ -105,11 +107,11 @@
for (i=0;i<=this->treedepth;i++) {
if (this->handles[i] != -1) {
- closefile(this->handles[i]);
+ CLOSE(this->handles[i]);
this->handles[i] = -1;
}
}
- MUTEX_DESTROY(&this->lock);
+ MUTEX_DESTROY(this->lock);
if (YES == unlinkTreeFiles) {
for (i=1;i<= this->treedepth;i++) {
fn = MALLOC(strlen(this->filename) + 3 + strlen(GNUNET_DIRECTORY_EXT));
@@ -121,9 +123,10 @@
strcat(fn, ".A");
fn[strlen(fn)-1]+=i;
if (0 != UNLINK(fn))
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Could not unlink temporary file `%s': %s\n"),
- fn, STRERROR(errno));
+ GE_LOG(this->ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Could not unlink temporary file `%s': %s\n"),
+ fn, STRERROR(errno));
FREE(fn);
}
}
@@ -139,16 +142,18 @@
* @param filename the name of the level-0 file
* @return OK on success, SYSERR on failure
*/
-static int createIOContext(IOContext * this,
+static int createIOContext(struct GE_Context * ectx,
+ IOContext * this,
unsigned long long filesize,
const char * filename) {
int i;
char * fn;
struct stat st;
+ this->ectx = ectx;
GE_ASSERT(ectx, filename != NULL);
this->treedepth = computeDepth(filesize);
- MUTEX_CREATE(&this->lock);
+ this->lock = MUTEX_CREATE(NO);
this->handles = MALLOC(sizeof(int) * (this->treedepth+1));
this->filename = STRDUP(filename);
@@ -156,9 +161,10 @@
((size_t)st.st_size > filesize ) ) {
/* if exists and oversized, truncate */
if (truncate(filename, filesize) != 0) {
- GE_LOG_STRERROR_FILE(ectx,LOG_FAILURE,
- "truncate",
- filename);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_ADMIN | GE_BULK,
+ "truncate",
+ filename);
return SYSERR;
}
}
@@ -176,13 +182,11 @@
strcat(fn, ".A");
fn[strlen(fn)-1] += i;
}
- this->handles[i] = fileopen(fn,
- O_CREAT|O_RDWR,
- S_IRUSR|S_IWUSR );
+ this->handles[i] = disk_file_open(ectx,
+ fn,
+ O_CREAT|O_RDWR,
+ S_IRUSR|S_IWUSR );
if (this->handles[i] < 0) {
- GE_LOG_STRERROR_FILE(ectx,LOG_FAILURE,
- "open",
- fn);
freeIOC(this, NO);
FREE(fn);
return SYSERR;
@@ -209,21 +213,22 @@
unsigned int len) {
int ret;
- MUTEX_LOCK(&this->lock);
+ MUTEX_LOCK(this->lock);
lseek(this->handles[level],
pos,
SEEK_SET);
ret = READ(this->handles[level],
buf,
len);
- MUTEX_UNLOCK(&this->lock);
+ MUTEX_UNLOCK(this->lock);
#ifdef DEBUG_DOWNLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "IOC read at level %u offset %llu wanted %u got %d\n",
- level,
- pos,
- len,
- ret);
+ GE_LOG(this->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "IOC read at level %u offset %llu wanted %u got %d\n",
+ level,
+ pos,
+ len,
+ ret);
#endif
return ret;
}
@@ -245,7 +250,7 @@
unsigned int len) {
int ret;
- MUTEX_LOCK(&this->lock);
+ MUTEX_LOCK(this->lock);
lseek(this->handles[level],
pos,
SEEK_SET);
@@ -253,20 +258,22 @@
buf,
len);
if (ret != len) {
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Write(%d, %p, %d) failed: %s\n"),
- this->handles[level],
- buf,
- len,
- STRERROR(errno));
+ GE_LOG(this->ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Write(%d, %p, %d) failed: %s\n"),
+ this->handles[level],
+ buf,
+ len,
+ STRERROR(errno));
}
- MUTEX_UNLOCK(&this->lock);
+ MUTEX_UNLOCK(this->lock);
#ifdef DEBUG_DOWNLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "IOC write at level %u offset %llu writes %u\n",
- level,
- pos,
- len);
+ GE_LOG(this->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "IOC write at level %u offset %llu writes %u\n",
+ level,
+ pos,
+ len);
#endif
return ret;
}
@@ -319,6 +326,12 @@
NodeClosure * node;
/**
+ * Search handle of the last request (NULL if never
+ * requested).
+ */
+ struct FS_SEARCH_HANDLE * searchHandle;
+
+ /**
* Last time the query was send.
*/
cron_t lasttime;
@@ -340,12 +353,6 @@
*/
unsigned int lastPriority;
- /**
- * Search handle of the last request (NULL if never
- * requested).
- */
- struct FS_SEARCH_HANDLE * searchHandle;
-
} RequestEntry;
/**
@@ -361,13 +368,21 @@
/**
* Mutex for synchronizing access to this struct
*/
- Mutex lock;
+ struct MUTEX * lock;
/**
* Current list of all pending requests
*/
RequestEntry ** requestList;
+ struct FS_SEARCH_CONTEXT * sctx;
+
+ struct PTHREAD * requestThread;
+
+ struct GE_Context * ectx;
+
+ struct GC_Configuration * cfg;
+
/**
* Number of pending requests (highest used index)
*/
@@ -405,10 +420,6 @@
*/
int abortFlag;
- struct FS_SEARCH_CONTEXT * sctx;
-
- PTHREAD_T requestThread;
-
} RequestManager;
static int nodeReceive(const HashCode512 * query,
@@ -422,17 +433,26 @@
*
* @return NULL on error
*/
-static RequestManager * createRequestManager() {
+static RequestManager * createRequestManager(struct GE_Context * ectx,
+ struct GC_Configuration * cfg) {
RequestManager * rm;
rm = MALLOC(sizeof(RequestManager));
- PTHREAD_GET_SELF(&rm->requestThread);
+ rm->ectx
+ = ectx;
+ rm->cfg
+ = cfg;
+ rm->requestThread
+ = PTHREAD_GET_SELF();
rm->abortFlag
= NO;
rm->lastDET
= 0;
- MUTEX_CREATE_RECURSIVE(&rm->lock);
- rm->sctx = FS_SEARCH_makeContext(&rm->lock);
+ rm->lock
+ = MUTEX_CREATE(YES);
+ rm->sctx = FS_SEARCH_makeContext(ectx,
+ cfg,
+ rm->lock);
rm->requestListIndex
= 0;
rm->requestListSize
@@ -455,9 +475,10 @@
rm->ssthresh
= 65535;
#ifdef DEBUG_DOWNLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "created request manager %p\n",
- rm);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "created request manager %p\n",
+ rm);
#endif
return rm;
}
@@ -473,11 +494,12 @@
int i;
#ifdef DEBUG_DOWNLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "destroying request manager %p\n",
- rm);
+ GE_LOG(rm->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "destroying request manager %p\n",
+ rm);
#endif
- MUTEX_LOCK(&rm->lock);
+ MUTEX_LOCK(rm->lock);
for (i=0;i<rm->requestListIndex;i++) {
if (rm->requestList[i]->searchHandle != NULL)
FS_stop_search(rm->sctx,
@@ -488,10 +510,10 @@
GROW(rm->requestList,
rm->requestListSize,
0);
- MUTEX_UNLOCK(&rm->lock);
+ MUTEX_UNLOCK(rm->lock);
FS_SEARCH_destroyContext(rm->sctx);
- MUTEX_DESTROY(&rm->lock);
- PTHREAD_REL_SELF(&rm->requestThread);
+ MUTEX_DESTROY(rm->lock);
+ PTHREAD_REL_SELF(rm->requestThread);
FREE(rm);
}
@@ -502,14 +524,14 @@
static void requestManagerEndgame(RequestManager * rm) {
int i;
- MUTEX_LOCK(&rm->lock);
+ MUTEX_LOCK(rm->lock);
for (i=0;i<rm->requestListIndex;i++) {
RequestEntry * entry = rm->requestList[i];
/* cut TTL in half */
entry->lasttime
+= (entry->lasttime + entry->lastTimeout) / 2;
}
- MUTEX_UNLOCK(&rm->lock);
+ MUTEX_UNLOCK(rm->lock);
}
/**
@@ -524,15 +546,18 @@
#if DEBUG_DOWNLOAD
EncName enc;
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&node->chk.query,
- &enc));
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Queuing request (query: %s)\n",
- &enc);
+ IF_GELOG(rm->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&node->chk.query,
+ &enc));
+ GE_LOG(rm->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Queuing request (query: %s)\n",
+ &enc);
#endif
- GE_ASSERT(ectx, node != NULL);
+ GE_ASSERT(rm->ectx,
+ node != NULL);
entry
= MALLOC(sizeof(RequestEntry));
entry->node
@@ -547,14 +572,15 @@
= 0;
entry->searchHandle
= NULL;
- MUTEX_LOCK(&rm->lock);
- GE_ASSERT(ectx, rm->requestListSize > 0);
+ MUTEX_LOCK(rm->lock);
+ GE_ASSERT(rm->ectx,
+ rm->requestListSize > 0);
if (rm->requestListSize == rm->requestListIndex)
GROW(rm->requestList,
rm->requestListSize,
rm->requestListSize*2);
rm->requestList[rm->requestListIndex++] = entry;
- MUTEX_UNLOCK(&rm->lock);
+ MUTEX_UNLOCK(rm->lock);
}
@@ -569,7 +595,7 @@
int i;
RequestEntry * re;
- MUTEX_LOCK(&rm->lock);
+ MUTEX_LOCK(rm->lock);
for (i=0;i<rm->requestListIndex;i++) {
re = rm->requestList[i];
if (re->node == node) {
@@ -577,7 +603,7 @@
= rm->requestList[--rm->requestListIndex];
rm->requestList[rm->requestListIndex]
= NULL;
- MUTEX_UNLOCK(&rm->lock);
+ MUTEX_UNLOCK(rm->lock);
if (NULL != re->searchHandle)
FS_stop_search(rm->sctx,
re->searchHandle);
@@ -585,8 +611,8 @@
return;
}
}
- MUTEX_UNLOCK(&rm->lock);
- GE_BREAK(ectx, 0); /* uh uh - at least a memory leak... */
+ MUTEX_UNLOCK(rm->lock);
+ GE_BREAK(rm->ectx, 0); /* uh uh - at least a memory leak... */
}
@@ -597,15 +623,15 @@
* Design Question: integrate with IOContext?
*/
typedef struct CommonCtx {
+ unsigned long long total;
+ unsigned long long completed;
+ cron_t startTime;
+ cron_t TTL_DECREMENT;
RequestManager * rm;
IOContext * ioc;
- unsigned long long total;
- unsigned long long completed;
ECRS_DownloadProgressCallback dpcb;
void * dpcbClosure;
- cron_t startTime;
unsigned int anonymityLevel;
- cron_t TTL_DECREMENT;
} CommonCtx;
/**
@@ -619,15 +645,17 @@
unsigned long long spos;
unsigned long long epos;
- GE_ASSERT(ectx, node->offset < node->ctx->total);
+ GE_ASSERT(node->ctx->rm->ectx,
+ node->offset < node->ctx->total);
if (node->level == 0) {
ret = DBLOCK_SIZE;
if (node->offset + (unsigned long long) ret
> node->ctx->total)
ret = (unsigned int) (node->ctx->total - node->offset);
#if DEBUG_DOWNLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Node at offset %llu and level %d has size %u\n",
+ GE_LOG(node->ctx->rm->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Node at offset %llu and level %d has size %u\n",
node->offset,
node->level,
ret);
@@ -645,11 +673,12 @@
if (ret * rsize < epos - spos)
ret++; /* need to round up! */
#if DEBUG_DOWNLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Node at offset %llu and level %d has size %u\n",
- node->offset,
- node->level,
- ret * sizeof(CHK));
+ GE_LOG(node->ctx->rm->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Node at offset %llu and level %d has size %u\n",
+ node->offset,
+ node->level,
+ ret * sizeof(CHK));
#endif
return ret * sizeof(CHK);
}
@@ -671,7 +700,7 @@
cron_t eta;
node->ctx->completed += size;
- cronTime(&eta); /* now */
+ eta = get_time();
if (node->ctx->completed > 0) {
eta = (cron_t) (node->ctx->startTime +
(((double)(eta -
node->ctx->startTime)/(double)node->ctx->completed))
@@ -794,11 +823,12 @@
ret = NO;
FREE(data);
#ifdef DEBUG_DOWNLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Checked presence of block at %llu level %u. Result: %s\n",
- node->offset,
- node->level,
- ret == YES ? "YES" : "NO");
+ GE_LOG(node->ctx->rm->ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Checked presence of block at %llu level %u. Result: %s\n",
+ node->offset,
+ node->level,
+ ret == YES ? "YES" : "NO");
#endif
return ret;
@@ -812,6 +842,7 @@
static void iblock_download_children(NodeClosure * node,
char * data,
unsigned int size) {
+ struct GE_Context * ectx = node->ctx->rm->ectx;
int i;
NodeClosure * child;
unsigned int childcount;
@@ -819,7 +850,8 @@
unsigned int levelSize;
unsigned long long baseOffset;
- GE_ASSERT(ectx, node->level > 0);
+ GE_ASSERT(ectx,
+ node->level > 0);
childcount = size / sizeof(CHK);
if (size != childcount * sizeof(CHK)) {
GE_BREAK(ectx, 0);
@@ -867,7 +899,8 @@
INITVECTOR iv;
SESSIONKEY skey;
- GE_ASSERT(ectx, (data!=NULL) && (hashcode != NULL) && (result != NULL));
+ GE_ASSERT(NULL,
+ (data!=NULL) && (hashcode != NULL) && (result != NULL));
/* get key and init value from the hash code */
hashToKey(hashcode,
&skey,
@@ -892,6 +925,7 @@
static int nodeReceive(const HashCode512 * query,
const Datastore_Value * reply,
NodeClosure * node) {
+ struct GE_Context * ectx = node->ctx->rm->ectx;
HashCode512 hc;
unsigned int size;
int i;
@@ -899,16 +933,19 @@
#if DEBUG_DOWNLOAD
EncName enc;
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(query,
- &enc));
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Receiving reply to query `%s'\n",
- &enc);
+ IF_GELOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(query,
+ &enc));
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Receiving reply to query `%s'\n",
+ &enc);
#endif
- GE_ASSERT(ectx, equalsHashCode512(query,
- &node->chk.query));
+ GE_ASSERT(ectx,
+ equalsHashCode512(query,
+ &node->chk.query));
size = ntohl(reply->size) - sizeof(Datastore_Value);
if ( (size <= sizeof(DBlock)) ||
(size - sizeof(DBlock) != getNodeSize(node)) ) {
@@ -943,7 +980,9 @@
node->offset,
data,
size)) {
- LOG_STRERROR(LOG_ERROR, "WRITE");
+ GE_LOG_STRERROR(ectx,
+ GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
+ "WRITE");
node->ctx->rm->abortFlag = YES;
return SYSERR;
}
@@ -967,8 +1006,7 @@
requestManagerEndgame(node->ctx->rm);
}
}
- PTHREAD_KILL(&node->ctx->rm->requestThread,
- SIGALRM);
+ PTHREAD_STOP_SLEEP(node->ctx->rm->requestThread);
FREE(data);
FREE(node);
return OK;
@@ -997,7 +1035,7 @@
EncName enc;
#endif
- cronTime(&now);
+ now = get_time();
entry = rm->requestList[requestIndex];
/* compute priority */
@@ -1006,10 +1044,11 @@
10 seconds */
struct ClientServerConnection * sock;
- sock = getClientSocket();
+ sock = client_connection_create(rm->ectx,
+ rm->cfg);
lastmpriority = FS_getAveragePriority(sock);
lastmpritime = now;
- releaseClientSocket(sock);
+ connection_destroy(sock);
}
mpriority = lastmpriority;
priority
@@ -1031,7 +1070,7 @@
= entry->node->ctx->TTL_DECREMENT;
if (entry->lastTimeout + TTL_DECREMENT > now)
- GE_BREAK(ectx, 0);
+ GE_BREAK(rm->ectx, 0);
if (entry->lasttime == 0) {
timeout = now + rm->initialTTL;
} else {
@@ -1105,13 +1144,15 @@
if ( (0 == (entry->tries % MAX_TRIES)) &&
(entry->tries > 0) ) {
EncName enc;
- IF_GELOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- hash2enc(&entry->node->chk.key,
- &enc));
- GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
- _("Content `%s' seems to be not available on the network (tried %u
times).\n"),
- &enc,
- entry->tries);
+ IF_GELOG(rm->ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ hash2enc(&entry->node->chk.key,
+ &enc));
+ GE_LOG(rm->ectx,
+ GE_WARNING | GE_BULK | GE_USER,
+ _("Content `%s' seems to be not available on the network (tried %u
times).\n"),
+ &enc,
+ entry->tries);
}
}
@@ -1129,12 +1170,12 @@
int * perm;
unsigned int TTL_DECREMENT;
- MUTEX_LOCK(&rm->lock);
+ MUTEX_LOCK(rm->lock);
if (rm->requestListIndex == 0) {
- MUTEX_UNLOCK(&rm->lock);
+ MUTEX_UNLOCK(rm->lock);
return 0;
}
- cronTime(&now);
+ now = get_time();
pending = 0;
TTL_DECREMENT = 0;
if (rm->requestListIndex > 0)
@@ -1182,7 +1223,7 @@
FREE(perm);
if (minSleep < cronMILLIS * 100)
minSleep = cronMILLIS * 100; /* maximum resolution: 100ms */
- MUTEX_UNLOCK(&rm->lock);
+ MUTEX_UNLOCK(rm->lock);
return minSleep;
}
@@ -1196,7 +1237,9 @@
* @param uri the URI of the file (determines what to download)
* @param filename where to store the file
*/
-int ECRS_downloadFile(const struct ECRS_URI * uri,
+int ECRS_downloadFile(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
const char * filename,
unsigned int anonymityLevel,
ECRS_DownloadProgressCallback dpcb,
@@ -1218,11 +1261,12 @@
filename);
#endif
if (0 == ECRS_fileSize(uri)) {
- ret = fileopen(filename, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR|S_IWUSR);
- if (ret == -1) {
- GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "open", filename);
- return SYSERR;
- }
+ ret = disk_file_open(ectx,
+ filename,
+ O_CREAT | O_WRONLY | O_TRUNC,
+ S_IRUSR|S_IWUSR);
+ if (ret == -1)
+ return SYSERR;
CLOSE(ret);
dpcb(0, 0, get_time(), 0, NULL, 0, dpcbClosure);
return OK;
@@ -1234,7 +1278,8 @@
return SYSERR;
}
- if (OK != createIOContext(&ioc,
+ if (OK != createIOContext(ectx,
+ &ioc,
ntohll(fid.file_length),
filename)) {
#if DEBUG_DOWNLOAD
@@ -1245,9 +1290,10 @@
#endif
return SYSERR;
}
- rm = createRequestManager();
+ rm = createRequestManager(ectx,
+ cfg);
- cronTime(&ctx.startTime);
+ ctx.startTime = get_time();
ctx.anonymityLevel = anonymityLevel;
ctx.TTL_DECREMENT = 5 * cronSECONDS; /* HACK! */
ctx.rm = rm;
Modified: GNUnet/src/applications/fs/ecrs/ecrs.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrs.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/ecrs.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+ (C) 2004, 2005. 2006 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -38,12 +38,13 @@
hashToKey(hc, &skey, &iv);
tmp = MALLOC(len);
- GE_ASSERT(ectx, len ==
- encryptBlock(data,
- len,
- &skey,
- &iv,
- tmp));
+ GE_ASSERT(NULL,
+ len ==
+ encryptBlock(data,
+ len,
+ &skey,
+ &iv,
+ tmp));
memcpy(data, tmp, len);
FREE(tmp);
}
@@ -57,12 +58,13 @@
hashToKey(hc, &skey, &iv);
tmp = MALLOC(len);
- GE_ASSERT(ectx, len ==
- decryptBlock(&skey,
- data,
- len,
- &iv,
- tmp));
+ GE_ASSERT(NULL,
+ len ==
+ decryptBlock(&skey,
+ data,
+ len,
+ &iv,
+ tmp));
memcpy(data, tmp, len);
FREE(tmp);
}
Modified: GNUnet/src/applications/fs/ecrs/ecrstest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/ecrstest.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/ecrstest.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -293,7 +293,7 @@
/* END OF TEST CODE */
FAILURE:
if (sock != NULL)
- releaseClientSocket(sock);
+ connection_destroy(sock);
stopCron();
GE_ASSERT(ectx, OK == stopGNUnetDaemon());
GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
Modified: GNUnet/src/applications/fs/ecrs/indexinfo.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/indexinfo.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/indexinfo.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2005 Christian Grothoff (and other contributing authors)
+ (C) 2005, 2006 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -38,24 +38,28 @@
* in either case, if SYSERR is returned the user should probably
* be notified that 'something is wrong')
*/
-int ECRS_isFileIndexed(const char * filename) {
+int ECRS_isFileIndexed(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * filename) {
HashCode512 hc;
struct ClientServerConnection * sock;
int ret;
- if (SYSERR == getFileHash(filename,
+ if (SYSERR == getFileHash(ectx,
+ filename,
&hc))
return SYSERR;
- sock = getClientSocket();
+ sock = client_connection_create(ectx, cfg);
if (sock == NULL)
return SYSERR;
ret = FS_testIndexed(sock,
&hc);
- releaseClientSocket(sock);
+ connection_destroy(sock);
return ret;
}
struct iiC {
+ struct GE_Context * ectx;
ECRS_FileIterator iterator;
void * closure;
int cnt;
@@ -93,9 +97,10 @@
continue;
}
if (errno != EINVAL) {
- GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
- "readlink",
- fullName);
+ GE_LOG_STRERROR_FILE(cls->ectx,
+ GE_WARNING | GE_BULK | GE_ADMIN | GE_USER,
+ "readlink",
+ fullName);
}
FREE(lnkName);
FREE(fullName);
@@ -130,31 +135,35 @@
*
* @return number of files indexed, SYSERR if iterator aborted
*/
-int ECRS_iterateIndexedFiles(ECRS_FileIterator iterator,
+int ECRS_iterateIndexedFiles(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ ECRS_FileIterator iterator,
void * closure) {
char * tmp;
char * indexDirectory;
struct ClientServerConnection * sock;
struct iiC cls;
- sock = getClientSocket();
+ sock = client_connection_create(ectx, cfg);
if (sock == NULL)
return 0;
tmp = getConfigurationOptionValue(sock,
"FS",
"INDEX-DIRECTORY");
- releaseClientSocket(sock);
+ connection_destroy(sock);
if (tmp == NULL) {
return 0;
}
- indexDirectory = expandFileName(tmp);
+ indexDirectory = string_expandFileName(ectx, tmp);
FREE(tmp);
+ cls.ectx = ectx;
cls.iterator = iterator;
cls.closure = closure;
cls.cnt = 0;
- scanDirectory(indexDirectory,
- &iiHelper,
- &cls);
+ disk_directory_scan(ectx,
+ indexDirectory,
+ &iiHelper,
+ &cls);
FREE(indexDirectory);
return cls.cnt;
}
Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other
contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other
contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -49,7 +49,8 @@
*
* @return SYSERR if the entry is malformed
*/
-static int verifyKBlock(const HashCode512 * key,
+static int verifyKBlock(struct GE_Context * ectx,
+ const HashCode512 * key,
Datastore_Value * value) {
unsigned int type;
ECRS_FileInfo fi;
@@ -57,7 +58,6 @@
HashCode512 query;
KBlock * kb;
const char * dstURI;
- EncName enc;
int j;
type = ntohl(value->type);
@@ -72,9 +72,6 @@
if (size < sizeof(KBlock))
return SYSERR;
kb = (KBlock*) &value[1];
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(key,
- &enc));
ECRS_decryptInPlace(key,
&kb[1],
size - sizeof(KBlock));
@@ -83,18 +80,20 @@
(((const char*)kb)[j] != '\0') )
j++;
if (j == size) {
- GE_BREAK(ectx, 0); /* kblock malformed */
+ GE_BREAK(NULL, 0); /* kblock malformed */
return SYSERR;
}
dstURI = (const char*) &kb[1];
j++;
- fi.meta = ECRS_deserializeMetaData(&((const char*)kb)[j],
+ fi.meta = ECRS_deserializeMetaData(ectx,
+ &((const char*)kb)[j],
size - j);
if (fi.meta == NULL) {
GE_BREAK(ectx, 0); /* kblock malformed */
return SYSERR;
}
- fi.uri = ECRS_stringToUri(dstURI);
+ fi.uri = ECRS_stringToUri(ectx,
+ dstURI);
if (fi.uri == NULL) {
GE_BREAK(ectx, 0); /* kblock malformed */
ECRS_freeMetaData(fi.meta);
@@ -117,7 +116,9 @@
* @param md what meta-data should be associated with the
* entry?
*/
-int ECRS_addToKeyspace(const struct ECRS_URI * uri,
+int ECRS_addToKeyspace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
unsigned int anonymityLevel,
unsigned int priority,
cron_t expirationTime,
@@ -161,7 +162,8 @@
dstURI,
strlen(dstURI)+1);
mdsize = size - sizeof(KBlock) - strlen(dstURI) - 1;
- mdsize = ECRS_serializeMetaData(md,
+ mdsize = ECRS_serializeMetaData(ectx,
+ md,
&((char*)&kb[1])[strlen(dstURI)+1],
mdsize,
ECRS_SERIALIZE_PART);
@@ -179,23 +181,26 @@
memcpy(&kb[1],
dstURI,
strlen(dstURI)+1);
- GE_ASSERT(ectx, mdsize ==
- ECRS_serializeMetaData(md,
- &((char*)&kb[1])[strlen(dstURI)+1],
- mdsize,
- ECRS_SERIALIZE_FULL));
+ GE_ASSERT(ectx,
+ mdsize ==
+ ECRS_serializeMetaData(ectx,
+ md,
+ &((char*)&kb[1])[strlen(dstURI)+1],
+ mdsize,
+ ECRS_SERIALIZE_FULL));
}
value->size = htonl(sizeof(Datastore_Value) + size);
value->type = htonl(K_BLOCK);
value->prio = htonl(priority);
value->anonymityLevel = htonl(anonymityLevel);
value->expirationTime = htonll(expirationTime);
- sock = getClientSocket();
+ sock = client_connection_create(ectx, cfg);
ret = OK;
- if (testConfigurationString("FS",
- "DISABLE-CREATION-TIME",
- "YES"))
+ if (GC_get_configuration_value_yesno(cfg,
+ "FS",
+ "DISABLE-CREATION-TIME",
+ NO) == YES)
xuri = ECRS_dupUri(uri);
else
xuri = ECRS_dateExpandKeywordUri(uri);
@@ -239,13 +244,16 @@
if (OK != FS_insert(sock, value))
ret = SYSERR;
#if EXTRA_CHECKS
- GE_ASSERT(ectx, OK == verifyKBlock(&key, value))
+ GE_ASSERT(ectx,
+ OK == verifyKBlock(ectx,
+ &key,
+ value))
#endif
}
ECRS_freeUri(xuri);
FREE(cpy);
FREE(dstURI);
- releaseClientSocket(sock);
+ connection_destroy(sock);
FREE(value);
return ret;
}
Modified: GNUnet/src/applications/fs/ecrs/meta.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/meta.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/meta.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -81,7 +81,7 @@
const char * data) {
int idx;
- GE_ASSERT(ectx, data != NULL);
+ GE_ASSERT(NULL, data != NULL);
for (idx=0;idx<md->itemCount;idx++) {
if ( (md->items[idx].type == type) &&
(0 == strcmp(md->items[idx].data,
@@ -291,7 +291,8 @@
* @return SYSERR on error, otherwise the number
* of meta-data items obtained
*/
-int ECRS_extractMetaData(MetaData * md,
+int ECRS_extractMetaData(struct GE_Context * ectx,
+ MetaData * md,
const char * filename,
EXTRACTOR_ExtractorList * extractors) {
EXTRACTOR_KeywordList * head;
@@ -419,7 +420,8 @@
* SYSERR on error (typically: not enough
* space)
*/
-int ECRS_serializeMetaData(const MetaData * md,
+int ECRS_serializeMetaData(struct GE_Context * ectx,
+ const MetaData * md,
char * target,
unsigned int max,
int part) {
@@ -490,7 +492,8 @@
#if EXTRA_CHECKS
{
MetaData * mdx;
- mdx = ECRS_deserializeMetaData(target,
+ mdx = ECRS_deserializeMetaData(ectx,
+ target,
size);
GE_ASSERT(ectx, NULL != mdx);
ECRS_freeMetaData(mdx);
@@ -555,7 +558,8 @@
* bad format)
*/
struct ECRS_MetaData *
-ECRS_deserializeMetaData(const char * input,
+ECRS_deserializeMetaData(struct GE_Context * ectx,
+ const char * input,
unsigned int size) {
MetaData * md;
const MetaDataHeader * hdr;
@@ -723,7 +727,8 @@
* renaming).
* @return the new filename
*/
-char * ECRS_suggestFilename(const char * filename) {
+char * ECRS_suggestFilename(struct GE_Context * ectx,
+ const char * filename) {
EXTRACTOR_ExtractorList * l;
EXTRACTOR_KeywordList * list;
const char * key;
Modified: GNUnet/src/applications/fs/ecrs/namespace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/namespace.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/namespace.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+ (C) 2004, 2005, 2006 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -25,6 +25,7 @@
*/
#include "platform.h"
+#include "gnunet_directories.h"
#include "gnunet_protocols.h"
#include "gnunet_ecrs_lib.h"
#include "gnunet_fs_lib.h"
@@ -36,20 +37,26 @@
#define MAX_NBLOCK_SIZE 32000
#define MAX_SBLOCK_SIZE 32000
-static char * getPseudonymFileName(const char * name) {
+static char * getPseudonymFileName(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * name) {
char * gnHome;
char * fileName;
-
- gnHome = getFileName("GNUNET",
- "GNUNET_HOME",
- _("Configuration file must specify a directory for"
- " GNUnet to store per-peer data under %s%s.\n"));
+
+ GC_get_configuration_value_string(cfg,
+ "GNUNET",
+ "GNUNET_HOME",
+ GNUNET_HOME_DIRECTORY,
+ &fileName);
+ gnHome = string_expandFileName(ectx, fileName);
+ FREE(fileName);
fileName = MALLOC(strlen(gnHome) + strlen(PSEUDODIR) + strlen(name) + 2);
strcpy(fileName, gnHome);
FREE(gnHome);
strcat(fileName, "/");
strcat(fileName, PSEUDODIR);
- mkdirp(fileName);
+ disk_directory_create(ectx,
+ fileName);
strcat(fileName, name);
return fileName;
}
@@ -59,12 +66,17 @@
*
* @return OK on success, SYSERR on error
*/
-int ECRS_deleteNamespace(const char * name) {
+int ECRS_deleteNamespace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * name) {
char * fileName;
- fileName = getPseudonymFileName(name);
+ fileName = getPseudonymFileName(ectx, cfg, name);
if (0 != UNLINK(fileName)) {
- GE_LOG_STRERROR_FILE(ectx,LOG_EVERYTHING, "unlink", fileName);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_WARNING | GE_USER | GE_BULK,
+ "unlink",
+ fileName);
FREE(fileName);
return SYSERR;
} else {
@@ -94,7 +106,9 @@
* @return OK on success, SYSERR on error (namespace already exists)
*/
struct ECRS_URI *
-ECRS_createNamespace(const char * name,
+ECRS_createNamespace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * name,
const struct ECRS_MetaData * meta,
unsigned int anonymityLevel,
unsigned int priority,
@@ -127,12 +141,18 @@
GE_BREAK(ectx, 0);
return NULL;
}
- fileName = getPseudonymFileName(name);
- if (1 == readFile(fileName, 1, &tmp)) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Cannot create pseudonym `%s', file `%s' exists.\n"),
- name,
- fileName);
+ fileName = getPseudonymFileName(ectx,
+ cfg,
+ name);
+ if (1 == disk_file_read(ectx,
+ fileName,
+ 1,
+ &tmp)) {
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Cannot create pseudonym `%s', file `%s' exists.\n"),
+ name,
+ fileName);
FREE(fileName);
return NULL;
}
@@ -140,10 +160,11 @@
hke = encodePrivateKey(hk);
len = ntohs(hke->len);
dst = (char*) hke;
- writeFile(fileName,
- dst,
- len,
- "600");
+ disk_file_write(ectx,
+ fileName,
+ dst,
+ len,
+ "600");
FREE(fileName);
FREE(dst);
@@ -159,13 +180,16 @@
nb = (NBlock*) &value[1];
nb->type = htonl(N_BLOCK);
mdsize = size - sizeof(NBlock);
- mdsize = ECRS_serializeMetaData(meta,
+ mdsize = ECRS_serializeMetaData(ectx,
+ meta,
(char*)&nb[1],
mdsize,
ECRS_SERIALIZE_PART);
if (mdsize == -1) {
GE_BREAK(ectx, 0);
- ECRS_deleteNamespace(name);
+ ECRS_deleteNamespace(ectx,
+ cfg,
+ name);
freePrivateKey(hk);
return NULL;
}
@@ -175,7 +199,8 @@
size);
nb = (NBlock*) &value[1];
nb->type = htonl(N_BLOCK);
- ECRS_serializeMetaData(meta,
+ ECRS_serializeMetaData(ectx,
+ meta,
(char*)&nb[1],
mdsize,
ECRS_SERIALIZE_FULL);
@@ -185,7 +210,7 @@
value->prio = htonl(priority);
value->anonymityLevel = htonl(anonymityLevel);
value->expirationTime = htonll(expiration);
- sock = getClientSocket();
+ sock = client_connection_create(ectx, cfg);
/* publish NBlock */
memset(&nb->identifier, 0, sizeof(HashCode512));
@@ -208,9 +233,9 @@
if (OK != FS_insert(sock, value)) {
FREE(rootURI);
FREE(value);
- releaseClientSocket(sock);
+ connection_destroy(sock);
freePrivateKey(hk);
- ECRS_deleteNamespace(name);
+ ECRS_deleteNamespace(ectx, cfg, name);
return NULL;
}
@@ -255,11 +280,11 @@
freePrivateKey(pk);
if (OK != FS_insert(sock, knvalue)) {
FREE(rootURI);
- ECRS_deleteNamespace(name);
+ ECRS_deleteNamespace(ectx, cfg, name);
FREE(cpy);
FREE(knvalue);
FREE(value);
- releaseClientSocket(sock);
+ connection_destroy(sock);
freePrivateKey(hk);
return NULL;
}
@@ -272,7 +297,7 @@
}
FREE(knvalue);
FREE(value);
- releaseClientSocket(sock);
+ connection_destroy(sock);
freePrivateKey(hk);
return rootURI;
@@ -285,7 +310,9 @@
* hc of the public key
* @return OK if the namespace exists, SYSERR if not
*/
-int ECRS_testNamespaceExists(const char * name,
+int ECRS_testNamespaceExists(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * name,
const HashCode512 * hc) {
struct PrivateKey * hk;
char * fileName;
@@ -296,9 +323,13 @@
PublicKey pk;
/* FIRST: read and decrypt pseudonym! */
- fileName = getPseudonymFileName(name);
- if (OK != getFileSize(fileName,
- &len)) {
+ fileName = getPseudonymFileName(ectx,
+ cfg,
+ name);
+ if (OK != disk_file_size(ectx,
+ fileName,
+ &len,
+ YES)) {
FREE(fileName);
return SYSERR;
}
@@ -310,13 +341,14 @@
return SYSERR;
}
dst = MALLOC(len);
- len = readFile(fileName, len, dst);
+ len = disk_file_read(ectx, fileName, len, dst);
FREE(fileName);
hke = (PrivateKeyEncoded*) dst;
if ( ntohs(hke->len) != len ) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Format of pseudonym `%s' is invalid.\n"),
- name);
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Format of pseudonym `%s' is invalid.\n"),
+ name);
FREE(hke);
return SYSERR;
}
@@ -346,7 +378,9 @@
* entry?
*/
struct ECRS_URI *
-ECRS_addToNamespace(const char * name,
+ECRS_addToNamespace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * name,
unsigned int anonymityLevel,
unsigned int priority,
cron_t expiration,
@@ -372,9 +406,11 @@
HashCode512 hc;
/* FIRST: read pseudonym! */
- fileName = getPseudonymFileName(name);
- if (OK != getFileSize(fileName,
- &len)) {
+ fileName = getPseudonymFileName(ectx, cfg, name);
+ if (OK != disk_file_size(ectx,
+ fileName,
+ &len,
+ YES)) {
FREE(fileName);
return NULL;
}
@@ -386,7 +422,7 @@
return NULL;
}
dst = MALLOC(len);
- len = readFile(fileName, len, dst);
+ len = disk_file_read(ectx, fileName, len, dst);
FREE(fileName);
hke = (PrivateKeyEncoded*) dst;
if ( ntohs(hke->len) != len ) {
@@ -416,7 +452,8 @@
dstURI,
strlen(dstURI) + 1);
mdsize = size - sizeof(SBlock) - strlen(dstURI) - 1;
- mdsize = ECRS_serializeMetaData(md,
+ mdsize = ECRS_serializeMetaData(ectx,
+ md,
&((char*)&sb[1])[strlen(dstURI)+1],
mdsize,
ECRS_SERIALIZE_PART);
@@ -434,7 +471,8 @@
memcpy(&sb[1],
dstURI,
strlen(dstURI) + 1);
- ECRS_serializeMetaData(md,
+ ECRS_serializeMetaData(ectx,
+ md,
&((char*)&sb[1])[strlen(dstURI)+1],
mdsize,
ECRS_SERIALIZE_FULL);
@@ -487,12 +525,12 @@
&sb->signature));
freePrivateKey(hk);
- sock = getClientSocket();
+ sock = client_connection_create(ectx, cfg);
if (OK != FS_insert(sock, value)) {
FREE(uri);
uri = NULL;
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
FREE(value);
FREE(dstURI);
@@ -500,6 +538,8 @@
}
struct lNCLS {
+ struct GE_Context * ectx;
+ struct GC_Configuration * cfg;
ECRS_NamespaceInfoCallback cb;
void * cls;
int cnt;
@@ -517,26 +557,35 @@
HashCode512 namespace;
PublicKey pk;
- fileName = getPseudonymFileName(name);
- if (OK != getFileSize(fileName,
- &len)) {
+ fileName = getPseudonymFileName(c->ectx,
+ c->cfg,
+ name);
+ if (OK != disk_file_size(c->ectx,
+ fileName,
+ &len,
+ YES)) {
FREE(fileName);
return OK;
}
if (len < 2) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("File `%s' does not contain a pseudonym.\n"),
- fileName);
+ GE_LOG(c->ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("File `%s' does not contain a pseudonym.\n"),
+ fileName);
FREE(fileName);
return OK;
}
dst = MALLOC(len);
- len = readFile(fileName, len, dst);
+ len = disk_file_read(c->ectx,
+ fileName,
+ len,
+ dst);
hke = (PrivateKeyEncoded*) dst;
if ( ntohs(hke->len) != len ) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Format of file `%s' is invalid.\n"),
- fileName);
+ GE_LOG(c->ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Format of file `%s' is invalid.\n"),
+ fileName);
FREE(hke);
FREE(fileName);
return OK;
@@ -544,11 +593,12 @@
hk = decodePrivateKey(hke);
FREE(hke);
if (hk == NULL) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Format of file `%s' is invalid.\n"),
- fileName);
+ GE_LOG(c->ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Format of file `%s' is invalid.\n"),
+ fileName);
FREE(fileName);
- GE_BREAK(ectx, 0);
+ GE_BREAK(c->ectx, 0);
return SYSERR;
}
FREE(fileName);
@@ -574,7 +624,9 @@
* @param list where to store the names (is allocated, caller frees)
* @return SYSERR on error, otherwise the number of pseudonyms in list
*/
-int ECRS_listNamespaces(ECRS_NamespaceInfoCallback cb,
+int ECRS_listNamespaces(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ ECRS_NamespaceInfoCallback cb,
void * cls) {
char * dirName;
struct lNCLS myCLS;
@@ -582,10 +634,13 @@
myCLS.cls = cls;
myCLS.cb = cb;
myCLS.cnt = 0;
- dirName = getPseudonymFileName("");
- scanDirectory(dirName,
- &processFile_,
- &myCLS);
+ myCLS.ectx = ectx;
+ myCLS.cfg = cfg;
+ dirName = getPseudonymFileName(ectx, cfg, "");
+ disk_directory_scan(ectx,
+ dirName,
+ &processFile_,
+ &myCLS);
FREE(dirName);
return myCLS.cnt;
}
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/search.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other
contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other
contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -41,6 +41,11 @@
struct FS_SEARCH_HANDLE * handle;
/**
+ * The keys (for the search).
+ */
+ HashCode512 * keys;
+
+ /**
* When does this query time-out (we may want
* to refresh it at that point).
*/
@@ -53,6 +58,11 @@
cron_t lastTransmission;
/**
+ * The key (for decryption)
+ */
+ HashCode512 decryptKey;
+
+ /**
* With which priority does the query run?
*/
unsigned int priority;
@@ -67,16 +77,6 @@
*/
unsigned int keyCount;
- /**
- * The keys (for the search).
- */
- HashCode512 * keys;
-
- /**
- * The key (for decryption)
- */
- HashCode512 decryptKey;
-
} PendingSearch;
/**
@@ -99,11 +99,6 @@
struct FS_SEARCH_CONTEXT * sctx;
/**
- * Number of queries running at the moment.
- */
- unsigned int queryCount;
-
- /**
* queryCount pending searches.
*/
PendingSearch ** queries;
@@ -112,10 +107,19 @@
void * spcbClosure;
- int aborted;
+ struct MUTEX * lock;
- Mutex lock;
+ struct GE_Context * ectx;
+ struct GC_Configuration * cfg;
+
+ int aborted;
+
+ /**
+ * Number of queries running at the moment.
+ */
+ unsigned int queryCount;
+
} SendQueriesContext;
/**
@@ -140,12 +144,12 @@
sizeof(HashCode512) * keyCount);
ps->decryptKey = *dkey;
ps->handle = NULL;
- MUTEX_LOCK(&sqc->lock);
+ MUTEX_LOCK(sqc->lock);
GROW(sqc->queries,
sqc->queryCount,
sqc->queryCount+1);
sqc->queries[sqc->queryCount-1] = ps;
- MUTEX_UNLOCK(&sqc->lock);
+ MUTEX_UNLOCK(sqc->lock);
}
/**
@@ -154,9 +158,12 @@
*/
static void addQueryForURI(const struct ECRS_URI * uri,
SendQueriesContext * sqc) {
+ struct GE_Context * ectx = sqc->ectx;
+
switch (uri->type) {
case chk:
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
_("CHK URI not allowed for search.\n"));
break;
case sks: {
@@ -185,8 +192,9 @@
int i;
#if DEBUG_SEARCH
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Computing queries (this may take a while).\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Computing queries (this may take a while).\n");
#endif
for (i=0;i<uri->data.ksk.keywordCount;i++) {
hash(uri->data.ksk.keywords[i],
@@ -206,14 +214,16 @@
freePrivateKey(pk);
}
#if DEBUG_SEARCH
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Queries ready.\n");
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Queries ready.\n");
#endif
break;
}
case loc:
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("LOC URI not allowed for search.\n"));
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("LOC URI not allowed for search.\n"));
break;
default:
GE_BREAK(ectx, 0);
@@ -252,7 +262,7 @@
c);
return OK;
}
- GE_ASSERT(ectx, ntohl(sb->updateInterval) != 0);
+ GE_ASSERT(NULL, ntohl(sb->updateInterval) != 0);
pos = ntohl(sb->creationTime);
deltaId(&sb->identifierIncrement,
&sb->nextIdentifier,
@@ -281,11 +291,13 @@
const HashCode512 * key,
unsigned int size,
SendQueriesContext * sqc) {
+ struct GE_Context * ectx = sqc->ectx;
ECRS_FileInfo fi;
struct ECRS_URI uri;
int ret;
- fi.meta = ECRS_deserializeMetaData((const char*)&nb[1],
+ fi.meta = ECRS_deserializeMetaData(ectx,
+ (const char*)&nb[1],
size - sizeof(NBlock));
if (fi.meta == NULL) {
GE_BREAK(ectx, 0); /* nblock malformed */
@@ -315,6 +327,7 @@
static int receiveReplies(const HashCode512 * key,
const Datastore_Value * value,
SendQueriesContext * sqc) {
+ struct GE_Context * ectx = sqc->ectx;
unsigned int type;
ECRS_FileInfo fi;
int i;
@@ -381,14 +394,16 @@
}
dstURI = (const char*) &kb[1];
j++;
- fi.meta = ECRS_deserializeMetaData(&((const char*)kb)[j],
+ fi.meta = ECRS_deserializeMetaData(ectx,
+ &((const char*)kb)[j],
size - j);
if (fi.meta == NULL) {
GE_BREAK(ectx, 0); /* kblock malformed */
FREE(kb);
return SYSERR;
}
- fi.uri = ECRS_stringToUri(dstURI);
+ fi.uri = ECRS_stringToUri(ectx,
+ dstURI);
if (fi.uri == NULL) {
GE_BREAK(ectx, 0); /* kblock malformed */
ECRS_freeMetaData(fi.meta);
@@ -467,14 +482,16 @@
}
dstURI = (const char*) &sb[1];
j++;
- fi.meta = ECRS_deserializeMetaData(&dstURI[j],
+ fi.meta = ECRS_deserializeMetaData(ectx,
+ &dstURI[j],
size - j);
if (fi.meta == NULL) {
GE_BREAK(ectx, 0); /* kblock malformed */
FREE(sb);
return SYSERR;
}
- fi.uri = ECRS_stringToUri(dstURI);
+ fi.uri = ECRS_stringToUri(ectx,
+ dstURI);
if (fi.uri == NULL) {
GE_BREAK(ectx, 0); /* sblock malformed */
ECRS_freeMetaData(fi.meta);
@@ -535,7 +552,9 @@
* @param uri specifies the search parameters
* @param uri set to the URI of the uploaded file
*/
-int ECRS_search(const struct ECRS_URI * uri,
+int ECRS_search(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const struct ECRS_URI * uri,
unsigned int anonymityLevel,
cron_t timeout,
ECRS_SearchProgressCallback spcb,
@@ -550,17 +569,21 @@
cron_t new_ttl;
unsigned int new_priority;
- cronTime(&ctx.start);
- cronTime(&now);
+ ctx.start = get_time();
+ now = get_time();
timeout += now;
+ ctx.ectx = ectx;
+ ctx.cfg = cfg;
ctx.timeout = timeout;
ctx.queryCount = 0;
ctx.queries = NULL;
ctx.spcb = spcb;
ctx.spcbClosure = spcbClosure;
ctx.aborted = NO;
- MUTEX_CREATE_RECURSIVE(&ctx.lock);
- ctx.sctx = FS_SEARCH_makeContext(&ctx.lock);
+ ctx.lock = MUTEX_CREATE(YES);
+ ctx.sctx = FS_SEARCH_makeContext(ectx,
+ cfg,
+ ctx.lock);
addQueryForURI(uri,
&ctx);
while ( (OK == tt(ttClosure)) &&
@@ -568,7 +591,7 @@
(ctx.aborted == NO) ) {
remTime = timeout - now;
- MUTEX_LOCK(&ctx.lock);
+ MUTEX_LOCK(ctx.lock);
for (i=0;i<ctx.queryCount;i++) {
ps = ctx.queries[i];
if ( (now < ps->timeout) &&
@@ -610,13 +633,13 @@
(Datum_Iterator) &receiveReplies,
&ctx);
}
- MUTEX_UNLOCK(&ctx.lock);
+ MUTEX_UNLOCK(ctx.lock);
if (! ( (OK == tt(ttClosure)) &&
(timeout > now) &&
(ctx.aborted == NO) ) )
break;
PTHREAD_SLEEP(100 * cronMILLIS);
- cronTime(&now);
+ now = get_time();
}
for (i=0;i<ctx.queryCount;i++) {
if (ctx.queries[i]->handle != NULL)
@@ -629,7 +652,7 @@
ctx.queryCount,
0);
FS_SEARCH_destroyContext(ctx.sctx);
- MUTEX_DESTROY(&ctx.lock);
+ MUTEX_DESTROY(ctx.lock);
return OK;
}
Modified: GNUnet/src/applications/fs/ecrs/searchtest.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/searchtest.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/fs/ecrs/searchtest.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -169,7 +169,7 @@
/* END OF TEST CODE */
FAILURE:
if (sock != NULL)
- releaseClientSocket(sock);
+ connection_destroy(sock);
stopCron();
GE_ASSERT(ectx, OK == stopGNUnetDaemon());
GE_ASSERT(ectx, OK == waitForGNUnetDaemonTermination(daemon));
Modified: GNUnet/src/applications/fs/ecrs/tree.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/tree.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/tree.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other
contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other
contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -31,8 +31,8 @@
unsigned int treeDepth;
unsigned long long fl;
- GE_ASSERT(ectx, DBLOCK_SIZE < MAX_BUFFER_SIZE);
- GE_ASSERT(ectx, IBLOCK_SIZE < MAX_BUFFER_SIZE);
+ GE_ASSERT(NULL, DBLOCK_SIZE < MAX_BUFFER_SIZE);
+ GE_ASSERT(NULL, IBLOCK_SIZE < MAX_BUFFER_SIZE);
treeDepth = 0;
fl = DBLOCK_SIZE;
while (fl < flen) {
Modified: GNUnet/src/applications/fs/ecrs/unindex.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/unindex.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/unindex.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2003, 2004 Christian Grothoff (and other contributing authors)
+ (C) 2003, 2004, 2006 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -26,8 +26,7 @@
* Unindex file.
*
* TODO:
- * - code cleanup (share more with
- * upload.c)
+ * - code cleanup (share more with upload.c)
*/
#include "platform.h"
@@ -77,7 +76,7 @@
&ichk,
level+1,
iblocks)) {
- GE_BREAK(ectx, 0);
+ GE_BREAK(NULL, 0);
return SYSERR;
}
fileBlockEncode(db,
@@ -88,7 +87,7 @@
if (SYSERR == FS_delete(sock,
value)) {
FREE(value);
- GE_BREAK(ectx, 0);
+ GE_BREAK(NULL, 0);
return SYSERR;
}
#else
@@ -115,7 +114,8 @@
* a) check if we have a symlink
* b) delete symbolic link
*/
-static int undoSymlinking(const char * fn,
+static int undoSymlinking(struct GE_Context * ectx,
+ const char * fn,
const HashCode512 * fileId,
struct ClientServerConnection * sock) {
EncName enc;
@@ -129,7 +129,10 @@
#endif
if (0 != LSTAT(fn,
&buf)) {
- GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "stat", fn);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
+ "stat",
+ fn);
return SYSERR;
}
#ifdef S_ISLNK
@@ -155,7 +158,10 @@
(char*)&enc);
if (0 != UNLINK(serverFN)) {
- GE_LOG_STRERROR_FILE(ectx,LOG_ERROR, "unlink", serverFN);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_BULK | GE_USER | GE_ADMIN,
+ "unlink",
+ serverFN);
FREE(serverFN);
return SYSERR;
}
@@ -170,7 +176,9 @@
*
* @return SYSERR if the unindexing failed (i.e. not indexed)
*/
-int ECRS_unindexFile(const char * filename,
+int ECRS_unindexFile(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * filename,
ECRS_UploadProgressCallback upcb,
void * upcbClosure,
ECRS_TestTerminate tt,
@@ -193,31 +201,34 @@
cron_t now;
int wasIndexed;
- cronTime(&start);
- if (isDirectory(filename)) {
+ start = get_time();
+ if (disk_directory_test(ectx, filename)) {
GE_BREAK(ectx, 0);
return SYSERR;
}
- if (0 == assertIsFile(filename)) {
+ if (0 == disk_file_test(ectx, filename)) {
GE_BREAK(ectx, 0);
return SYSERR;
}
- if (OK != getFileSize(filename,
- &filesize))
+ if (OK != disk_file_size(ectx,
+ filename,
+ &filesize,
+ YES))
return SYSERR;
- sock = getClientSocket();
+ sock = client_connection_create(ectx, cfg);
if (sock == NULL)
return SYSERR;
eta = 0;
if (upcb != NULL)
upcb(filesize, 0, eta, upcbClosure);
- if (SYSERR == getFileHash(filename,
+ if (SYSERR == getFileHash(ectx,
+ filename,
&fileId)) {
- releaseClientSocket(sock);
+ connection_destroy(sock);
GE_BREAK(ectx, 0);
return SYSERR;
}
- cronTime(&now);
+ now = get_time();
eta = now + 2 * (now - start);
/* very rough estimate: hash reads once through the file,
we'll do that once more and write it. But of course
@@ -233,11 +244,11 @@
= FS_testIndexed(sock,
&fileId);
- fd = fileopen(filename, O_RDONLY | O_LARGEFILE);
- if (fd == -1) {
- GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "OPEN", filename);
- return SYSERR;
- }
+ fd = disk_file_open(ectx,
+ filename,
+ O_RDONLY | O_LARGEFILE);
+ if (fd == -1)
+ return SYSERR;
dblock = MALLOC(sizeof(Datastore_Value) + DBLOCK_SIZE + sizeof(DBlock));
dblock->size = htonl(sizeof(Datastore_Value) + DBLOCK_SIZE + sizeof(DBlock));
dblock->anonymityLevel = htonl(0);
@@ -275,9 +286,10 @@
if (size != READ(fd,
&db[1],
size)) {
- GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
- "READ",
- filename);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_USER | GE_ADMIN | GE_BULK,
+ "READ",
+ filename);
goto FAILURE;
}
if (tt != NULL)
@@ -320,7 +332,7 @@
}
}
pos += size;
- cronTime(&now);
+ now = get_time();
eta = (cron_t) (start +
(((double)(now - start)/(double)pos))
* (double)filesize);
@@ -365,7 +377,8 @@
}
if (wasIndexed) {
- if (OK == undoSymlinking(filename,
+ if (OK == undoSymlinking(ectx,
+ filename,
&fileId,
sock)) {
if (OK != FS_unindex(sock,
@@ -383,16 +396,16 @@
/* free resources */
FREE(iblocks);
FREE(dblock);
- closefile(fd);
- releaseClientSocket(sock);
+ CLOSE(fd);
+ connection_destroy(sock);
return OK;
FAILURE:
for (i=0;i<treedepth;i++)
FREENONNULL(iblocks[i]);
FREE(iblocks);
FREE(dblock);
- closefile(fd);
- releaseClientSocket(sock);
+ CLOSE(fd);
+ connection_destroy(sock);
return SYSERR;
}
Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/upload.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other
contributing authors)
+ (C) 2001, 2002, 2003, 2004, 2005, 2006 Christian Grothoff (and other
contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -61,9 +61,9 @@
#endif
size = ntohl(iblocks[level]->size);
- GE_ASSERT(ectx, size > sizeof(Datastore_Value));
+ GE_ASSERT(NULL, size > sizeof(Datastore_Value));
size -= sizeof(Datastore_Value);
- GE_ASSERT(ectx, size - sizeof(DBlock) <= IBLOCK_SIZE);
+ GE_ASSERT(NULL, size - sizeof(DBlock) <= IBLOCK_SIZE);
present = (size - sizeof(DBlock)) / sizeof(CHK);
db = (DBlock*) &iblocks[level][1];
if (present == CHK_PER_INODE) {
@@ -73,15 +73,6 @@
fileBlockGetQuery(db,
size,
&ichk.query);
-#if DEBUG_UPLOAD
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&ichk.query,
- &enc));
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Query for current iblock at level %u is %s\n",
- level,
- &enc);
-#endif
if (OK != pushBlock(sock,
&ichk,
level+1,
@@ -93,18 +84,10 @@
&ichk.query,
&value);
if (value == NULL) {
- GE_BREAK(ectx, 0);
+ GE_BREAK(NULL, 0);
return SYSERR;
}
value->prio = htonl(prio);
-#if DEBUG_UPLOAD
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&ichk.query,
- &enc));
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Publishing block (query: %s)\n",
- &enc);
-#endif
if (OK != FS_insert(sock,
value)) {
FREE(value);
@@ -118,7 +101,7 @@
chk,
sizeof(CHK));
size += sizeof(CHK) + sizeof(Datastore_Value);
- GE_ASSERT(ectx, size < MAX_BUFFER_SIZE);
+ GE_ASSERT(NULL, size < MAX_BUFFER_SIZE);
iblocks[level]->size = htonl(size);
return OK;
@@ -135,7 +118,9 @@
* @return SYSERR if the upload failed (i.e. not enough space
* or gnunetd not running)
*/
-int ECRS_uploadFile(const char * filename,
+int ECRS_uploadFile(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
+ const char * filename,
int doIndex,
unsigned int anonymityLevel,
unsigned int priority,
@@ -167,27 +152,37 @@
EncName enc;
#endif
- cronTime(&start);
+ start = get_time();
memset(&chk, 0, sizeof(CHK));
- if (isDirectory(filename)) {
+ if (disk_directory_test(ectx,
+ filename)) {
GE_BREAK(ectx, 0);
/* Should not happen */
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, "Cannot upload file `%s', it
seems to be a directory!", filename);
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ "Cannot upload file `%s', it seems to be a directory!",
+ filename);
return SYSERR;
}
- if (0 == assertIsFile(filename)) {
+ if (0 == disk_file_test(ectx,
+ filename)) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("`%s' is not a file.\n"),
filename);
return SYSERR;
}
- if (OK != getFileSize(filename,
- &filesize)) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER, _("Cannot get size of file
`%s'"), filename);
+ if (OK != disk_file_size(ectx,
+ filename,
+ &filesize,
+ YES)) {
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Cannot get size of file `%s'"),
+ filename);
return SYSERR;
}
- sock = getClientSocket();
+ sock = client_connection_create(ectx, cfg);
if (sock == NULL) {
GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("Failed to connect to gnunetd."));
@@ -197,15 +192,17 @@
if (upcb != NULL)
upcb(filesize, 0, eta, upcbClosure);
if (doIndex) {
- if (SYSERR == getFileHash(filename,
+ if (SYSERR == getFileHash(ectx,
+ filename,
&fileId)) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Cannot hash `%s'.\n"),
- filename);
- releaseClientSocket(sock);
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Cannot hash `%s'.\n"),
+ filename);
+ connection_destroy(sock);
return SYSERR;
}
- cronTime(&now);
+ now = get_time();
eta = now + 2 * (now - start);
/* very rough estimate: hash reads once through the file,
we'll do that once more and write it. But of course
@@ -217,24 +214,27 @@
switch (FS_initIndex(sock, &fileId, filename)) {
case SYSERR:
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Initialization for indexing file `%s' failed.\n"),
- filename);
- releaseClientSocket(sock);
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Initialization for indexing file `%s' failed.\n"),
+ filename);
+ connection_destroy(sock);
return SYSERR;
case NO:
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
- _("Indexing file `%s' failed. Trying to insert file...\n"),
- filename);
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Indexing file `%s' failed. Trying to insert file...\n"),
+ filename);
doIndex = YES;
}
}
treedepth = computeDepth(filesize);
-
- fd = fileopen(filename, O_RDONLY | O_LARGEFILE);
+ fd = disk_file_open(ectx,
+ filename,
+ O_RDONLY | O_LARGEFILE);
if (fd == -1) {
- GE_LOG_STRERROR_FILE(ectx,LOG_WARNING, "OPEN", filename);
- return SYSERR;
+ connection_destroy(sock);
+ return SYSERR;
}
dblock = MALLOC(sizeof(Datastore_Value) + DBLOCK_SIZE + sizeof(DBlock));
@@ -270,14 +270,16 @@
0,
DBLOCK_SIZE);
}
- GE_ASSERT(ectx, sizeof(Datastore_Value) + size + sizeof(DBlock) <
MAX_BUFFER_SIZE);
+ GE_ASSERT(ectx,
+ sizeof(Datastore_Value) + size + sizeof(DBlock) <
MAX_BUFFER_SIZE);
dblock->size = htonl(sizeof(Datastore_Value) + size + sizeof(DBlock));
if (size != READ(fd,
&db[1],
size)) {
- GE_LOG_STRERROR_FILE(ectx,LOG_WARNING,
- "READ",
- filename);
+ GE_LOG_STRERROR_FILE(ectx,
+ GE_ERROR | GE_BULK | GE_ADMIN | GE_USER,
+ "READ",
+ filename);
goto FAILURE;
}
if (tt != NULL)
@@ -290,22 +292,26 @@
size + sizeof(DBlock),
&chk.query);
#if DEBUG_UPLOAD
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&chk.query,
- &enc));
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Query for current block of size %u is %s\n",
- size,
- &enc);
+ IF_GELOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&chk.query,
+ &enc));
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Query for current block of size %u is %s\n",
+ size,
+ &enc);
#endif
if (doIndex) {
if (SYSERR == FS_index(sock,
&fileId,
dblock,
pos)) {
- GE_LOG(ectx, GE_ERROR | GE_BULK | GE_USER,
_("Indexing data failed at position %i.\n"), pos);
- goto FAILURE;
- }
+ GE_LOG(ectx,
+ GE_ERROR | GE_BULK | GE_USER,
+ _("Indexing data failed at position %i.\n"), pos);
+ goto FAILURE;
+ }
} else {
value = NULL;
if (OK !=
@@ -324,7 +330,7 @@
FREE(value);
}
pos += size;
- cronTime(&now);
+ now = get_time();
if (pos > 0) {
eta = (cron_t) (start +
(((double)(now - start)/(double)pos))
@@ -341,18 +347,20 @@
if (OK != tt(ttClosure))
goto FAILURE;
#if DEBUG_UPLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Tree depth is %u, walking up tree.\n",
- treedepth);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Tree depth is %u, walking up tree.\n",
+ treedepth);
#endif
for (i=0;i<treedepth;i++) {
size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
GE_ASSERT(ectx, size < MAX_BUFFER_SIZE);
if (size == sizeof(DBlock)) {
#if DEBUG_UPLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Level %u is empty\n",
- i);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Level %u is empty\n",
+ i);
#endif
continue;
}
@@ -361,21 +369,24 @@
size,
&chk.key);
#if DEBUG_UPLOAD
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Computing query for %u bytes content.\n",
- size);
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Computing query for %u bytes content.\n",
+ size);
#endif
fileBlockGetQuery(db,
size,
&chk.query);
#if DEBUG_UPLOAD
- IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- hash2enc(&chk.query,
- &enc));
- GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
- "Query for current block at level %u is `%s'.\n",
- i,
- &enc);
+ IF_GELOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ hash2enc(&chk.query,
+ &enc));
+ GE_LOG(ectx,
+ GE_DEBUG | GE_REQUEST | GE_USER,
+ "Query for current block at level %u is `%s'.\n",
+ i,
+ &enc);
#endif
if (OK != pushBlock(sock,
&chk,
@@ -415,23 +426,23 @@
fid.chk = *(CHK*)&(db[1]);
uris = createFileURI(&fid);
- *uri = ECRS_stringToUri(uris);
+ *uri = ECRS_stringToUri(ectx, uris);
FREE(uris);
/* free resources */
FREENONNULL(iblocks[treedepth]);
FREE(iblocks);
FREE(dblock);
- closefile(fd);
- releaseClientSocket(sock);
+ CLOSE(fd);
+ connection_destroy(sock);
return OK;
FAILURE:
for (i=0;i<=treedepth;i++)
FREENONNULL(iblocks[i]);
FREE(iblocks);
FREE(dblock);
- closefile(fd);
- releaseClientSocket(sock);
+ CLOSE(fd);
+ connection_destroy(sock);
return SYSERR;
}
Modified: GNUnet/src/applications/fs/ecrs/uri.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/uri.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/ecrs/uri.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- (C) 2003, 2004, 2005 Christian Grothoff (and other contributing authors)
+ (C) 2003, 2004, 2005, 2006 Christian Grothoff (and other contributing
authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -164,7 +164,7 @@
*/
char * ECRS_uriToString(const struct ECRS_URI * uri) {
if (uri == NULL) {
- GE_BREAK(ectx, 0);
+ GE_BREAK(NULL, 0);
return NULL;
}
switch (uri->type) {
@@ -179,7 +179,7 @@
case loc:
return "FIXME";
default:
- GE_BREAK(ectx, 0);
+ GE_BREAK(NULL, 0);
return NULL;
}
}
@@ -192,7 +192,8 @@
* @return SYSERR if this is not a search URI, otherwise
* the number of keywords placed in the array
*/
-static int parseKeywordURI(const char * uri,
+static int parseKeywordURI(struct GE_Context * ectx,
+ const char * uri,
char *** keywords) {
unsigned int pos;
int ret;
@@ -255,7 +256,8 @@
* @param identifier set to the ID in the namespace
* @return OK on success, SYSERR if this is not a namespace URI
*/
-static int parseSubspaceURI(const char * uri,
+static int parseSubspaceURI(struct GE_Context * ectx,
+ const char * uri,
HashCode512 * namespace,
HashCode512 * identifier) {
unsigned int pos;
@@ -307,7 +309,8 @@
* @param fi the file identifier
* @return OK on success, SYSERR if this is not a file URI
*/
-static int parseFileURI(const char * uri,
+static int parseFileURI(struct GE_Context * ectx,
+ const char * uri,
FileIdentifier * fi) {
unsigned int pos;
size_t slen;
@@ -353,24 +356,28 @@
/**
* Convert a UTF-8 String to a URI.
*/
-URI * ECRS_stringToUri(const char * uri) {
+URI * ECRS_stringToUri(struct GE_Context * ectx,
+ const char * uri) {
URI * ret;
int len;
ret = MALLOC(sizeof(URI));
- if (OK == parseFileURI(uri,
+ if (OK == parseFileURI(ectx,
+ uri,
&ret->data.chk)) {
ret->type = chk;
return ret;
}
- if (OK == parseSubspaceURI(uri,
+ if (OK == parseSubspaceURI(ectx,
+ uri,
&ret->data.sks.namespace,
&ret->data.sks.identifier)) {
ret->type = sks;
return ret;
}
/* FIXME: parse location! */
- len = parseKeywordURI(uri,
+ len = parseKeywordURI(ectx,
+ uri,
&ret->data.ksk.keywords);
if (len < 0) {
FREE(ret);
@@ -387,7 +394,8 @@
*/
void ECRS_freeUri(struct ECRS_URI * uri) {
int i;
- GE_ASSERT(ectx, uri != NULL);
+
+ GE_ASSERT(NULL, uri != NULL);
if (uri->type == ksk) {
for (i=0;i<uri->data.ksk.keywordCount;i++)
FREE(uri->data.ksk.keywords[i]);
@@ -430,7 +438,7 @@
int ECRS_getNamespaceId(const struct ECRS_URI * uri,
HashCode512 * id) {
if (! ECRS_isNamespaceUri(uri)) {
- GE_BREAK(ectx, 0);
+ GE_BREAK(NULL, 0);
return SYSERR;
}
*id = uri->data.sks.namespace;
@@ -445,7 +453,7 @@
int ECRS_getSKSContentHash(const struct ECRS_URI * uri,
HashCode512 * id) {
if (! ECRS_isNamespaceUri(uri)) {
- GE_BREAK(ectx, 0);
+ GE_BREAK(NULL, 0);
return SYSERR;
}
*id = uri->data.sks.identifier;
@@ -461,7 +469,7 @@
if (uri->type == ksk) {
for (i=uri->data.ksk.keywordCount-1;i>=0;i--)
- GE_ASSERT(ectx, uri->data.ksk.keywords[i] != NULL);
+ GE_ASSERT(NULL, uri->data.ksk.keywords[i] != NULL);
}
#endif
return uri->type == ksk;
@@ -527,7 +535,7 @@
case loc:
return ntohll(uri->data.loc.size);
default:
- GE_ASSERT(ectx, 0);
+ GE_ASSERT(NULL, 0);
}
return 0; /* unreachable */
}
@@ -574,7 +582,7 @@
time_t now;
unsigned int keywordCount;
- GE_ASSERT(ectx, uri->type == ksk);
+ GE_ASSERT(NULL, uri->type == ksk);
time(&now);
#ifdef HAVE_GMTIME_R
gmtime_r(&now, &t);
@@ -590,7 +598,7 @@
ret->data.ksk.keywords = MALLOC(sizeof(char*) * keywordCount * 2);
for (i=0;i<keywordCount;i++) {
key = uri->data.ksk.keywords[i];
- GE_ASSERT(ectx, key != NULL);
+ GE_ASSERT(NULL, key != NULL);
ret->data.ksk.keywords[2*i]
= STRDUP(key);
kd = MALLOC(strlen(key) + 13);
@@ -659,7 +667,7 @@
}
}
if (add == 1) {
- GE_ASSERT(ectx, md->items[i].data != NULL);
+ GE_ASSERT(NULL, md->items[i].data != NULL);
ret->data.ksk.keywords[i-havePreview]
= STRDUP(md->items[i].data);
}
@@ -704,8 +712,8 @@
int i;
int j;
- GE_ASSERT(ectx, uri1 != NULL);
- GE_ASSERT(ectx, uri2 != NULL);
+ GE_ASSERT(NULL, uri1 != NULL);
+ GE_ASSERT(NULL, uri2 != NULL);
if (uri1->type != uri2->type)
return NO;
switch(uri1->type) {
Modified: GNUnet/src/applications/fs/fsui/namespace_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/namespace_info.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/fs/fsui/namespace_info.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -519,7 +519,7 @@
deltaId(lastId,
thisId,
&delta);
- cronTime(&now);
+ now = get_time();
TIME(&tnow);
*nextId = *thisId;
while (lastTime < tnow + updateInterval/2) {
Modified: GNUnet/src/applications/fs/fsui/upload.c
===================================================================
--- GNUnet/src/applications/fs/fsui/upload.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/fsui/upload.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -85,7 +85,7 @@
FSUI_Event event;
cron_t now;
- cronTime(&now);
+ now = get_time();
event.type = FSUI_upload_progress;
event.data.UploadProgress.completed = completedBytes;
event.data.UploadProgress.total = totalBytes;
Modified: GNUnet/src/applications/fs/lib/fslibtest.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslibtest.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/fs/lib/fslibtest.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -185,7 +185,7 @@
closure.found = NO;
closure.i = i;
closure.sem = SEMAPHORE_CREATE(0);
- cronTime(&now);
+ now = get_time();
handle = FS_start_search(ctx,
D_BLOCK,
1,
@@ -225,7 +225,7 @@
char * tmpName;
int fd;
- cronTime(&now);
+ now = get_time();
if (OK != initUtil(argc,
argv,
&parseCommandLine))
@@ -354,7 +354,7 @@
if (ctx != NULL)
FS_SEARCH_destroyContext(ctx);
if (sock != NULL)
- releaseClientSocket(sock);
+ connection_destroy(sock);
MUTEX_DESTROY(&lock);
stopCron();
GE_ASSERT(ectx, OK == stopGNUnetDaemon());
Modified: GNUnet/src/applications/fs/tools/gnunet-delete.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-delete.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/fs/tools/gnunet-delete.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -152,7 +152,7 @@
"Probably a few blocks were already missing from the database.\n"),
filename);
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
doneUtil();
FREE(filename);
if (ok == OK)
Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -159,7 +159,7 @@
} else {
cron_t now;
- cronTime(&now);
+ now = get_time();
delta = now - event->data.UploadComplete.start_time;
PRINTF(_("Upload of `%s' complete, "
"current average speed is %8.3f KiB/s.\n"),
Modified: GNUnet/src/applications/gap/gaptest.c
===================================================================
--- GNUnet/src/applications/gap/gaptest.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/gap/gaptest.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -333,7 +333,7 @@
left--;
CHECK(left > 0);
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
uri = uploadFile(12345);
Modified: GNUnet/src/applications/rpc/rpc.c
===================================================================
--- GNUnet/src/applications/rpc/rpc.c 2006-08-13 02:45:10 UTC (rev 3222)
+++ GNUnet/src/applications/rpc/rpc.c 2006-08-13 03:45:47 UTC (rev 3223)
@@ -626,7 +626,7 @@
static void retryRPCJob(CallInstance * call) {
cron_t now;
- cronTime(&now);
+ now = get_time();
GE_ASSERT(ectx, (get_time() + 1 * cronMINUTES > call->expirationTime) ||
(call->expirationTime - get_time() < 1 * cronHOURS) );
MUTEX_LOCK(rpcLock);
Modified: GNUnet/src/applications/session/sessiontest.c
===================================================================
--- GNUnet/src/applications/session/sessiontest.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/session/sessiontest.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -139,7 +139,7 @@
break;
}
}
- releaseClientSocket(sock);
+ connection_destroy(sock);
if (daemon1 != -1) {
if (! termProcess(daemon1))
DIE_STRERROR("kill");
Modified: GNUnet/src/applications/tbench/tbenchtest.c
===================================================================
--- GNUnet/src/applications/tbench/tbenchtest.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/tbench/tbenchtest.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -220,7 +220,7 @@
checkConnected(sock);
}
ret = test(sock, 32768, 10, 10, 500 * cronMILLIS, 1, 10 * cronSECONDS);
- releaseClientSocket(sock);
+ connection_destroy(sock);
if (daemon1 != -1) {
if (! termProcess(daemon1))
DIE_STRERROR("kill");
Modified: GNUnet/src/applications/tbench/tbenchtest_udp.c
===================================================================
--- GNUnet/src/applications/tbench/tbenchtest_udp.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/tbench/tbenchtest_udp.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -223,7 +223,7 @@
}
ret = test(sock, 4096, 10, 10, 500 * cronMILLIS, 1, 10 * cronSECONDS);
ret = test(sock, 32768, 10, 10, 500 * cronMILLIS, 1, 10 * cronSECONDS);
- releaseClientSocket(sock);
+ connection_destroy(sock);
if (daemon1 != -1) {
if (! termProcess(daemon1))
DIE_STRERROR("kill");
Modified: GNUnet/src/applications/topology_f2f/topology.c
===================================================================
--- GNUnet/src/applications/topology_f2f/topology.c 2006-08-13 02:45:10 UTC
(rev 3222)
+++ GNUnet/src/applications/topology_f2f/topology.c 2006-08-13 03:45:47 UTC
(rev 3223)
@@ -166,7 +166,7 @@
cron_t now;
EncName enc;
- cronTime(&now);
+ now = get_time();
indexMatch.index = index;
indexMatch.matchCount = 0;
indexMatch.costSelector = 0;
@@ -237,7 +237,7 @@
if (weak_randomi(LIVE_PING_EFFECTIVENESS) != 0)
return;
- cronTime(&now);
+ now = get_time();
if (SYSERR == coreAPI->getLastActivityOf(peer, &act)) {
GE_BREAK(ectx, 0);
return; /* this should not happen... */
Modified: GNUnet/src/applications/vpn/gnunet-vpn.c
===================================================================
--- GNUnet/src/applications/vpn/gnunet-vpn.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/applications/vpn/gnunet-vpn.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -292,7 +292,7 @@
SEMAPHORE_FREE(exitCheck);
MUTEX_DESTROY(&lock);
PTHREAD_JOIN(&messageReceiveThread, &unused);
- releaseClientSocket(sock);
+ connection_destroy(sock);
doneUtil();
return 0;
Modified: GNUnet/src/include/gnunet_ecrs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_ecrs_lib.h 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/include/gnunet_ecrs_lib.h 2006-08-13 03:45:47 UTC (rev
3223)
@@ -267,8 +267,7 @@
* Convert a NULL-terminated array of keywords
* to an ECRS URI.
*/
-struct ECRS_URI * ECRS_keywordsToUri(struct GE_Context * ectx,
- const char * keyword[]);
+struct ECRS_URI * ECRS_keywordsToUri(const char * keyword[]);
/**
* Convert a UTF-8 String to a URI.
@@ -417,6 +416,7 @@
* or gnunetd not running)
*/
int ECRS_uploadFile(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const char * filename,
int doIndex,
unsigned int anonymityLevel,
@@ -438,6 +438,7 @@
* be notified that 'something is wrong')
*/
int ECRS_isFileIndexed(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const char * filename);
/**
@@ -459,6 +460,7 @@
* @return number of files indexed, SYSERR if iterator aborted
*/
int ECRS_iterateIndexedFiles(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
ECRS_FileIterator iterator,
void * closure);
@@ -468,6 +470,7 @@
* @return SYSERR if the unindexing failed (i.e. not indexed)
*/
int ECRS_unindexFile(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const char * filename,
ECRS_UploadProgressCallback upcb,
void * upcbClosure,
@@ -497,6 +500,7 @@
*/
struct ECRS_URI *
ECRS_createNamespace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const char * name,
const struct ECRS_MetaData * meta,
unsigned int anonymityLevel,
@@ -512,6 +516,7 @@
* @return OK if the namespace exists, SYSERR if not
*/
int ECRS_testNamespaceExists(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const char * name,
const HashCode512 * hc);
@@ -523,6 +528,7 @@
* @return OK on success, SYSERR on error
*/
int ECRS_deleteNamespace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const char * namespaceName); /* namespace.c */
/**
@@ -543,6 +549,7 @@
* @return SYSERR on error, otherwise the number of pseudonyms in list
*/
int ECRS_listNamespaces(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
ECRS_NamespaceInfoCallback cb,
void * cls); /* namespace.c */
@@ -558,6 +565,7 @@
*/
struct ECRS_URI *
ECRS_addToNamespace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const char * name,
unsigned int anonymityLevel,
unsigned int priority,
@@ -579,6 +587,7 @@
* entry?
*/
int ECRS_addToKeyspace(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const struct ECRS_URI * uri,
unsigned int anonymityLevel,
unsigned int priority,
@@ -611,6 +620,7 @@
* @param uri set to the URI of the uploaded file
*/
int ECRS_search(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const struct ECRS_URI * uri,
unsigned int anonymityLevel,
cron_t timeout,
@@ -649,6 +659,7 @@
* @param filename where to store the file
*/
int ECRS_downloadFile(struct GE_Context * ectx,
+ struct GC_Configuration * cfg,
const struct ECRS_URI * uri,
const char * filename,
unsigned int anonymityLevel,
Modified: GNUnet/src/include/gnunet_util_threads.h
===================================================================
--- GNUnet/src/include/gnunet_util_threads.h 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/include/gnunet_util_threads.h 2006-08-13 03:45:47 UTC (rev
3223)
@@ -85,7 +85,7 @@
/**
* Get the handle for THIS thread.
*/
-struct PTHREAD * PTHREAD_GET_SELF();
+struct PTHREAD * PTHREAD_GET_SELF(void);
/**
* Release handle for a thread (should have been
Modified: GNUnet/src/util/network_client/tcpiotest.c
===================================================================
--- GNUnet/src/util/network_client/tcpiotest.c 2006-08-13 02:45:10 UTC (rev
3222)
+++ GNUnet/src/util/network_client/tcpiotest.c 2006-08-13 03:45:47 UTC (rev
3223)
@@ -229,7 +229,7 @@
serverSocket = openServerSocket();
clientSocket = getClientSocket();
if (serverSocket == -1) {
- releaseClientSocket(clientSocket);
+ connection_destroy(clientSocket);
doneUtil();
return 1;
}
@@ -253,7 +253,7 @@
ret = -1;
}
}
- releaseClientSocket(clientSocket);
+ connection_destroy(clientSocket);
doneUtil();
if (ret > 0)
fprintf(stderr, "Error %d\n", ret);
Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2006-08-13 02:45:10 UTC (rev 3222)
+++ GNUnet/todo 2006-08-13 03:45:47 UTC (rev 3223)
@@ -27,9 +27,9 @@
+ fragmentation, identity, pingpong, session, transport,
stats, topology_default, state, getoption, advertising,
traffic, ecrs_core, template, tbench, tracekit, fs/fslib,
- fs/module, gap compile
+ fs/module, gap, fs/ecrs compile
+ bootstrap_http: maybe switch to libwww?
- + for fs: fs/ecrs (7000), fs/fsui (5500), fs/tools (2500)
+ + for fs: fs/fsui (5500), fs/tools (2500)
+ rest: sqstore_mysql, dht, rpc, topology_f2f, vpn
+ low priority: chat, kvstore_sqlite, testbed
* setup:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r3223 - in GNUnet: . src/applications/chat src/applications/dht/module src/applications/dht/tools src/applications/fs/ecrs src/applications/fs/fsui src/applications/fs/lib src/applications/fs/tools src/applications/gap src/applications/rpc src/applications/session src/applications/tbench src/applications/topology_f2f src/applications/vpn src/include src/util/network_client,
grothoff <=