[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6168 - in GNUnet/src: applications/chat applications/dht/m
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6168 - in GNUnet/src: applications/chat applications/dht/module applications/fs/ecrs applications/fs/gap applications/fs/lib applications/fs/module applications/stats applications/testing include server setup/qt transports util/boot util/containers |
Date: |
Wed, 6 Feb 2008 00:44:31 -0700 (MST) |
Author: grothoff
Date: 2008-02-06 00:44:26 -0700 (Wed, 06 Feb 2008)
New Revision: 6168
Modified:
GNUnet/src/applications/chat/clientapi.c
GNUnet/src/applications/dht/module/routing.h
GNUnet/src/applications/fs/ecrs/download.c
GNUnet/src/applications/fs/ecrs/search.c
GNUnet/src/applications/fs/gap/anonymity.c
GNUnet/src/applications/fs/gap/anonymity.h
GNUnet/src/applications/fs/gap/fs.c
GNUnet/src/applications/fs/gap/fs_dht.c
GNUnet/src/applications/fs/gap/fs_dht.h
GNUnet/src/applications/fs/gap/gap.c
GNUnet/src/applications/fs/gap/gap.h
GNUnet/src/applications/fs/gap/gap_old.c
GNUnet/src/applications/fs/gap/migration.c
GNUnet/src/applications/fs/gap/migration.h
GNUnet/src/applications/fs/gap/ondemand.c
GNUnet/src/applications/fs/gap/ondemand.h
GNUnet/src/applications/fs/gap/pid_table.c
GNUnet/src/applications/fs/gap/pid_table.h
GNUnet/src/applications/fs/gap/plan.c
GNUnet/src/applications/fs/gap/plan.h
GNUnet/src/applications/fs/gap/querymanager.c
GNUnet/src/applications/fs/gap/querymanager.h
GNUnet/src/applications/fs/gap/shared.c
GNUnet/src/applications/fs/gap/shared.h
GNUnet/src/applications/fs/lib/fslib.c
GNUnet/src/applications/fs/module/fs.c
GNUnet/src/applications/fs/module/ondemand.c
GNUnet/src/applications/stats/clientapi.c
GNUnet/src/applications/testing/remote.c
GNUnet/src/include/fs.h
GNUnet/src/include/gnunet_core.h
GNUnet/src/include/gnunet_fs_lib.h
GNUnet/src/include/gnunet_remote_lib.h
GNUnet/src/include/gnunet_util_containers.h
GNUnet/src/server/connection.c
GNUnet/src/server/connection.h
GNUnet/src/server/core.c
GNUnet/src/server/tcpserver.c
GNUnet/src/server/tcpserver.h
GNUnet/src/setup/qt/setupWizard.h
GNUnet/src/transports/http.c
GNUnet/src/util/boot/startup.c
GNUnet/src/util/containers/bloomfilter.c
Log:
formatting
Modified: GNUnet/src/applications/chat/clientapi.c
===================================================================
--- GNUnet/src/applications/chat/clientapi.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/chat/clientapi.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -95,19 +95,19 @@
const char *memberInfo,
GNUNET_CHAT_MessageCallback callback, void *cls)
{
- CS_chat_MESSAGE *chat_msg;
+ CS_chat_MESSAGE *chat_msg;
GNUNET_MessageHeader csHdr;
struct GNUNET_CHAT_Room *chat_room;
struct GNUNET_ClientServerConnection *sock;
-
+
int ret;
ret = GNUNET_OK;
csHdr.size = htons (sizeof (GNUNET_MessageHeader));
csHdr.type = htons (GNUNET_CS_PROTO_CHAT_MSG);
-
+
sock = GNUNET_client_connection_create(ectx,cfg);
-
+
if (sock == NULL)
{
fprintf (stderr, _("Error establishing connection with gnunetd.\n"));
@@ -119,9 +119,9 @@
fprintf (stderr, _("Error writing to socket.\n"));
ret = GNUNET_SYSERR;
}
-
+
chat_msg = GNUNET_malloc (sizeof (CS_chat_MESSAGE));
-
+
// connect
// allocate & init room struct
Modified: GNUnet/src/applications/dht/module/routing.h
===================================================================
--- GNUnet/src/applications/dht/module/routing.h 2008-02-06 07:42:25 UTC
(rev 6167)
+++ GNUnet/src/applications/dht/module/routing.h 2008-02-06 07:44:26 UTC
(rev 6168)
@@ -49,7 +49,7 @@
/**
* Perform a DHT put operation. Note that PUT operations always
* expire after a period of time and the client is responsible for
- * doing periodic refreshs.
+ * doing periodic refreshs.
*
* @param expirationTime absolute expiration time
*/
Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/ecrs/download.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -48,13 +48,13 @@
/**
* Previous entry in DLL.
- */
- struct Node * prev;
+ */
+ struct Node *prev;
/**
* Next entry in DLL.
*/
- struct Node * next;
+ struct Node *next;
/**
* What is the CHK for this block?
@@ -94,7 +94,7 @@
* Number of bytes already obtained
*/
unsigned long long completed;
-
+
/**
* Starting-offset in file (for partial download)
*/
@@ -118,12 +118,12 @@
/**
* Doubly linked list of all pending requests (head)
*/
- struct Node * head;
+ struct Node *head;
/**
* Doubly linked list of all pending requests (tail)
*/
- struct Node * tail;
+ struct Node *tail;
/**
* FSLIB context for issuing requests.
@@ -153,7 +153,7 @@
/**
* Main thread running the operation.
*/
- struct GNUNET_ThreadHandle * main;
+ struct GNUNET_ThreadHandle *main;
/**
* Function to call when we make progress.
@@ -208,12 +208,11 @@
* is not complete and may be resumed later.
*/
static void
-free_request_manager(struct RequestManager * rm,
- int unlinkTreeFiles)
+free_request_manager (struct RequestManager *rm, int unlinkTreeFiles)
{
int i;
char *fn;
- struct Node * pos;
+ struct Node *pos;
GNUNET_mutex_lock (rm->lock);
/* cannot hold lock during shutdown since
@@ -222,13 +221,13 @@
and start to ignore fslib events! */
rm->abortFlag = GNUNET_YES;
GNUNET_mutex_unlock (rm->lock);
- GNUNET_FS_destroy_search_context(rm->sctx);
+ GNUNET_FS_destroy_search_context (rm->sctx);
rm->sctx = NULL;
while (rm->head != NULL)
{
pos = rm->head;
rm->head = pos->next;
- GNUNET_free(pos);
+ GNUNET_free (pos);
}
rm->tail = NULL;
for (i = 0; i <= rm->treedepth; i++)
@@ -242,7 +241,7 @@
if (rm->lock != NULL)
GNUNET_mutex_destroy (rm->lock);
if (rm->main != NULL)
- GNUNET_thread_release_self(rm->main);
+ GNUNET_thread_release_self (rm->main);
if (GNUNET_YES == unlinkTreeFiles)
{
for (i = 1; i <= rm->treedepth; i++)
@@ -275,14 +274,14 @@
* @return number of bytes read, GNUNET_SYSERR on error
*/
static int
-read_from_files (struct RequestManager * this,
- unsigned int level,
- unsigned long long pos, void *buf, unsigned int len)
+read_from_files (struct RequestManager *this,
+ unsigned int level,
+ unsigned long long pos, void *buf, unsigned int len)
{
int ret;
if (this->handles[level] == -1)
- return GNUNET_SYSERR;
+ return GNUNET_SYSERR;
LSEEK (this->handles[level], pos, SEEK_SET);
ret = READ (this->handles[level], buf, len);
#if DEBUG_DOWNLOAD
@@ -305,14 +304,14 @@
* @return number of bytes written, GNUNET_SYSERR on error
*/
static int
-write_to_files (struct RequestManager * this,
- unsigned int level,
- unsigned long long pos, void *buf, unsigned int len)
+write_to_files (struct RequestManager *this,
+ unsigned int level,
+ unsigned long long pos, void *buf, unsigned int len)
{
int ret;
if ((this->handles[level] == -1) && (level > 0))
- return len; /* lie -- no temps allowed... */
+ return len; /* lie -- no temps allowed... */
LSEEK (this->handles[level], pos, SEEK_SET);
ret = WRITE (this->handles[level], buf, len);
if (ret != len)
@@ -327,8 +326,8 @@
static int
content_receive_callback (const GNUNET_HashCode * query,
- const GNUNET_DatastoreValue * reply, void *cls,
- unsigned long long uid);
+ const GNUNET_DatastoreValue * reply, void *cls,
+ unsigned long long uid);
/**
* Queue a request for execution.
@@ -337,9 +336,9 @@
* @param node the node to call once a reply is received
*/
static void
-addRequest (struct Node * node)
+addRequest (struct Node *node)
{
- struct RequestManager * rm = node->ctx;
+ struct RequestManager *rm = node->ctx;
node->next = rm->head;
node->next->prev = node;
@@ -348,19 +347,18 @@
if (rm->tail == NULL)
rm->tail = node;
GNUNET_FS_start_search (rm->sctx,
- rm->have_target == GNUNET_NO ? NULL : &rm->target,
- GNUNET_ECRS_BLOCKTYPE_DATA, 1,
- &node->chk.query,
- rm->anonymityLevel,
- &content_receive_callback,
- node);
+ rm->have_target == GNUNET_NO ? NULL : &rm->target,
+ GNUNET_ECRS_BLOCKTYPE_DATA, 1,
+ &node->chk.query,
+ rm->anonymityLevel,
+ &content_receive_callback, node);
}
static void
-signal_abort(struct RequestManager * rm)
+signal_abort (struct RequestManager *rm)
{
rm->abortFlag = GNUNET_YES;
- GNUNET_thread_stop_sleep(rm->main);
+ GNUNET_thread_stop_sleep (rm->main);
}
/**
@@ -370,9 +368,9 @@
* @param node the block for which the request is canceled
*/
static void
-delete_node (struct Node * node)
+delete_node (struct Node *node)
{
- struct RequestManager * rm = node->ctx;
+ struct RequestManager *rm = node->ctx;
if (node->prev == NULL)
rm->head = node->next;
@@ -382,9 +380,9 @@
rm->tail = node->prev;
else
node->next->prev = node->prev;
- GNUNET_free(node);
+ GNUNET_free (node);
if (rm->head == NULL)
- signal_abort(rm);
+ signal_abort (rm);
}
/**
@@ -392,7 +390,7 @@
* this node.
*/
static unsigned int
-get_node_size (const struct Node * node)
+get_node_size (const struct Node *node)
{
unsigned int i;
unsigned int ret;
@@ -437,26 +435,24 @@
* Notify client about progress.
*/
static void
-notify_client_about_progress (const struct Node * node, const char *data,
unsigned int size)
+notify_client_about_progress (const struct Node *node, const char *data,
+ unsigned int size)
{
struct RequestManager *rm = node->ctx;
GNUNET_CronTime eta;
- if ( (rm->abortFlag == GNUNET_YES) ||
- (node->level != 0) )
- return;
+ if ((rm->abortFlag == GNUNET_YES) || (node->level != 0))
+ return;
rm->completed += size;
eta = GNUNET_get_time ();
- if (rm->completed > 0)
+ if (rm->completed > 0)
eta = (GNUNET_CronTime) (rm->startTime +
- (((double) (eta - rm->startTime) /
- (double) rm->completed)) *
- (double) rm->length);
+ (((double) (eta - rm->startTime) /
+ (double) rm->completed)) *
+ (double) rm->length);
if (rm->dpcb != NULL)
rm->dpcb (rm->length,
- rm->completed,
- eta,
- node->offset, data, size, rm->dpcbClosure);
+ rm->completed, eta, node->offset, data, size, rm->dpcbClosure);
}
@@ -465,7 +461,7 @@
*
* @param rm the node that should downloaded
*/
-static void iblock_download_children (struct Node * node,
+static void iblock_download_children (struct Node *node,
char *data, unsigned int size);
/**
@@ -483,7 +479,7 @@
* @return GNUNET_YES if present, GNUNET_NO if not.
*/
static int
-check_node_present (struct Node * node)
+check_node_present (struct Node *node)
{
int res;
int ret;
@@ -495,9 +491,9 @@
/* first check if node is within range.
For now, keeping it simple, we only do
this for level-0 nodes */
- if ( (node->level == 0) &&
- ((node->offset + size < node->ctx->offset) ||
- (node->offset >= node->ctx->offset + node->ctx->length)) )
+ if ((node->level == 0) &&
+ ((node->offset + size < node->ctx->offset) ||
+ (node->offset >= node->ctx->offset + node->ctx->length)))
return GNUNET_YES;
data = GNUNET_malloc (size);
res = read_from_files (node->ctx, node->level, node->offset, data, size);
@@ -526,7 +522,7 @@
* @param this the node that should downloaded
*/
static void
-iblock_download_children (struct Node * node, char *data, unsigned int size)
+iblock_download_children (struct Node *node, char *data, unsigned int size)
{
struct GNUNET_GE_Context *ectx = node->ctx->ectx;
int i;
@@ -556,7 +552,7 @@
chks = (CHK *) data;
for (i = 0; i < childcount; i++)
{
- child = GNUNET_malloc (sizeof (struct Node));
+ child = GNUNET_malloc (sizeof (struct Node));
child->ctx = node->ctx;
child->chk = chks[i];
child->offset = baseOffset + i * levelSize;
@@ -583,8 +579,8 @@
*/
static int
decrypt_content (const char *data,
- unsigned int size, const GNUNET_HashCode * hashcode,
- char *result)
+ unsigned int size, const GNUNET_HashCode * hashcode,
+ char *result)
{
GNUNET_AES_InitializationVector iv;
GNUNET_AES_SessionKey skey;
@@ -609,21 +605,22 @@
*/
static int
content_receive_callback (const GNUNET_HashCode * query,
- const GNUNET_DatastoreValue * reply, void *cls,
- unsigned long long uid)
+ const GNUNET_DatastoreValue * reply, void *cls,
+ unsigned long long uid)
{
struct Node *node = cls;
- struct RequestManager * rm = node->ctx;
+ struct RequestManager *rm = node->ctx;
struct GNUNET_GE_Context *ectx = rm->ectx;
GNUNET_HashCode hc;
unsigned int size;
char *data;
GNUNET_mutex_lock (rm->lock);
- if (rm->abortFlag != GNUNET_NO) {
- GNUNET_mutex_unlock (rm->lock);
- return GNUNET_SYSERR;
- }
+ if (rm->abortFlag != GNUNET_NO)
+ {
+ GNUNET_mutex_unlock (rm->lock);
+ return GNUNET_SYSERR;
+ }
GNUNET_GE_ASSERT (ectx,
0 == memcmp (query, &node->chk.query,
sizeof (GNUNET_HashCode)));
@@ -638,7 +635,7 @@
size -= sizeof (DBlock);
data = GNUNET_malloc (size);
if (GNUNET_SYSERR == decrypt_content ((char *) &((DBlock *) & reply[1])[1],
- size, &node->chk.key, data))
+ size, &node->chk.key, data))
GNUNET_GE_ASSERT (ectx, 0);
GNUNET_hash (data, size, &hc);
if (0 != memcmp (&hc, &node->chk.key, sizeof (GNUNET_HashCode)))
@@ -649,17 +646,16 @@
_("Decrypted content does not match key. "
"This is either a bug or a maliciously inserted "
"file. Download aborted.\n"));
- signal_abort(rm);
+ signal_abort (rm);
GNUNET_mutex_unlock (rm->lock);
return GNUNET_SYSERR;
}
- if (size != write_to_files (rm,
- node->level, node->offset, data, size))
+ if (size != write_to_files (rm, node->level, node->offset, data, size))
{
GNUNET_GE_LOG_STRERROR (ectx,
GNUNET_GE_ERROR | GNUNET_GE_ADMIN |
GNUNET_GE_USER | GNUNET_GE_BULK, "WRITE");
- signal_abort(rm);
+ signal_abort (rm);
GNUNET_mutex_unlock (rm->lock);
return GNUNET_SYSERR;
}
@@ -676,11 +672,11 @@
/**
* Helper function to sanitize filename
- * and create necessary directories.
+ * and create necessary directories.
*/
static char *
-get_real_download_filename(struct GNUNET_GE_Context * ectx,
- const char * filename)
+get_real_download_filename (struct GNUNET_GE_Context *ectx,
+ const char *filename)
{
struct stat buf;
char *realFN;
@@ -725,7 +721,7 @@
pos++;
}
GNUNET_free (realFN);
- return path;
+ return path;
}
/* ***************** main method **************** */
@@ -778,7 +774,7 @@
return GNUNET_SYSERR;
}
- memset(&rm, 0, sizeof(struct RequestManager));
+ memset (&rm, 0, sizeof (struct RequestManager));
rm.ectx = ectx;
rm.cfg = cfg;
rm.startTime = GNUNET_get_time ();
@@ -787,14 +783,14 @@
rm.length = length;
rm.dpcb = dpcb;
rm.dpcbClosure = dpcbClosure;
- rm.main = GNUNET_thread_get_self();
+ rm.main = GNUNET_thread_get_self ();
rm.total = GNUNET_ntohll (uri->data.fi.file_length);
- rm.filename = get_real_download_filename(ectx,
- filename);
-
- if (GNUNET_SYSERR == GNUNET_disk_directory_create_for_file (ectx,
rm.filename))
+ rm.filename = get_real_download_filename (ectx, filename);
+
+ if (GNUNET_SYSERR ==
+ GNUNET_disk_directory_create_for_file (ectx, rm.filename))
{
- free_request_manager(&rm, GNUNET_NO);
+ free_request_manager (&rm, GNUNET_NO);
return GNUNET_SYSERR;
}
if (0 == rm.total)
@@ -804,13 +800,13 @@
O_CREAT | O_WRONLY | O_TRUNC,
S_IRUSR | S_IWUSR);
if (ret == -1)
- {
- free_request_manager(&rm, GNUNET_NO);
- return GNUNET_SYSERR;
- }
+ {
+ free_request_manager (&rm, GNUNET_NO);
+ return GNUNET_SYSERR;
+ }
CLOSE (ret);
dpcb (0, 0, rm.startTime, 0, NULL, 0, dpcbClosure);
- free_request_manager(&rm, GNUNET_NO);
+ free_request_manager (&rm, GNUNET_NO);
return GNUNET_OK;
}
rm.treedepth = GNUNET_ECRS_compute_depth (rm.total);
@@ -824,8 +820,9 @@
{
GNUNET_GE_LOG_STRERROR_FILE (ectx,
GNUNET_GE_ERROR | GNUNET_GE_ADMIN |
- GNUNET_GE_BULK, "truncate",
rm.filename);
- free_request_manager(&rm, GNUNET_NO);
+ GNUNET_GE_BULK, "truncate",
+ rm.filename);
+ free_request_manager (&rm, GNUNET_NO);
return GNUNET_SYSERR;
}
}
@@ -841,12 +838,12 @@
fn[strlen (fn) - 1] += i;
}
rm.handles[i] = GNUNET_disk_file_open (ectx,
- fn,
- O_CREAT | O_RDWR,
- S_IRUSR | S_IWUSR);
+ fn,
+ O_CREAT | O_RDWR,
+ S_IRUSR | S_IWUSR);
if (rm.handles[i] < 0)
{
- free_request_manager(&rm, GNUNET_NO);
+ free_request_manager (&rm, GNUNET_NO);
return GNUNET_SYSERR;
}
GNUNET_free (fn);
@@ -856,7 +853,7 @@
rm.sctx = GNUNET_FS_create_search_context (ectx, cfg, rm.lock);
if (rm.sctx == NULL)
{
- free_request_manager(&rm, GNUNET_NO);
+ free_request_manager (&rm, GNUNET_NO);
return GNUNET_SYSERR;
}
if (GNUNET_ECRS_uri_test_loc (uri))
@@ -867,7 +864,7 @@
}
top = GNUNET_malloc (sizeof (struct Node));
- memset(top, 0, sizeof(struct Node));
+ memset (top, 0, sizeof (struct Node));
top->ctx = &rm;
top->chk = uri->data.fi.chk;
top->offset = 0;
@@ -879,9 +876,8 @@
else
GNUNET_free (top);
GNUNET_mutex_unlock (rm.lock);
- while ( (GNUNET_OK == tt (ttClosure)) &&
- (rm.abortFlag == GNUNET_NO) &&
- (rm.head != NULL) )
+ while ((GNUNET_OK == tt (ttClosure)) &&
+ (rm.abortFlag == GNUNET_NO) && (rm.head != NULL))
GNUNET_thread_sleep (5 * GNUNET_CRON_SECONDS);
if ((rm.head == NULL) &&
((rm.completed == rm.total) ||
@@ -908,8 +904,7 @@
__FUNCTION__, filename,
ret == GNUNET_OK ? "SUCCESS" : "INCOMPLETE");
#endif
- if ( (ret == GNUNET_SYSERR) &&
- (tt(ttClosure) == GNUNET_SYSERR) )
+ if ((ret == GNUNET_SYSERR) && (tt (ttClosure) == GNUNET_SYSERR))
{
if (0 != UNLINK (rm.filename))
{
@@ -919,7 +914,7 @@
}
else
{
- /* delete empty directories */
+ /* delete empty directories */
rdir = GNUNET_strdup (rm.filename);
len = strlen (rdir);
do
@@ -931,12 +926,11 @@
while ((len > 0) && (0 == rmdir (rdir)));
GNUNET_free (rdir);
}
- }
- free_request_manager (&rm,
- ( (ret == GNUNET_OK) ||
- (tt(ttClosure) == GNUNET_SYSERR) )
- ? GNUNET_YES
- : GNUNET_NO);
+ }
+ free_request_manager (&rm,
+ ((ret == GNUNET_OK) ||
+ (tt (ttClosure) == GNUNET_SYSERR))
+ ? GNUNET_YES : GNUNET_NO);
return ret;
}
Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/ecrs/search.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -34,7 +34,7 @@
#define DEBUG_SEARCH GNUNET_NO
/**
- * This struct is followed by keyCount keys of
+ * This struct is followed by keyCount keys of
* type "GNUNET_HashCode".
*/
struct PendingSearch
Modified: GNUnet/src/applications/fs/gap/anonymity.c
===================================================================
--- GNUnet/src/applications/fs/gap/anonymity.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/anonymity.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -29,13 +29,12 @@
#include "gnunet_protocols.h"
#include "gnunet_traffic_service.h"
-static GNUNET_Traffic_ServiceAPI * traffic;
+static GNUNET_Traffic_ServiceAPI *traffic;
static GNUNET_CoreAPIForPlugins *coreAPI;
int
-GNUNET_FS_ANONYMITY_check (unsigned int level,
- unsigned short content_type)
+GNUNET_FS_ANONYMITY_check (unsigned int level, unsigned short content_type)
{
unsigned int count;
unsigned int peers;
@@ -94,18 +93,18 @@
/**
* Initialize the migration module.
*/
-void
+void
GNUNET_FS_ANONYMITY_init (GNUNET_CoreAPIForPlugins * capi)
{
coreAPI = capi;
- traffic = capi->request_service("traffic");
+ traffic = capi->request_service ("traffic");
}
-void
+void
GNUNET_FS_ANONYMITY_done ()
{
if (traffic != NULL)
- coreAPI->release_service("traffic");
+ coreAPI->release_service ("traffic");
}
/* end of anonymity.c */
Modified: GNUnet/src/applications/fs/gap/anonymity.h
===================================================================
--- GNUnet/src/applications/fs/gap/anonymity.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/anonymity.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -32,11 +32,9 @@
/**
* Initialize the migration module.
*/
-void
-GNUNET_FS_ANONYMITY_init (GNUNET_CoreAPIForPlugins * capi);
+void GNUNET_FS_ANONYMITY_init (GNUNET_CoreAPIForPlugins * capi);
-void
-GNUNET_FS_ANONYMITY_done (void);
+void GNUNET_FS_ANONYMITY_done (void);
/**
* Consider traffic volume before sending out content or
@@ -46,6 +44,6 @@
*/
int
GNUNET_FS_ANONYMITY_check (unsigned int anonymityLevel,
- unsigned short content_type);
+ unsigned short content_type);
#endif
Modified: GNUnet/src/applications/fs/gap/fs.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs.c 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/applications/fs/gap/fs.c 2008-02-06 07:44:26 UTC (rev 6168)
@@ -60,7 +60,7 @@
* Lock shared between all C files in this
* directory.
*/
-struct GNUNET_Mutex * GNUNET_FS_lock;
+struct GNUNET_Mutex *GNUNET_FS_lock;
static struct GNUNET_GE_Context *ectx;
@@ -70,7 +70,7 @@
static GNUNET_Stats_ServiceAPI *stats;
-static GNUNET_Datastore_ServiceAPI * datastore;
+static GNUNET_Datastore_ServiceAPI *datastore;
static int stat_gap_query_received;
@@ -99,7 +99,7 @@
*/
static int
handle_cs_insert_request (struct GNUNET_ClientHandle *sock,
- const GNUNET_MessageHeader * req)
+ const GNUNET_MessageHeader * req)
{
const CS_fs_request_insert_MESSAGE *ri;
GNUNET_DatastoreValue *datum;
@@ -110,13 +110,13 @@
#endif
ri = (const CS_fs_request_insert_MESSAGE *) req;
- if ( (ntohs (req->size) < sizeof (CS_fs_request_insert_MESSAGE)) ||
- (GNUNET_OK !=
- GNUNET_EC_file_block_check_and_get_query (ntohs (ri->header.size) -
- sizeof
-
(CS_fs_request_insert_MESSAGE),
- (const DBlock *) &ri[1],
- GNUNET_YES, &query)) )
+ if ((ntohs (req->size) < sizeof (CS_fs_request_insert_MESSAGE)) ||
+ (GNUNET_OK !=
+ GNUNET_EC_file_block_check_and_get_query (ntohs (ri->header.size) -
+ sizeof
+
(CS_fs_request_insert_MESSAGE),
+ (const DBlock *) &ri[1],
+ GNUNET_YES, &query)))
{
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
@@ -130,9 +130,10 @@
datum->expirationTime = ri->expiration;
datum->prio = ri->prio;
datum->anonymityLevel = ri->anonymityLevel;
- datum->type = htonl(GNUNET_EC_file_block_get_type (ntohs (ri->header.size) -
- sizeof
(CS_fs_request_insert_MESSAGE),
- (const DBlock *) &ri[1]));
+ datum->type =
+ htonl (GNUNET_EC_file_block_get_type
+ (ntohs (ri->header.size) - sizeof (CS_fs_request_insert_MESSAGE),
+ (const DBlock *) &ri[1]));
#if DEBUG_FS
IF_GELOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
GNUNET_hash_to_enc (&query, &enc));
@@ -152,8 +153,8 @@
*/
static int
handle_cs_init_index_request (struct GNUNET_ClientHandle *sock,
- const GNUNET_MessageHeader * req)
-{
+ const GNUNET_MessageHeader * req)
+{
const CS_fs_request_init_index_MESSAGE *ri;
struct GNUNET_GE_Context *cectx;
int fnLen;
@@ -161,11 +162,11 @@
char *fn;
fnLen = ntohs (req->size) - sizeof (CS_fs_request_init_index_MESSAGE);
- if ( (ntohs (req->size) < sizeof (CS_fs_request_init_index_MESSAGE))
+ if ((ntohs (req->size) < sizeof (CS_fs_request_init_index_MESSAGE))
#if WINDOWS
- || (fnLen > _MAX_PATH)
+ || (fnLen > _MAX_PATH)
#endif
- )
+ )
{
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
@@ -174,10 +175,9 @@
fn = GNUNET_malloc (fnLen + 1);
strncpy (fn, (const char *) &ri[1], fnLen + 1);
fn[fnLen] = 0;
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
- ret = GNUNET_FS_ONDEMAND_index_prepare_with_symlink (cectx, &ri->fileId, fn);
+ cectx = coreAPI->cs_create_client_log_context (sock);
+ ret =
+ GNUNET_FS_ONDEMAND_index_prepare_with_symlink (cectx, &ri->fileId, fn);
GNUNET_GE_free_context (cectx);
GNUNET_free (fn);
#if DEBUG_FS
@@ -196,7 +196,7 @@
*/
static int
handle_cs_index_request (struct GNUNET_ClientHandle *sock,
- const GNUNET_MessageHeader * req)
+ const GNUNET_MessageHeader * req)
{
int ret;
const CS_fs_request_index_MESSAGE *ri;
@@ -207,20 +207,21 @@
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
}
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
+ cectx = coreAPI->cs_create_client_log_context (sock);
ri = (const CS_fs_request_index_MESSAGE *) req;
ret = GNUNET_FS_ONDEMAND_add_indexed_content (cectx,
- datastore,
- ntohl (ri->prio),
- GNUNET_ntohll (ri->expiration),
- GNUNET_ntohll (ri->fileOffset),
- ntohl (ri->anonymityLevel),
- &ri->fileId,
- ntohs (ri->header.size) -
- sizeof (CS_fs_request_index_MESSAGE),
- (const DBlock *) &ri[1]);
+ datastore,
+ ntohl (ri->prio),
+ GNUNET_ntohll (ri->
+ expiration),
+ GNUNET_ntohll (ri->
+ fileOffset),
+ ntohl (ri->anonymityLevel),
+ &ri->fileId,
+ ntohs (ri->header.size) -
+ sizeof
+ (CS_fs_request_index_MESSAGE),
+ (const DBlock *) &ri[1]);
GNUNET_GE_free_context (cectx);
#if DEBUG_FS
GNUNET_GE_LOG (ectx,
@@ -238,7 +239,7 @@
*/
static int
handle_cs_delete_request (struct GNUNET_ClientHandle *sock,
- const GNUNET_MessageHeader * req)
+ const GNUNET_MessageHeader * req)
{
int ret;
const CS_fs_request_delete_MESSAGE *rd;
@@ -287,7 +288,10 @@
type);
#endif
GNUNET_mutex_lock (GNUNET_FS_lock);
- if (GNUNET_SYSERR == datastore->get (&query, type,
&GNUNET_FS_HELPER_complete_value_from_database_callback, value))
+ if (GNUNET_SYSERR ==
+ datastore->get (&query, type,
+ &GNUNET_FS_HELPER_complete_value_from_database_callback,
+ value))
{ /* aborted == found! */
ret = datastore->del (&query, value);
}
@@ -311,15 +315,13 @@
*/
static int
handle_cs_unindex_request (struct GNUNET_ClientHandle *sock,
- const GNUNET_MessageHeader * req)
+ const GNUNET_MessageHeader * req)
{
int ret;
const CS_fs_request_unindex_MESSAGE *ru;
struct GNUNET_GE_Context *cectx;
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
+ cectx = coreAPI->cs_create_client_log_context (sock);
if (ntohs (req->size) != sizeof (CS_fs_request_unindex_MESSAGE))
{
GNUNET_GE_BREAK (ectx, 0);
@@ -334,7 +336,9 @@
"FS received REQUEST UNINDEX\n");
#endif
ret = GNUNET_FS_ONDEMAND_delete_indexed_content (cectx,
- datastore, ntohl (ru->blocksize), &ru->fileId);
+ datastore,
+ ntohl (ru->blocksize),
+ &ru->fileId);
GNUNET_GE_free_context (cectx);
return coreAPI->sendValueToClient (sock, ret);
}
@@ -345,7 +349,7 @@
*/
static int
handle_cs_test_indexed_request (struct GNUNET_ClientHandle *sock,
- const GNUNET_MessageHeader * req)
+ const GNUNET_MessageHeader * req)
{
int ret;
const CS_fs_request_test_index_MESSAGE *ru;
@@ -371,44 +375,41 @@
* we should about the iteration (return GNUNET_SYSERR).
*/
static int
-fast_path_processor(const GNUNET_HashCode * key,
- const GNUNET_DatastoreValue *
- value, void *closure,
- unsigned long long uid) {
- struct GNUNET_ClientHandle * sock = closure;
- const DBlock * dblock;
- CS_fs_reply_content_MESSAGE * msg;
+fast_path_processor (const GNUNET_HashCode * key,
+ const GNUNET_DatastoreValue *
+ value, void *closure, unsigned long long uid)
+{
+ struct GNUNET_ClientHandle *sock = closure;
+ const DBlock *dblock;
+ CS_fs_reply_content_MESSAGE *msg;
unsigned int size;
- GNUNET_DatastoreValue * enc;
- const GNUNET_DatastoreValue * use;
+ GNUNET_DatastoreValue *enc;
+ const GNUNET_DatastoreValue *use;
- size = ntohl(value->size) - sizeof(GNUNET_DatastoreValue);
- dblock = (const DBlock*) &value[1];
+ size = ntohl (value->size) - sizeof (GNUNET_DatastoreValue);
+ dblock = (const DBlock *) &value[1];
enc = NULL;
- if ( (ntohl(dblock->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND) &&
- (GNUNET_OK != GNUNET_FS_ONDEMAND_get_indexed_content(value,
- key,
- &enc)) )
- return GNUNET_OK; /* data corrupt, continue to search */
+ if ((ntohl (dblock->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND) &&
+ (GNUNET_OK != GNUNET_FS_ONDEMAND_get_indexed_content (value,
+ key, &enc)))
+ return GNUNET_OK; /* data corrupt, continue to search */
if (enc == NULL)
use = value;
else
use = enc;
- size = ntohl(use->size) - sizeof(GNUNET_DatastoreValue);
- dblock = (const DBlock*) &use[1];
- msg = GNUNET_malloc(sizeof(CS_fs_reply_content_MESSAGE) + size);
- msg->header.type = htons(GNUNET_CS_PROTO_GAP_RESULT);
- msg->header.size = htons(sizeof(CS_fs_reply_content_MESSAGE) + size);
+ size = ntohl (use->size) - sizeof (GNUNET_DatastoreValue);
+ dblock = (const DBlock *) &use[1];
+ msg = GNUNET_malloc (sizeof (CS_fs_reply_content_MESSAGE) + size);
+ msg->header.type = htons (GNUNET_CS_PROTO_GAP_RESULT);
+ msg->header.size = htons (sizeof (CS_fs_reply_content_MESSAGE) + size);
msg->anonymityLevel = use->anonymityLevel;
msg->expirationTime = use->expirationTime;
- memcpy(&msg[1],
- dblock,
- size);
- GNUNET_free_non_null(enc);
- coreAPI->cs_send_to_client(sock, &msg->header, GNUNET_YES);
- GNUNET_free(msg);
- if (ntohl(dblock->type) == GNUNET_ECRS_BLOCKTYPE_DATA)
- return GNUNET_SYSERR; /* unique response */
+ memcpy (&msg[1], dblock, size);
+ GNUNET_free_non_null (enc);
+ coreAPI->cs_send_to_client (sock, &msg->header, GNUNET_YES);
+ GNUNET_free (msg);
+ if (ntohl (dblock->type) == GNUNET_ECRS_BLOCKTYPE_DATA)
+ return GNUNET_SYSERR; /* unique response */
return GNUNET_OK;
}
@@ -420,7 +421,7 @@
*/
static int
handle_cs_query_start_request (struct GNUNET_ClientHandle *sock,
- const GNUNET_MessageHeader * req)
+ const GNUNET_MessageHeader * req)
{
static GNUNET_PeerIdentity all_zeros;
const CS_fs_request_search_MESSAGE *rs;
@@ -437,21 +438,18 @@
rs = (const CS_fs_request_search_MESSAGE *) req;
type = ntohl (rs->type);
/* try "fast path" avoiding gap/dht if unique reply is locally available */
- if (GNUNET_SYSERR == datastore->get(&rs->query[0],
- type,
- &fast_path_processor, sock))
+ if (GNUNET_SYSERR == datastore->get (&rs->query[0],
+ type, &fast_path_processor, sock))
return GNUNET_OK;
- anonymityLevel = ntohl(rs->anonymityLevel);
+ anonymityLevel = ntohl (rs->anonymityLevel);
keyCount =
1 + (ntohs (req->size) -
sizeof (CS_fs_request_search_MESSAGE)) / sizeof (GNUNET_HashCode);
- have_target = memcmp (&all_zeros, &rs->target, sizeof (GNUNET_PeerIdentity))
!= 0;
- GNUNET_FS_QUERYMANAGER_start_query (&rs->query[0],
- keyCount,
- anonymityLevel,
- type,
- sock,
- have_target ? &rs->target : NULL);
+ have_target =
+ memcmp (&all_zeros, &rs->target, sizeof (GNUNET_PeerIdentity)) != 0;
+ GNUNET_FS_QUERYMANAGER_start_query (&rs->query[0], keyCount, anonymityLevel,
+ type, sock,
+ have_target ? &rs->target : NULL);
return GNUNET_OK;
}
@@ -475,9 +473,9 @@
*/
static int
handle_p2p_query (const GNUNET_PeerIdentity * sender,
- const GNUNET_MessageHeader * msg)
+ const GNUNET_MessageHeader * msg)
{
- const P2P_gap_query_MESSAGE * req;
+ const P2P_gap_query_MESSAGE *req;
unsigned int query_count;
unsigned short size;
unsigned int bloomfilter_size;
@@ -505,20 +503,22 @@
#endif
return GNUNET_OK;
}
- size = ntohs(msg->size);
- if (size < sizeof(P2P_gap_query_MESSAGE))
+ size = ntohs (msg->size);
+ if (size < sizeof (P2P_gap_query_MESSAGE))
{
GNUNET_GE_BREAK_OP (ectx, 0);
return GNUNET_SYSERR; /* malformed query */
}
- req = (const P2P_gap_query_MESSAGE*) msg;
- query_count = ntohl(req->number_of_queries);
- if ( (query_count == 0) ||
- (query_count > GNUNET_MAX_BUFFER_SIZE / sizeof(GNUNET_HashCode)) ||
- (size < sizeof(P2P_gap_query_MESSAGE) + (query_count-1) *
sizeof(GNUNET_HashCode)) ||
- (0 == memcmp (&req->returnTo,
- coreAPI->myIdentity,
- sizeof (GNUNET_PeerIdentity))) )
+ req = (const P2P_gap_query_MESSAGE *) msg;
+ query_count = ntohl (req->number_of_queries);
+ if ((query_count == 0) ||
+ (query_count > GNUNET_MAX_BUFFER_SIZE / sizeof (GNUNET_HashCode)) ||
+ (size <
+ sizeof (P2P_gap_query_MESSAGE) + (query_count -
+ 1) * sizeof (GNUNET_HashCode))
+ || (0 ==
+ memcmp (&req->returnTo, coreAPI->myIdentity,
+ sizeof (GNUNET_PeerIdentity))))
{
GNUNET_GE_BREAK_OP (ectx, 0);
return GNUNET_SYSERR; /* malformed query */
@@ -526,28 +526,29 @@
if (stats != NULL)
stats->change (stat_gap_query_received, 1);
- bloomfilter_size = size - (sizeof(P2P_gap_query_MESSAGE) + (query_count-1) *
sizeof(GNUNET_HashCode));
- GNUNET_GE_ASSERT(NULL, bloomfilter_size < size);
- prio = ntohl (req->priority);
+ bloomfilter_size =
+ size - (sizeof (P2P_gap_query_MESSAGE) +
+ (query_count - 1) * sizeof (GNUNET_HashCode));
+ GNUNET_GE_ASSERT (NULL, bloomfilter_size < size);
+ prio = ntohl (req->priority);
netLoad =
- GNUNET_network_monitor_get_load (coreAPI->load_monitor,
- GNUNET_ND_UPLOAD);
- if ( (netLoad == (unsigned int) -1) ||
- (netLoad < GAP_IDLE_LOAD_THRESHOLD) )
+ GNUNET_network_monitor_get_load (coreAPI->load_monitor, GNUNET_ND_UPLOAD);
+ if ((netLoad == (unsigned int) -1) || (netLoad < GAP_IDLE_LOAD_THRESHOLD))
{
- prio = 0; /* minimum priority, no charge! */
+ prio = 0; /* minimum priority, no charge! */
policy = GNUNET_FS_RoutingPolicy_ALL;
}
- else
+ else
{
- prio = - identity->changeHostTrust (sender, -prio);
+ prio = -identity->changeHostTrust (sender, -prio);
if (netLoad < GAP_IDLE_LOAD_THRESHOLD + prio)
- policy = GNUNET_FS_RoutingPolicy_ALL;
+ policy = GNUNET_FS_RoutingPolicy_ALL;
else if (netLoad < 90 + 10 * prio)
- policy = GNUNET_FS_RoutingPolicy_ANSWER |
GNUNET_FS_RoutingPolicy_FORWARD;
+ policy =
+ GNUNET_FS_RoutingPolicy_ANSWER | GNUNET_FS_RoutingPolicy_FORWARD;
else if (netLoad < 100)
- policy = GNUNET_FS_RoutingPolicy_ANSWER;
- return GNUNET_OK; /* drop */
+ policy = GNUNET_FS_RoutingPolicy_ANSWER;
+ return GNUNET_OK; /* drop */
}
if ((policy & GNUNET_FS_RoutingPolicy_INDIRECT) > 0)
{
@@ -560,17 +561,16 @@
respond_to = *sender;
prio = 0;
}
- ttl = GNUNET_FS_HELPER_bound_ttl(ntohl (req->ttl),
- prio);
- type = ntohl(req->type);
+ ttl = GNUNET_FS_HELPER_bound_ttl (ntohl (req->ttl), prio);
+ type = ntohl (req->type);
/* decrement ttl (always) */
if (ttl < 0)
{
ttl -= 2 * TTL_DECREMENT +
GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, TTL_DECREMENT);
if (ttl > 0)
- /* integer underflow => drop (should be very rare)! */
- return GNUNET_OK;
+ /* integer underflow => drop (should be very rare)! */
+ return GNUNET_OK;
}
else
{
@@ -584,15 +584,15 @@
preference = QUERY_BANDWIDTH_VALUE;
coreAPI->preferTrafficFrom (sender, preference);
GNUNET_FS_GAP_execute_query (&respond_to,
- prio,
- policy,
- ttl,
- type,
- query_count,
- &req->queries[0],
- ntohl(req->filter_mutator),
- bloomfilter_size,
- &req->queries[query_count+1]);
+ prio,
+ policy,
+ ttl,
+ type,
+ query_count,
+ &req->queries[0],
+ ntohl (req->filter_mutator),
+ bloomfilter_size,
+ &req->queries[query_count + 1]);
return GNUNET_OK;
}
@@ -602,13 +602,13 @@
* @param hostId the peer from where the content came,
* NULL for the local peer
*/
-static int
+static int
handle_p2p_content (const GNUNET_PeerIdentity * sender,
- const GNUNET_MessageHeader * pmsg)
+ const GNUNET_MessageHeader * pmsg)
{
const P2P_gap_reply_MESSAGE *msg;
- const DBlock * dblock;
- GNUNET_DatastoreValue * value;
+ const DBlock *dblock;
+ GNUNET_DatastoreValue *value;
GNUNET_HashCode query;
unsigned short size;
unsigned int data_size;
@@ -616,7 +616,7 @@
unsigned long long expiration;
double preference;
- size = ntohs(pmsg->size);
+ size = ntohs (pmsg->size);
if (size < sizeof (P2P_gap_reply_MESSAGE))
{
GNUNET_GE_BREAK_OP (ectx, 0);
@@ -624,60 +624,51 @@
}
msg = (const P2P_gap_reply_MESSAGE *) pmsg;
data_size = size - sizeof (P2P_gap_reply_MESSAGE);
- dblock = (const DBlock*) &msg[1];
- if (GNUNET_OK !=
- GNUNET_EC_file_block_check_and_get_query(data_size,
- dblock,
- GNUNET_YES,
- &query))
+ dblock = (const DBlock *) &msg[1];
+ if (GNUNET_OK !=
+ GNUNET_EC_file_block_check_and_get_query (data_size,
+ dblock, GNUNET_YES, &query))
{
GNUNET_GE_BREAK_OP (ectx, 0);
return GNUNET_SYSERR; /* invalid! */
}
if (stats != NULL)
stats->change (stat_gap_content_received, 1);
- expiration = GNUNET_ntohll(msg->expiration);
+ expiration = GNUNET_ntohll (msg->expiration);
/* forward to other peers */
- prio = GNUNET_FS_GAP_handle_response(sender,
- &query,
- expiration,
- data_size,
- dblock);
+ prio = GNUNET_FS_GAP_handle_response (sender,
+ &query,
+ expiration, data_size, dblock);
/* forward to local clients */
- prio += GNUNET_FS_QUERYMANAGER_handle_response(sender,
- &query,
- expiration,
- data_size,
- dblock);
+ prio += GNUNET_FS_QUERYMANAGER_handle_response (sender,
+ &query,
+ expiration,
+ data_size, dblock);
/* FIXME: offer to migration module? */
- if ( (sender != NULL) &&
- ( (prio > 0) || (! test_load_too_high ()) ) )
+ if ((sender != NULL) && ((prio > 0) || (!test_load_too_high ())))
{
/* consider storing in local datastore */
- value = GNUNET_malloc (data_size +
- sizeof (GNUNET_DatastoreValue));
- value->size = htonl (data_size +
- sizeof (GNUNET_DatastoreValue));
+ value = GNUNET_malloc (data_size + sizeof (GNUNET_DatastoreValue));
+ value->size = htonl (data_size + sizeof (GNUNET_DatastoreValue));
value->type = dblock->type;
value->prio = htonl (prio);
- value->anonymityLevel = htonl(1);
- value->expirationTime = GNUNET_htonll(expiration + GNUNET_get_time());
+ value->anonymityLevel = htonl (1);
+ value->expirationTime = GNUNET_htonll (expiration + GNUNET_get_time ());
memcpy (&value[1], dblock, data_size);
- datastore->putUpdate(&query,
- value);
+ datastore->putUpdate (&query, value);
GNUNET_free (value);
}
if (sender != NULL)
{ /* if we are the sender, sender will be NULL */
identity->changeHostTrust (sender, prio);
if (stats != NULL)
- stats->change (stat_gap_trust_awarded, prio);
+ stats->change (stat_gap_trust_awarded, prio);
preference = (double) prio;
if (preference < CONTENT_BANDWIDTH_VALUE)
preference = CONTENT_BANDWIDTH_VALUE;
coreAPI->preferTrafficFrom (sender, preference);
}
- return GNUNET_OK;
+ return GNUNET_OK;
}
@@ -702,13 +693,12 @@
GNUNET_GE_ASSERT (ectx, sizeof (P2P_gap_reply_MESSAGE) == 68);
GNUNET_GE_ASSERT (ectx, sizeof (P2P_gap_query_MESSAGE) == 144);
- if ( (-1 == GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "LOAD",
"HARDCPULIMIT", 0, 100000, /* 1000 CPUs!? */
- 0, /* 0 == no
limit */
- &hardCPULimit)) ||
- (-1 == GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "LOAD",
"HARDUPLIMIT", 0, 999999999, 0, /* 0 == no limit */
- &hardUpLimit)) )
- return GNUNET_SYSERR;
-
+ if ((-1 == GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "LOAD",
"HARDCPULIMIT", 0, 100000, /* 1000 CPUs!? */
+ 0, /* 0 == no
limit */
+ &hardCPULimit)) || (-1
== GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "LOAD",
"HARDUPLIMIT", 0, 999999999, 0, /* 0 == no limit */
+
&hardUpLimit)))
+ return GNUNET_SYSERR;
+
stats = capi->request_service ("stats");
if (stats != NULL)
{
@@ -723,26 +713,26 @@
if (identity == NULL)
{
GNUNET_GE_BREAK (ectx, 0);
- capi->release_service(stats);
+ capi->release_service (stats);
return GNUNET_SYSERR;
}
datastore = capi->request_service ("datastore");
if (datastore == NULL)
{
- capi->release_service(identity);
- capi->release_service(stats);
+ capi->release_service (identity);
+ capi->release_service (stats);
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
}
GNUNET_FS_lock = GNUNET_mutex_create (GNUNET_YES);
- GNUNET_FS_ANONYMITY_init(capi);
- GNUNET_FS_PLAN_init(capi);
- GNUNET_FS_ONDEMAND_init(capi);
- GNUNET_FS_PT_init(ectx, stats);
- GNUNET_FS_QUERYMANAGER_init(capi);
- GNUNET_FS_DHT_init(capi);
- GNUNET_FS_GAP_init(capi);
- GNUNET_FS_MIGRATION_init(capi);
+ GNUNET_FS_ANONYMITY_init (capi);
+ GNUNET_FS_PLAN_init (capi);
+ GNUNET_FS_ONDEMAND_init (capi);
+ GNUNET_FS_PT_init (ectx, stats);
+ GNUNET_FS_QUERYMANAGER_init (capi);
+ GNUNET_FS_DHT_init (capi);
+ GNUNET_FS_GAP_init (capi);
+ GNUNET_FS_MIGRATION_init (capi);
GNUNET_GE_LOG (ectx, GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
_
("`%s' registering client handlers %d %d %d %d %d %d %d and
P2P handlers %d %d\n"),
@@ -751,14 +741,15 @@
GNUNET_CS_PROTO_GAP_INDEX, GNUNET_CS_PROTO_GAP_DELETE,
GNUNET_CS_PROTO_GAP_UNINDEX, GNUNET_CS_PROTO_GAP_TESTINDEX,
GNUNET_CS_PROTO_GAP_INIT_INDEX,
- GNUNET_P2P_PROTO_GAP_QUERY,
- GNUNET_P2P_PROTO_GAP_RESULT);
+ GNUNET_P2P_PROTO_GAP_QUERY, GNUNET_P2P_PROTO_GAP_RESULT);
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->registerHandler (GNUNET_P2P_PROTO_GAP_QUERY,
&handle_p2p_query));
+ capi->registerHandler (GNUNET_P2P_PROTO_GAP_QUERY,
+ &handle_p2p_query));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- capi->registerHandler (GNUNET_P2P_PROTO_GAP_RESULT,
&handle_p2p_content));
+ capi->registerHandler (GNUNET_P2P_PROTO_GAP_RESULT,
+ &handle_p2p_content));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
capi->
@@ -808,12 +799,14 @@
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- coreAPI->unregisterHandler (GNUNET_P2P_PROTO_GAP_QUERY,
&handle_p2p_query));
+ coreAPI->unregisterHandler (GNUNET_P2P_PROTO_GAP_QUERY,
+ &handle_p2p_query));
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
- coreAPI->unregisterHandler (GNUNET_P2P_PROTO_GAP_RESULT,
&handle_p2p_content));
-
+ coreAPI->unregisterHandler (GNUNET_P2P_PROTO_GAP_RESULT,
+ &handle_p2p_content));
+
GNUNET_GE_ASSERT (ectx,
GNUNET_SYSERR !=
coreAPI->
@@ -849,14 +842,14 @@
coreAPI->
unregisterClientHandler (GNUNET_CS_PROTO_GAP_TESTINDEX,
&handle_cs_test_indexed_request));
- GNUNET_FS_MIGRATION_done();
- GNUNET_FS_GAP_done();
- GNUNET_FS_DHT_done();
- GNUNET_FS_QUERYMANAGER_done();
- GNUNET_FS_PT_done();
- GNUNET_FS_ONDEMAND_done();
- GNUNET_FS_PLAN_done();
- GNUNET_FS_ANONYMITY_done();
+ GNUNET_FS_MIGRATION_done ();
+ GNUNET_FS_GAP_done ();
+ GNUNET_FS_DHT_done ();
+ GNUNET_FS_QUERYMANAGER_done ();
+ GNUNET_FS_PT_done ();
+ GNUNET_FS_ONDEMAND_done ();
+ GNUNET_FS_PLAN_done ();
+ GNUNET_FS_ANONYMITY_done ();
if (stats != NULL)
{
coreAPI->release_service (stats);
@@ -868,7 +861,7 @@
identity = NULL;
- GNUNET_mutex_destroy(GNUNET_FS_lock);
+ GNUNET_mutex_destroy (GNUNET_FS_lock);
GNUNET_FS_lock = NULL;
}
Modified: GNUnet/src/applications/fs/gap/fs_dht.c
===================================================================
--- GNUnet/src/applications/fs/gap/fs_dht.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/fs_dht.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -40,9 +40,9 @@
struct ActiveRequestRecords
{
- struct ActiveRequestRecords * next;
+ struct ActiveRequestRecords *next;
- struct GNUNET_DHT_GetHandle * handle;
+ struct GNUNET_DHT_GetHandle *handle;
GNUNET_CronTime end_time;
@@ -50,53 +50,53 @@
};
-static GNUNET_DHT_ServiceAPI * dht;
+static GNUNET_DHT_ServiceAPI *dht;
-static GNUNET_CoreAPIForPlugins * coreAPI;
+static GNUNET_CoreAPIForPlugins *coreAPI;
-static struct GNUNET_Mutex * lock;
+static struct GNUNET_Mutex *lock;
-static struct ActiveRequestRecords * records;
+static struct ActiveRequestRecords *records;
/**
* Cancel all requests with the DHT that
* are older than a certain time limit.
*/
static void
-purge_old_records(GNUNET_CronTime limit)
+purge_old_records (GNUNET_CronTime limit)
{
- struct ActiveRequestRecords * pos;
- struct ActiveRequestRecords * prev;
+ struct ActiveRequestRecords *pos;
+ struct ActiveRequestRecords *prev;
prev = NULL;
pos = records;
while (pos != NULL)
{
if (pos->end_time < limit)
- {
- if (prev == NULL)
- records = pos->next;
- else
- prev->next = pos->next;
- dht->get_stop(pos->handle);
- GNUNET_free(pos);
- if (prev == NULL)
- pos = records;
- else
- pos = prev->next;
- }
+ {
+ if (prev == NULL)
+ records = pos->next;
+ else
+ prev->next = pos->next;
+ dht->get_stop (pos->handle);
+ GNUNET_free (pos);
+ if (prev == NULL)
+ pos = records;
+ else
+ pos = prev->next;
+ }
else
- {
- prev = pos;
- pos = pos->next;
- }
+ {
+ prev = pos;
+ pos = pos->next;
+ }
}
}
/**
* We got a result from the DHT. Check that it is valid
- * and pass to our clients.
+ * and pass to our clients.
*
* @param key the current key
* @param value the current value
@@ -104,43 +104,36 @@
* @return GNUNET_OK to continue with iteration, GNUNET_SYSERR to abort
*/
static int
-response_callback(const GNUNET_HashCode * key,
- const GNUNET_DataContainer * value,
- void *cls)
+response_callback (const GNUNET_HashCode * key,
+ const GNUNET_DataContainer * value, void *cls)
{
- struct ActiveRequestRecords * record = cls;
+ struct ActiveRequestRecords *record = cls;
unsigned int size;
- const DBlock * dblock;
+ const DBlock *dblock;
GNUNET_HashCode hc;
- size = ntohl(value->size);
+ size = ntohl (value->size);
if (size < 4)
{
- GNUNET_GE_BREAK_OP(NULL, 0);
+ GNUNET_GE_BREAK_OP (NULL, 0);
return GNUNET_OK;
}
- dblock = (const DBlock*) &value[1];
- if ( (GNUNET_SYSERR ==
- GNUNET_EC_file_block_check_and_get_query(size,
- dblock,
- GNUNET_YES,
- &hc)) ||
- (0 != memcmp(key,
- &hc,
- sizeof(GNUNET_HashCode))) )
- {
- GNUNET_GE_BREAK_OP(NULL, 0);
+ dblock = (const DBlock *) &value[1];
+ if ((GNUNET_SYSERR ==
+ GNUNET_EC_file_block_check_and_get_query (size,
+ dblock,
+ GNUNET_YES,
+ &hc)) ||
+ (0 != memcmp (key, &hc, sizeof (GNUNET_HashCode))))
+ {
+ GNUNET_GE_BREAK_OP (NULL, 0);
return GNUNET_OK;
}
- GNUNET_FS_QUERYMANAGER_handle_response(NULL,
- &hc,
- 0,
- size,
- dblock);
+ GNUNET_FS_QUERYMANAGER_handle_response (NULL, &hc, 0, size, dblock);
if (record->type == GNUNET_ECRS_BLOCKTYPE_DATA)
{
- record->end_time = 0; /* delete ASAP */
- return GNUNET_SYSERR; /* no more! */
+ record->end_time = 0; /* delete ASAP */
+ return GNUNET_SYSERR; /* no more! */
}
return GNUNET_OK;
}
@@ -154,48 +147,43 @@
* @param querie hash code of the query
*/
void
-GNUNET_FS_DHT_execute_query(unsigned int type,
- const GNUNET_HashCode * query)
+GNUNET_FS_DHT_execute_query (unsigned int type, const GNUNET_HashCode * query)
{
- struct ActiveRequestRecords * record;
+ struct ActiveRequestRecords *record;
GNUNET_CronTime now;
if (dht == NULL)
return;
- now = GNUNET_get_time();
- record = GNUNET_malloc(sizeof(struct ActiveRequestRecords));
+ now = GNUNET_get_time ();
+ record = GNUNET_malloc (sizeof (struct ActiveRequestRecords));
record->end_time = now + MAX_DHT_DELAY;
- record->handle = dht->get_start(type,
- query,
- &response_callback,
- record);
+ record->handle = dht->get_start (type, query, &response_callback, record);
record->type = type;
- GNUNET_mutex_lock(lock);
+ GNUNET_mutex_lock (lock);
record->next = records;
records = record;
- purge_old_records(now);
- GNUNET_mutex_unlock(lock);
+ purge_old_records (now);
+ GNUNET_mutex_unlock (lock);
}
int
-GNUNET_FS_DHT_init(GNUNET_CoreAPIForPlugins * capi)
+GNUNET_FS_DHT_init (GNUNET_CoreAPIForPlugins * capi)
{
coreAPI = capi;
- lock = GNUNET_mutex_create(GNUNET_YES);
- dht = capi->request_service("dht");
+ lock = GNUNET_mutex_create (GNUNET_YES);
+ dht = capi->request_service ("dht");
return 0;
}
int
-GNUNET_FS_DHT_done()
+GNUNET_FS_DHT_done ()
{
- purge_old_records(-1);
+ purge_old_records (-1);
if (dht != NULL)
- coreAPI->release_service(dht);
+ coreAPI->release_service (dht);
coreAPI = NULL;
- GNUNET_mutex_destroy(lock);
+ GNUNET_mutex_destroy (lock);
lock = NULL;
return 0;
}
-
Modified: GNUnet/src/applications/fs/gap/fs_dht.h
===================================================================
--- GNUnet/src/applications/fs/gap/fs_dht.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/fs_dht.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -29,11 +29,9 @@
#include "gnunet_util.h"
-int
-GNUNET_FS_DHT_init(GNUNET_CoreAPIForPlugins * capi);
+int GNUNET_FS_DHT_init (GNUNET_CoreAPIForPlugins * capi);
-int
-GNUNET_FS_DHT_done(void);
+int GNUNET_FS_DHT_done (void);
/**
* Execute a GAP query. Determines where to forward
@@ -44,7 +42,7 @@
* @param querie hash code of the query
*/
void
-GNUNET_FS_DHT_execute_query(unsigned int type,
- const GNUNET_HashCode * query);
+GNUNET_FS_DHT_execute_query (unsigned int type,
+ const GNUNET_HashCode * query);
#endif
Modified: GNUnet/src/applications/fs/gap/gap.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/gap.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -37,13 +37,13 @@
/**
* The GAP routing table.
*/
-static struct RequestList ** table;
+static struct RequestList **table;
-static GNUNET_CoreAPIForPlugins * coreAPI;
+static GNUNET_CoreAPIForPlugins *coreAPI;
-static GNUNET_Datastore_ServiceAPI * datastore;
+static GNUNET_Datastore_ServiceAPI *datastore;
-static struct GNUNET_CronManager * cron;
+static struct GNUNET_CronManager *cron;
/**
* Size of the routing table.
@@ -59,12 +59,11 @@
static unsigned int
-get_table_index(const GNUNET_HashCode * key)
+get_table_index (const GNUNET_HashCode * key)
{
unsigned int res
= (((unsigned int *) key)[0] ^
- ((unsigned int *) key)[1] / (1 + random_qsel))
- % table_size;
+ ((unsigned int *) key)[1] / (1 + random_qsel)) % table_size;
GNUNET_GE_ASSERT (coreAPI->ectx, res < table_size);
return res;
}
@@ -73,16 +72,14 @@
* Cron-job to inject (artificially) delayed messages.
*/
static void
-send_delayed(void * cls)
+send_delayed (void *cls)
{
- GNUNET_MessageHeader * msg = cls;
-
- coreAPI->p2p_inject_message(NULL,
- (const char*) msg,
- ntohl(msg->size),
- GNUNET_YES,
- NULL);
- GNUNET_free(msg);
+ GNUNET_MessageHeader *msg = cls;
+
+ coreAPI->p2p_inject_message (NULL,
+ (const char *) msg,
+ ntohl (msg->size), GNUNET_YES, NULL);
+ GNUNET_free (msg);
}
/**
@@ -92,7 +89,7 @@
* 1) abort if the load is getting too high
* 2) try on-demand encoding (and if that fails,
* discard the entry)
- * 3) assemble a response and inject it via
+ * 3) assemble a response and inject it via
* loopback WITH a delay
*
* @param datum called with the next item
@@ -103,69 +100,62 @@
* @return GNUNET_SYSERR to abort the iteration, GNUNET_OK to continue,
* GNUNET_NO to delete the item and continue (if supported)
*/
-static int
+static int
datastore_value_processor (const GNUNET_HashCode * key,
- const GNUNET_DatastoreValue *
- value, void *closure,
- unsigned long long uid)
+ const GNUNET_DatastoreValue *
+ value, void *closure, unsigned long long uid)
{
- struct RequestList * req = closure;
- P2P_gap_reply_MESSAGE * msg;
- GNUNET_DatastoreValue * enc;
+ struct RequestList *req = closure;
+ P2P_gap_reply_MESSAGE *msg;
+ GNUNET_DatastoreValue *enc;
unsigned int size;
unsigned long long et;
GNUNET_CronTime now;
int ret;
GNUNET_HashCode hc;
GNUNET_HashCode mhc;
-
+
enc = NULL;
- if (ntohl(value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND)
+ if (ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND)
{
if (GNUNET_OK !=
- GNUNET_FS_ONDEMAND_get_indexed_content(value,
- key,
- &enc))
- return GNUNET_NO;
+ GNUNET_FS_ONDEMAND_get_indexed_content (value, key, &enc))
+ return GNUNET_NO;
value = enc;
}
if (req->bloomfilter != NULL)
{
- GNUNET_hash(&value[1],
- ntohl(value->size) - sizeof(GNUNET_DatastoreValue),
- &hc);
- GNUNET_FS_HELPER_mingle_hash(&hc,
- req->bloomfilter_mutator,
- &mhc);
- if (GNUNET_YES == GNUNET_bloomfilter_test(req->bloomfilter,
- &mhc))
- return GNUNET_OK; /* not useful */
+ GNUNET_hash (&value[1],
+ ntohl (value->size) - sizeof (GNUNET_DatastoreValue), &hc);
+ GNUNET_FS_HELPER_mingle_hash (&hc, req->bloomfilter_mutator, &mhc);
+ if (GNUNET_YES == GNUNET_bloomfilter_test (req->bloomfilter, &mhc))
+ return GNUNET_OK; /* not useful */
}
- et = GNUNET_ntohll(value->expirationTime);
- now = GNUNET_get_time();
+ et = GNUNET_ntohll (value->expirationTime);
+ now = GNUNET_get_time ();
if (now > et)
et -= now;
else
et = 0;
et %= MAX_MIGRATION_EXP;
- size = sizeof(P2P_gap_reply_MESSAGE) + ntohl(value->size) -
sizeof(GNUNET_DatastoreValue);
- msg = GNUNET_malloc(size);
- msg->header.type = htons(GNUNET_P2P_PROTO_GAP_RESULT);
- msg->header.size = htons(size);
- msg->reserved = htonl(0);
+ size =
+ sizeof (P2P_gap_reply_MESSAGE) + ntohl (value->size) -
+ sizeof (GNUNET_DatastoreValue);
+ msg = GNUNET_malloc (size);
+ msg->header.type = htons (GNUNET_P2P_PROTO_GAP_RESULT);
+ msg->header.size = htons (size);
+ msg->reserved = htonl (0);
msg->expiration = et;
- memcpy(&msg[1],
- &value[1],
- size - sizeof(P2P_gap_reply_MESSAGE));
- GNUNET_cron_add_job(cron,
- send_delayed,
- GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
- TTL_DECREMENT),
- 0,
- msg);
- ret = (ntohl(value->type) == GNUNET_ECRS_BLOCKTYPE_DATA) ? GNUNET_SYSERR :
GNUNET_OK;
- GNUNET_free(msg);
- GNUNET_free_non_null(enc);
+ memcpy (&msg[1], &value[1], size - sizeof (P2P_gap_reply_MESSAGE));
+ GNUNET_cron_add_job (cron,
+ send_delayed,
+ GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK,
+ TTL_DECREMENT), 0, msg);
+ ret =
+ (ntohl (value->type) ==
+ GNUNET_ECRS_BLOCKTYPE_DATA) ? GNUNET_SYSERR : GNUNET_OK;
+ GNUNET_free (msg);
+ GNUNET_free_non_null (enc);
return ret;
}
@@ -185,206 +175,197 @@
* @param bloomfilter_data the bloom filter bits
*/
void
-GNUNET_FS_GAP_execute_query(const GNUNET_PeerIdentity * respond_to,
- unsigned int priority,
- enum GNUNET_FS_RoutingPolicy policy,
- int ttl,
- unsigned int type,
- unsigned int query_count,
- const GNUNET_HashCode * queries,
- int filter_mutator,
- unsigned int filter_size,
- const void * bloomfilter_data)
+GNUNET_FS_GAP_execute_query (const GNUNET_PeerIdentity * respond_to,
+ unsigned int priority,
+ enum GNUNET_FS_RoutingPolicy policy,
+ int ttl,
+ unsigned int type,
+ unsigned int query_count,
+ const GNUNET_HashCode * queries,
+ int filter_mutator,
+ unsigned int filter_size,
+ const void *bloomfilter_data)
{
- struct RequestList * rl;
+ struct RequestList *rl;
PID_INDEX peer;
unsigned int index;
GNUNET_CronTime now;
- GNUNET_GE_ASSERT(NULL, query_count > 0);
- peer = GNUNET_FS_PT_intern(respond_to);
- GNUNET_mutex_lock(GNUNET_FS_lock);
- index = get_table_index(&queries[0]);
- now = GNUNET_get_time();
+ GNUNET_GE_ASSERT (NULL, query_count > 0);
+ peer = GNUNET_FS_PT_intern (respond_to);
+ GNUNET_mutex_lock (GNUNET_FS_lock);
+ index = get_table_index (&queries[0]);
+ now = GNUNET_get_time ();
/* check if table is full (and/or delete old entries!) */
- if ( (table[index] != NULL) &&
- (table[index]->next != NULL) )
+ if ((table[index] != NULL) && (table[index]->next != NULL))
{
/* limit to at most two entries per slot in table */
- if ( (now + ttl < table[index]->expiration) &&
- (now + ttl < table[index]->next->expiration) )
- {
- /* do not process */
- GNUNET_mutex_unlock(GNUNET_FS_lock);
- return;
- }
- if (table[index]->expiration >
- table[index]->next->expiration)
- {
- GNUNET_FS_SHARED_free_request_list(table[index]->next);
- table[index]->next = NULL;
- }
+ if ((now + ttl < table[index]->expiration) &&
+ (now + ttl < table[index]->next->expiration))
+ {
+ /* do not process */
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ return;
+ }
+ if (table[index]->expiration > table[index]->next->expiration)
+ {
+ GNUNET_FS_SHARED_free_request_list (table[index]->next);
+ table[index]->next = NULL;
+ }
else
- {
- rl = table[index];
- table[index] = rl->next;
- GNUNET_FS_SHARED_free_request_list(rl);
- }
+ {
+ rl = table[index];
+ table[index] = rl->next;
+ GNUNET_FS_SHARED_free_request_list (rl);
+ }
}
/* create new table entry */
- rl = GNUNET_malloc(sizeof(struct RequestList) + (query_count-1) *
sizeof(GNUNET_HashCode));
- memset(rl, 0, sizeof(struct RequestList));
- memcpy(&rl->queries[0], queries, query_count * sizeof(GNUNET_HashCode));
+ rl =
+ GNUNET_malloc (sizeof (struct RequestList) +
+ (query_count - 1) * sizeof (GNUNET_HashCode));
+ memset (rl, 0, sizeof (struct RequestList));
+ memcpy (&rl->queries[0], queries, query_count * sizeof (GNUNET_HashCode));
rl->key_count = query_count;
if (filter_size > 0)
{
rl->bloomfilter_size = filter_size;
rl->bloomfilter_mutator = filter_mutator;
- rl->bloomfilter = GNUNET_bloomfilter_init(coreAPI->ectx,
- bloomfilter_data,
- filter_size,
- GAP_BLOOMFILTER_K);
+ rl->bloomfilter = GNUNET_bloomfilter_init (coreAPI->ectx,
+ bloomfilter_data,
+ filter_size,
+ GAP_BLOOMFILTER_K);
}
rl->anonymityLevel = 1;
rl->type = type;
rl->value = priority;
- rl->expiration = GNUNET_get_time() + ttl * GNUNET_CRON_SECONDS;
+ rl->expiration = GNUNET_get_time () + ttl * GNUNET_CRON_SECONDS;
rl->next = table[index];
- rl->response_target = GNUNET_FS_PT_intern(respond_to);
- table[index] = rl;
-
+ rl->response_target = GNUNET_FS_PT_intern (respond_to);
+ table[index] = rl;
+
/* check local data store */
- datastore->get(&queries[0],
- type,
- datastore_value_processor,
- rl);
+ datastore->get (&queries[0], type, datastore_value_processor, rl);
/* if not found or not unique, forward */
- GNUNET_FS_PLAN_request(NULL, peer, rl);
- GNUNET_mutex_unlock(GNUNET_FS_lock);
+ GNUNET_FS_PLAN_request (NULL, peer, rl);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
}
/**
* Handle the given response (by forwarding it to
- * other peers as necessary).
+ * other peers as necessary).
*
* @param sender who send the response (good too know
* for future routing decisions)
- * @param primary_query hash code used for lookup
+ * @param primary_query hash code used for lookup
* (note that namespace membership may
* require additional verification that has
* not yet been performed; checking the
* signature has already been done)
* @param expiration relative time until the content
- * will expire
+ * will expire
* @param size size of the data
* @param data the data itself
* @return how much was this content worth to us?
*/
unsigned int
-GNUNET_FS_GAP_handle_response(const GNUNET_PeerIdentity * sender,
- const GNUNET_HashCode * primary_query,
- GNUNET_CronTime expiration,
- unsigned int size,
- const DBlock * data)
+GNUNET_FS_GAP_handle_response (const GNUNET_PeerIdentity * sender,
+ const GNUNET_HashCode * primary_query,
+ GNUNET_CronTime expiration,
+ unsigned int size, const DBlock * data)
{
GNUNET_HashCode hc;
GNUNET_PeerIdentity target;
- struct RequestList * rl;
+ struct RequestList *rl;
unsigned int value;
- P2P_gap_reply_MESSAGE * msg;
+ P2P_gap_reply_MESSAGE *msg;
PID_INDEX rid;
- rid = GNUNET_FS_PT_intern(sender);
+ rid = GNUNET_FS_PT_intern (sender);
value = 0;
- GNUNET_mutex_lock(GNUNET_FS_lock);
- rl = table[get_table_index(primary_query)];
+ GNUNET_mutex_lock (GNUNET_FS_lock);
+ rl = table[get_table_index (primary_query)];
while (rl != NULL)
- {
- if (GNUNET_OK == GNUNET_FS_SHARED_test_valid_new_response(rl,
- primary_query,
- size,
- data,
- &hc))
- {
- GNUNET_GE_ASSERT(NULL, rl->response_target != 0);
- GNUNET_FS_PT_resolve(rl->response_target,
- &target);
- /* queue response */
- msg = GNUNET_malloc(sizeof(P2P_gap_reply_MESSAGE) + size);
- msg->header.type = htons(GNUNET_CS_PROTO_GAP_RESULT);
- msg->header.size = htons(sizeof(P2P_gap_reply_MESSAGE) + size);
- msg->reserved = 0;
- msg->expiration = GNUNET_htonll(expiration);
- memcpy(&msg[1],
- data,
- size);
- coreAPI->unicast(&target,
- &msg->header,
- BASE_REPLY_PRIORITY * (1 + rl->value),
- MAX_GAP_DELAY);
- GNUNET_free(msg);
- if ( (rl->type != GNUNET_ECRS_BLOCKTYPE_DATA) &&
- (rl->bloomfilter != NULL) )
- GNUNET_FS_SHARED_mark_response_seen(rl, &hc);
- GNUNET_FS_PLAN_success(rid, NULL, rl->response_target, rl);
- value += rl->value;
- rl->value = 0;
- }
+ {
+ if (GNUNET_OK == GNUNET_FS_SHARED_test_valid_new_response (rl,
+ primary_query,
+ size,
+ data, &hc))
+ {
+ GNUNET_GE_ASSERT (NULL, rl->response_target != 0);
+ GNUNET_FS_PT_resolve (rl->response_target, &target);
+ /* queue response */
+ msg = GNUNET_malloc (sizeof (P2P_gap_reply_MESSAGE) + size);
+ msg->header.type = htons (GNUNET_CS_PROTO_GAP_RESULT);
+ msg->header.size = htons (sizeof (P2P_gap_reply_MESSAGE) + size);
+ msg->reserved = 0;
+ msg->expiration = GNUNET_htonll (expiration);
+ memcpy (&msg[1], data, size);
+ coreAPI->unicast (&target,
+ &msg->header,
+ BASE_REPLY_PRIORITY * (1 + rl->value),
+ MAX_GAP_DELAY);
+ GNUNET_free (msg);
+ if ((rl->type != GNUNET_ECRS_BLOCKTYPE_DATA) &&
+ (rl->bloomfilter != NULL))
+ GNUNET_FS_SHARED_mark_response_seen (rl, &hc);
+ GNUNET_FS_PLAN_success (rid, NULL, rl->response_target, rl);
+ value += rl->value;
+ rl->value = 0;
+ }
rl = rl->next;
}
- GNUNET_mutex_unlock(GNUNET_FS_lock);
- GNUNET_FS_PT_change_rc(rid, -1);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ GNUNET_FS_PT_change_rc (rid, -1);
return value;
}
-int
-GNUNET_FS_GAP_init(GNUNET_CoreAPIForPlugins * capi)
+int
+GNUNET_FS_GAP_init (GNUNET_CoreAPIForPlugins * capi)
{
unsigned long long ts;
coreAPI = capi;
- datastore = capi->request_service("datastore");
+ datastore = capi->request_service ("datastore");
random_qsel = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, 0xFFFF);
if (-1 ==
- GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "GAP",
"TABLESIZE",
- MIN_INDIRECTION_TABLE_SIZE,
- GNUNET_MAX_GNUNET_malloc_CHECKED
- /
- sizeof
- (struct RequestList *),
- MIN_INDIRECTION_TABLE_SIZE,
- &ts))
+ GNUNET_GC_get_configuration_value_number (coreAPI->cfg, "GAP",
+ "TABLESIZE",
+ MIN_INDIRECTION_TABLE_SIZE,
+
GNUNET_MAX_GNUNET_malloc_CHECKED
+ /
+ sizeof (struct RequestList *),
+ MIN_INDIRECTION_TABLE_SIZE,
+ &ts))
return GNUNET_SYSERR;
table_size = ts;
- table = GNUNET_malloc (sizeof (struct RequestList*) * table_size);
- memset (table,
- 0, sizeof (struct RequestList*) * table_size);
- cron = GNUNET_cron_create(coreAPI->ectx);
- GNUNET_cron_start(cron);
+ table = GNUNET_malloc (sizeof (struct RequestList *) * table_size);
+ memset (table, 0, sizeof (struct RequestList *) * table_size);
+ cron = GNUNET_cron_create (coreAPI->ectx);
+ GNUNET_cron_start (cron);
return 0;
}
-int
-GNUNET_FS_GAP_done()
+int
+GNUNET_FS_GAP_done ()
{
unsigned int i;
- struct RequestList * rl;
+ struct RequestList *rl;
for (i = 0; i < table_size; i++)
{
while (NULL != (rl = table[i]))
- {
- table[i] = rl->next;
- GNUNET_FS_SHARED_free_request_list(rl);
- }
+ {
+ table[i] = rl->next;
+ GNUNET_FS_SHARED_free_request_list (rl);
+ }
}
- GNUNET_free(table);
- coreAPI->release_service(datastore);
+ GNUNET_free (table);
+ coreAPI->release_service (datastore);
datastore = NULL;
- GNUNET_cron_stop(cron);
- GNUNET_cron_destroy(cron);
+ GNUNET_cron_stop (cron);
+ GNUNET_cron_destroy (cron);
return 0;
}
Modified: GNUnet/src/applications/fs/gap/gap.h
===================================================================
--- GNUnet/src/applications/fs/gap/gap.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/gap.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -29,16 +29,17 @@
#include "gnunet_util.h"
#include "ecrs_core.h"
-enum GNUNET_FS_RoutingPolicy {
+enum GNUNET_FS_RoutingPolicy
+{
GNUNET_FS_RoutingPolicy_ANSWER = 1,
GNUNET_FS_RoutingPolicy_FORWARD = 2,
GNUNET_FS_RoutingPolicy_INDIRECT = 4,
GNUNET_FS_RoutingPolicy_ALL = 7
};
-int GNUNET_FS_GAP_init(GNUNET_CoreAPIForPlugins * capi);
+int GNUNET_FS_GAP_init (GNUNET_CoreAPIForPlugins * capi);
-int GNUNET_FS_GAP_done(void);
+int GNUNET_FS_GAP_done (void);
/**
* Execute a GAP query. Determines where to forward
@@ -56,39 +57,38 @@
* @param bloomfilter_data the bloom filter bits
*/
void
-GNUNET_FS_GAP_execute_query(const GNUNET_PeerIdentity * respond_to,
- unsigned int priority,
- enum GNUNET_FS_RoutingPolicy policy,
- int ttl,
- unsigned int type,
- unsigned int query_count,
- const GNUNET_HashCode * queries,
- int filter_mutator,
- unsigned int filter_size,
- const void * bloomfilter_data);
+GNUNET_FS_GAP_execute_query (const GNUNET_PeerIdentity * respond_to,
+ unsigned int priority,
+ enum GNUNET_FS_RoutingPolicy policy,
+ int ttl,
+ unsigned int type,
+ unsigned int query_count,
+ const GNUNET_HashCode * queries,
+ int filter_mutator,
+ unsigned int filter_size,
+ const void *bloomfilter_data);
/**
* Handle the given response (by forwarding it to
- * other peers as necessary).
+ * other peers as necessary).
*
* @param sender who send the response (good too know
* for future routing decisions)
- * @param primary_query hash code used for lookup
+ * @param primary_query hash code used for lookup
* (note that namespace membership may
* require additional verification that has
* not yet been performed; checking the
* signature has already been done)
* @param expiration relative time until the content
- * will expire
+ * will expire
* @param size size of the data
* @param data the data itself
* @return how much was this content worth to us?
*/
unsigned int
-GNUNET_FS_GAP_handle_response(const GNUNET_PeerIdentity * sender,
- const GNUNET_HashCode * primary_query,
- GNUNET_CronTime expiration,
- unsigned int size,
- const DBlock * data);
+GNUNET_FS_GAP_handle_response (const GNUNET_PeerIdentity * sender,
+ const GNUNET_HashCode * primary_query,
+ GNUNET_CronTime expiration,
+ unsigned int size, const DBlock * data);
#endif
Modified: GNUnet/src/applications/fs/gap/gap_old.c
===================================================================
--- GNUnet/src/applications/fs/gap/gap_old.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/gap_old.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -524,10 +524,8 @@
static QUERY_POLICY
evaluateQuery (const GNUNET_PeerIdentity * sender, unsigned int *priority)
{
- unsigned int
+unsigned int}
-}
-
/**
* Map the id to an index into the bitmap array.
*/
@@ -875,15 +873,15 @@
"Sending query `%s' to `%s'\n", &encq, &encp);
#endif
if (stats != NULL)
- {
- stats->change (stat_routing_forwards, 1);
- GNUNET_mutex_lock(lock);
- outbound_query_count++;
- outbound_total_ttls += (int) ntohl(qr->msg->ttl);
- stats->set (stat_routing_outbound_ttl,
- outbound_total_ttls / outbound_query_count);
- GNUNET_mutex_unlock(lock);
- }
+ {
+ stats->change (stat_routing_forwards, 1);
+ GNUNET_mutex_lock (lock);
+ outbound_query_count++;
+ outbound_total_ttls += (int) ntohl (qr->msg->ttl);
+ stats->set (stat_routing_outbound_ttl,
+ outbound_total_ttls / outbound_query_count);
+ GNUNET_mutex_unlock (lock);
+ }
coreAPI->unicast (peer,
&qr->msg->header,
BASE_QUERY_PRIORITY * ntohl (qr->msg->priority) * 2,
@@ -998,8 +996,7 @@
qr->noTarget = intern_pid (coreAPI->myIdentity);
qr->totalDistance = 0;
qr->rankings = GNUNET_malloc (sizeof (int) * 8 * BITMAP_SIZE);
- qr->activeConnections
- = coreAPI-> (&hotpathSelectionCode, qr);
+ qr->activeConnections = coreAPI->(&hotpathSelectionCode, qr);
/* actual selection, proportional to rankings
assigned by hotpathSelectionCode ... */
rankingSum = 0;
@@ -1037,7 +1034,7 @@
change_pid_rc (tpid, -1);
}
/* now forward to a couple of selected nodes */
- coreAPI-> (&sendToSelected, qr);
+ coreAPI->(&sendToSelected, qr);
if (qr == &dummy)
{
change_pid_rc (dummy.noTarget, -1);
@@ -1468,7 +1465,7 @@
*isRouted = GNUNET_YES;
*doForward = GNUNET_YES;
if (stats != NULL)
- stats->change (stat_routing_request_repeat, 1);
+ stats->change (stat_routing_request_repeat, 1);
addToSlot (ITE_REPLACE, ite, query, ttl, priority, sender);
return 4;
}
@@ -1534,7 +1531,7 @@
{
*doForward = GNUNET_YES;
if (stats != NULL)
- stats->change (stat_routing_request_repeat, 1);
+ stats->change (stat_routing_request_repeat, 1);
}
else
*doForward = GNUNET_NO;
@@ -2229,15 +2226,15 @@
}
}
- now = GNUNET_get_time();
+ now = GNUNET_get_time ();
if (stats != NULL)
{
- GNUNET_mutex_lock(lock);
+ GNUNET_mutex_lock (lock);
internal_total_ttls += timeout - now;
- internal_query_count++;
+ internal_query_count++;
stats->set (stat_routing_internal_ttl,
- internal_total_ttls / internal_query_count);
- GNUNET_mutex_unlock(lock);
+ internal_total_ttls / internal_query_count);
+ GNUNET_mutex_unlock (lock);
}
msg = GNUNET_malloc (size);
@@ -2372,12 +2369,12 @@
if (stats != NULL)
{
- GNUNET_mutex_lock(lock);
- external_total_ttls += (int) ntohl(qmsg->ttl);
+ GNUNET_mutex_lock (lock);
+ external_total_ttls += (int) ntohl (qmsg->ttl);
external_query_count++;
stats->set (stat_routing_external_ttl,
- external_total_ttls / external_query_count);
- GNUNET_mutex_unlock(lock);
+ external_total_ttls / external_query_count);
+ GNUNET_mutex_unlock (lock);
}
/* decrement ttl (always) */
@@ -2494,15 +2491,15 @@
ectx = capi->ectx;
cfg = capi->cfg;
coreAPI = capi;
- || (-1 ==
- GNUNET_GC_get_configuration_value_number (cfg, "GAP", "TABLESIZE",
- MIN_INDIRECTION_TABLE_SIZE,
-
GNUNET_MAX_GNUNET_malloc_CHECKED
- /
- sizeof
- (IndirectionTableEntry),
- MIN_INDIRECTION_TABLE_SIZE,
- &indirectionTableSize)))
+ ||(-1 ==
+ GNUNET_GC_get_configuration_value_number (cfg, "GAP", "TABLESIZE",
+ MIN_INDIRECTION_TABLE_SIZE,
+ GNUNET_MAX_GNUNET_malloc_CHECKED
+ /
+ sizeof
+ (IndirectionTableEntry),
+ MIN_INDIRECTION_TABLE_SIZE,
+ &indirectionTableSize)))
return NULL;
stats = capi->request_service ("stats");
@@ -2539,14 +2536,11 @@
stats->
create (gettext_noop ("# gap duplicate requests that were re-tried"));
stat_routing_external_ttl =
- stats->
- create (gettext_noop ("# gap average inbound ttl"));
+ stats->create (gettext_noop ("# gap average inbound ttl"));
stat_routing_internal_ttl =
- stats->
- create (gettext_noop ("# gap average client ttl"));
+ stats->create (gettext_noop ("# gap average client ttl"));
stat_routing_outbound_ttl =
- stats->
- create (gettext_noop ("# gap average outbound ttl"));
+ stats->create (gettext_noop ("# gap average outbound ttl"));
stat_routing_reply_dups =
stats->create (gettext_noop ("# gap reply duplicates"));
@@ -2619,8 +2613,7 @@
return &api;
}
-void
-release_module_gap ()
+void release_module_gap ()
{
unsigned int i;
ResponseList *rpos;
Modified: GNUnet/src/applications/fs/gap/migration.c
===================================================================
--- GNUnet/src/applications/fs/gap/migration.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/migration.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -124,8 +124,8 @@
GNUNET_CronTime now;
unsigned int anonymity;
GNUNET_DatastoreValue *enc;
- GNUNET_DatastoreValue *value;
- P2P_gap_reply_MESSAGE * msg;
+ GNUNET_DatastoreValue *value;
+ P2P_gap_reply_MESSAGE *msg;
unsigned int index;
int entry;
int discard_entry;
@@ -259,7 +259,8 @@
if ((ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND) ||
(ntohl (value->type) == GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD))
{
- if (GNUNET_FS_ONDEMAND_get_indexed_content (value, &content[entry].key,
&enc) != GNUNET_OK)
+ if (GNUNET_FS_ONDEMAND_get_indexed_content
+ (value, &content[entry].key, &enc) != GNUNET_OK)
{
GNUNET_free_non_null (value);
content[entry].value = NULL;
@@ -294,44 +295,41 @@
msg = position;
et = GNUNET_ntohll (value->expirationTime);
if (et > now)
- et -= now;
+ et -= now;
else
et = 0;
et %= MAX_MIGRATION_EXP;
anonymity = ntohl (value->anonymityLevel);
ret = 0;
- if ( (anonymity == 0) ||
- (GNUNET_OK == GNUNET_FS_ANONYMITY_check(anonymity,
- GNUNET_P2P_PROTO_GAP_RESULT)) )
+ if ((anonymity == 0) ||
+ (GNUNET_OK == GNUNET_FS_ANONYMITY_check (anonymity,
+ GNUNET_P2P_PROTO_GAP_RESULT)))
{
- msg->header.type = htons(GNUNET_P2P_PROTO_GAP_RESULT);
- msg->header.size = htons(size);
- msg->reserved = htonl(0);
- msg->expiration = GNUNET_htonll(et);
- memcpy(&msg[1],
- &value[1],
- size - sizeof(P2P_gap_reply_MESSAGE));
+ msg->header.type = htons (GNUNET_P2P_PROTO_GAP_RESULT);
+ msg->header.size = htons (size);
+ msg->reserved = htonl (0);
+ msg->expiration = GNUNET_htonll (et);
+ memcpy (&msg[1], &value[1], size - sizeof (P2P_gap_reply_MESSAGE));
ret = size;
if (content[entry].sentCount == MAX_RECEIVERS)
- {
- GNUNET_free (content[entry].value);
- content[entry].value = NULL;
- content[entry].sentCount = 0;
- }
+ {
+ GNUNET_free (content[entry].value);
+ content[entry].value = NULL;
+ content[entry].sentCount = 0;
+ }
else
- {
- content[entry].receiverIndices[content[entry].sentCount++] =
- index;
- }
+ {
+ content[entry].receiverIndices[content[entry].sentCount++] = index;
+ }
}
else
{
#if DEBUG_MIGRATION
GNUNET_GE_LOG (ectx,
- GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
- "Migration: not enough cover traffic\n");
+ GNUNET_GE_DEBUG | GNUNET_GE_REQUEST | GNUNET_GE_USER,
+ "Migration: not enough cover traffic\n");
#endif
- }
+ }
GNUNET_mutex_unlock (lock);
if ((ret > 0) && (stats != NULL))
stats->change (stat_migration_count, 1);
@@ -347,8 +345,7 @@
coreAPI->
connection_register_send_callback
(GNUNET_GAP_ESTIMATED_DATA_SIZE,
- GNUNET_FS_GAP_CONTENT_MIGRATION_PRIORITY,
- &activeMigrationCallback);
+ GNUNET_FS_GAP_CONTENT_MIGRATION_PRIORITY, &activeMigrationCallback);
datastore = capi->request_service ("datastore");
dht = capi->request_service ("dht");
stats = capi->request_service ("stats");
Modified: GNUnet/src/applications/fs/gap/migration.h
===================================================================
--- GNUnet/src/applications/fs/gap/migration.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/migration.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -32,11 +32,9 @@
/**
* Initialize the migration module.
*/
-void
-GNUNET_FS_MIGRATION_init (GNUNET_CoreAPIForPlugins * capi);
+void GNUNET_FS_MIGRATION_init (GNUNET_CoreAPIForPlugins * capi);
-void
-GNUNET_FS_MIGRATION_done (void);
+void GNUNET_FS_MIGRATION_done (void);
/* end of migration.h */
#endif
Modified: GNUnet/src/applications/fs/gap/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/gap/ondemand.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/ondemand.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -70,7 +70,7 @@
* Name of the directory where we store symlinks to indexed
* files.
*/
-static char * index_directory;
+static char *index_directory;
static GNUNET_State_ServiceAPI *state;
@@ -105,16 +105,14 @@
* @param fileId hash of the file for which the marker
* should be removed
*/
-static void
-remove_unavailable_mark(const GNUNET_HashCode * fileId)
+static void
+remove_unavailable_mark (const GNUNET_HashCode * fileId)
{
GNUNET_EncName enc;
char unavail_key[256];
-
- GNUNET_hash_to_enc (fileId, &enc);
- GNUNET_snprintf (unavail_key,
- 256,
- "FIRST_UNAVAILABLE-%s", (char *) &enc);
+
+ GNUNET_hash_to_enc (fileId, &enc);
+ GNUNET_snprintf (unavail_key, 256, "FIRST_UNAVAILABLE-%s", (char *) &enc);
state->unlink (coreAPI->ectx, unavail_key);
}
@@ -127,8 +125,8 @@
* or, if the condition persists, to trigger its
* removal from the database.
*/
-static void
-publish_unavailable_mark(const GNUNET_HashCode * fileId)
+static void
+publish_unavailable_mark (const GNUNET_HashCode * fileId)
{
char unavail_key[256];
GNUNET_EncName enc;
@@ -141,44 +139,41 @@
now = GNUNET_get_time ();
GNUNET_hash_to_enc (fileId, &enc);
- GNUNET_snprintf (unavail_key, 256, "FIRST_UNVAILABLE-%s",
- (char *) &enc);
+ GNUNET_snprintf (unavail_key, 256, "FIRST_UNVAILABLE-%s", (char *) &enc);
if (state->read (coreAPI->ectx, unavail_key, (void *) &first_unavail) !=
sizeof (GNUNET_CronTime))
{
now = GNUNET_htonll (now);
state->write (coreAPI->ectx,
- unavail_key, sizeof (GNUNET_CronTime),
- (void *) &now);
+ unavail_key, sizeof (GNUNET_CronTime), (void *) &now);
return;
}
- if (GNUNET_ntohll (*first_unavail) - now <
- 3 * GNUNET_CRON_DAYS)
- return; /* do nothing for first 3 days */
- fn = get_indexed_filename(fileId);
+ if (GNUNET_ntohll (*first_unavail) - now < 3 * GNUNET_CRON_DAYS)
+ return; /* do nothing for first 3 days */
+ fn = get_indexed_filename (fileId);
/* Delete it after 3 days */
len = 256;
ofn = GNUNET_malloc (len);
while (((ret = READLINK (fn, ofn, len)) == -1) &&
- (errno == ENAMETOOLONG) && (len < 4 * 1024 * 1024))
+ (errno == ENAMETOOLONG) && (len < 4 * 1024 * 1024))
if (len * 2 < len)
{
- GNUNET_GE_BREAK (coreAPI->ectx, 0);
- GNUNET_array_grow (ofn, len, 0);
- GNUNET_free (fn);
- return;
+ GNUNET_GE_BREAK (coreAPI->ectx, 0);
+ GNUNET_array_grow (ofn, len, 0);
+ GNUNET_free (fn);
+ return;
}
- GNUNET_array_grow (ofn, len, len * 2);
+ GNUNET_array_grow (ofn, len, len * 2);
if (ret != -1)
{
GNUNET_GE_LOG (coreAPI->ectx,
- GNUNET_GE_ERROR | GNUNET_GE_BULK |
- GNUNET_GE_USER,
- _
- ("Because the file `%s' has been unavailable for 3 days"
- " it got removed from your share. Please unindex files
before"
- " deleting them as the index now contains invalid
references!\n"),
- ofn);
+ GNUNET_GE_ERROR | GNUNET_GE_BULK |
+ GNUNET_GE_USER,
+ _
+ ("Because the file `%s' has been unavailable for 3 days"
+ " it got removed from your share. Please unindex files
before"
+ " deleting them as the index now contains invalid
references!\n"),
+ ofn);
}
GNUNET_free (ofn);
state->unlink (coreAPI->ectx, unavail_key);
@@ -195,17 +190,18 @@
* GNUNET_YES on success
*/
int
-GNUNET_FS_ONDEMAND_index_prepare_with_symlink (struct GNUNET_GE_Context * ectx,
- const GNUNET_HashCode * fileId, const char *fn)
+GNUNET_FS_ONDEMAND_index_prepare_with_symlink (struct GNUNET_GE_Context *ectx,
+ const GNUNET_HashCode * fileId,
+ const char *fn)
{
GNUNET_EncName enc;
char *serverFN;
GNUNET_HashCode linkId;
- if ( (GNUNET_SYSERR == GNUNET_hash_file (ectx,
- fn,
- &linkId)) ||
- (0 != memcmp (&linkId, fileId, sizeof (GNUNET_HashCode))) )
+ if ((GNUNET_SYSERR == GNUNET_hash_file (ectx,
+ fn,
+ &linkId)) ||
+ (0 != memcmp (&linkId, fileId, sizeof (GNUNET_HashCode))))
return GNUNET_SYSERR;
serverFN =
GNUNET_malloc (strlen (index_directory) + 2 + sizeof (GNUNET_EncName));
@@ -231,7 +227,7 @@
}
GNUNET_GE_free_context (ectx);
GNUNET_free (serverFN);
- remove_unavailable_mark(fileId);
+ remove_unavailable_mark (fileId);
return GNUNET_YES;
}
@@ -243,14 +239,15 @@
* GNUNET_SYSERR on other error (i.e. datastore full)
*/
int
-GNUNET_FS_ONDEMAND_add_indexed_content (struct GNUNET_GE_Context * ectx,
- GNUNET_Datastore_ServiceAPI * datastore,
- unsigned int prio,
- GNUNET_CronTime expiration,
- unsigned long long fileOffset,
- unsigned int anonymityLevel,
- const GNUNET_HashCode * fileId,
- unsigned int size, const DBlock * content)
+GNUNET_FS_ONDEMAND_add_indexed_content (struct GNUNET_GE_Context *ectx,
+ GNUNET_Datastore_ServiceAPI *
+ datastore, unsigned int prio,
+ GNUNET_CronTime expiration,
+ unsigned long long fileOffset,
+ unsigned int anonymityLevel,
+ const GNUNET_HashCode * fileId,
+ unsigned int size,
+ const DBlock * content)
{
int ret;
OnDemandBlock odb;
@@ -272,7 +269,7 @@
)
{
/* not sym-linked, write content to offset! */
- fd = GNUNET_disk_file_open (ectx, fn, O_LARGEFILE | O_CREAT | O_WRONLY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* 644 */
+ fd = GNUNET_disk_file_open (ectx, fn, O_LARGEFILE | O_CREAT | O_WRONLY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* 644 */
if (fd == -1)
{
GNUNET_free (fn);
@@ -338,8 +335,8 @@
static void
async_delete_job (void *cls)
{
- GNUNET_HashCode * query = cls;
- GNUNET_DatastoreValue * dbv = (GNUNET_DatastoreValue*) &query[1];
+ GNUNET_HashCode *query = cls;
+ GNUNET_DatastoreValue *dbv = (GNUNET_DatastoreValue *) & query[1];
datastore->del (query, dbv);
GNUNET_free (query);
@@ -351,11 +348,12 @@
* a del operation during "get" would deadlock!
*/
static void
-delete_content_asynchronously (const GNUNET_DatastoreValue * dbv, const
GNUNET_HashCode * query)
+delete_content_asynchronously (const GNUNET_DatastoreValue * dbv,
+ const GNUNET_HashCode * query)
{
- GNUNET_HashCode * ctx;
+ GNUNET_HashCode *ctx;
- ctx = GNUNET_malloc (sizeof (GNUNET_HashCode) + ntohl(dbv->size));
+ ctx = GNUNET_malloc (sizeof (GNUNET_HashCode) + ntohl (dbv->size));
*ctx = *query;
memcpy (&ctx[1], dbv, ntohl (dbv->size));
GNUNET_cron_add_job (coreAPI->cron, &async_delete_job, 0, 0, ctx);
@@ -372,8 +370,8 @@
*/
int
GNUNET_FS_ONDEMAND_get_indexed_content (const GNUNET_DatastoreValue * dbv,
- const GNUNET_HashCode * query,
- GNUNET_DatastoreValue ** enc)
+ const GNUNET_HashCode * query,
+ GNUNET_DatastoreValue ** enc)
{
char *fn;
char *iobuf;
@@ -385,8 +383,8 @@
struct stat linkStat;
- if ( (ntohl (dbv->size) != sizeof (OnDemandBlock)) ||
- (ntohl (dbv->type) != GNUNET_ECRS_BLOCKTYPE_ONDEMAND) )
+ if ((ntohl (dbv->size) != sizeof (OnDemandBlock)) ||
+ (ntohl (dbv->type) != GNUNET_ECRS_BLOCKTYPE_ONDEMAND))
{
GNUNET_GE_BREAK (coreAPI->ectx, 0);
return GNUNET_SYSERR;
@@ -405,9 +403,9 @@
fn);
/* Is the symlink (still) there? */
if (LSTAT (fn, &linkStat) == -1)
- delete_content_asynchronously (dbv, query);
+ delete_content_asynchronously (dbv, query);
else
- publish_unavailable_mark(&odb->fileId);
+ publish_unavailable_mark (&odb->fileId);
GNUNET_free (fn);
return GNUNET_SYSERR;
}
@@ -470,7 +468,7 @@
*/
int
GNUNET_FS_ONDEMAND_test_indexed_file (GNUNET_Datastore_ServiceAPI * datastore,
- const GNUNET_HashCode * fileId)
+ const GNUNET_HashCode * fileId)
{
char *fn;
int fd;
@@ -495,9 +493,10 @@
* the keys of the odb blocks).
*/
int
-GNUNET_FS_ONDEMAND_delete_indexed_content (struct GNUNET_GE_Context * ectx,
- GNUNET_Datastore_ServiceAPI * datastore,
- unsigned int blocksize, const GNUNET_HashCode * fileId)
+GNUNET_FS_ONDEMAND_delete_indexed_content (struct GNUNET_GE_Context *ectx,
+ GNUNET_Datastore_ServiceAPI *
+ datastore, unsigned int blocksize,
+ const GNUNET_HashCode * fileId)
{
char *fn;
int fd;
@@ -552,7 +551,7 @@
odb.fileId = *fileId;
/* compute the primary key */
GNUNET_EC_file_block_get_query (block, delta + sizeof (DBlock), &key);
- if (GNUNET_SYSERR == datastore->get (&key,
GNUNET_ECRS_BLOCKTYPE_ONDEMAND,
&GNUNET_FS_HELPER_complete_value_from_database_callback, &odb.header)) /*
aborted == found! */
+ if (GNUNET_SYSERR == datastore->get (&key,
GNUNET_ECRS_BLOCKTYPE_ONDEMAND,
&GNUNET_FS_HELPER_complete_value_from_database_callback, &odb.header)) /*
aborted == found! */
ret = datastore->del (&key, &odb.header);
else /* not found */
ret = GNUNET_SYSERR;
@@ -573,15 +572,16 @@
CLOSE (fd);
UNLINK (fn);
GNUNET_free (fn);
- remove_unavailable_mark(fileId);
+ remove_unavailable_mark (fileId);
return GNUNET_OK;
}
-int GNUNET_FS_ONDEMAND_init(GNUNET_CoreAPIForPlugins * capi)
+int
+GNUNET_FS_ONDEMAND_init (GNUNET_CoreAPIForPlugins * capi)
{
- char * tmp;
+ char *tmp;
coreAPI = capi;
GNUNET_GC_get_configuration_value_filename (capi->cfg,
@@ -596,8 +596,8 @@
"INDEX-DIRECTORY",
tmp, &index_directory);
GNUNET_free (tmp);
- GNUNET_disk_directory_create (coreAPI->ectx, index_directory); /* just in
case */
-
+ GNUNET_disk_directory_create (coreAPI->ectx, index_directory); /*
just in case */
+
state = capi->request_service ("state");
if (state == NULL)
{
@@ -608,8 +608,9 @@
return 0;
}
-int GNUNET_FS_ONDEMAND_done()
-{
+int
+GNUNET_FS_ONDEMAND_done ()
+{
coreAPI->release_service (state);
state = NULL;
GNUNET_free (index_directory);
Modified: GNUnet/src/applications/fs/gap/ondemand.h
===================================================================
--- GNUnet/src/applications/fs/gap/ondemand.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/ondemand.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -41,8 +41,8 @@
*/
int
GNUNET_FS_ONDEMAND_get_indexed_content (const GNUNET_DatastoreValue * dbv,
- const GNUNET_HashCode * query,
- GNUNET_DatastoreValue ** enc);
+ const GNUNET_HashCode * query,
+ GNUNET_DatastoreValue ** enc);
/**
@@ -54,8 +54,10 @@
* GNUNET_YES on success
*/
int
-GNUNET_FS_ONDEMAND_index_prepare_with_symlink (struct GNUNET_GE_Context *cectx,
- const GNUNET_HashCode * fileId,
const char *fn);
+GNUNET_FS_ONDEMAND_index_prepare_with_symlink (struct GNUNET_GE_Context
+ *cectx,
+ const GNUNET_HashCode * fileId,
+ const char *fn);
/**
* Writes the given content to the file at the specified offset
@@ -66,13 +68,14 @@
*/
int
GNUNET_FS_ONDEMAND_add_indexed_content (struct GNUNET_GE_Context *cectx,
- GNUNET_Datastore_ServiceAPI * datastore,
- unsigned int prio,
- GNUNET_CronTime expiration,
- unsigned long long fileOffset,
- unsigned int anonymityLevel,
- const GNUNET_HashCode * fileId,
- unsigned int size, const DBlock *
content);
+ GNUNET_Datastore_ServiceAPI *
+ datastore, unsigned int prio,
+ GNUNET_CronTime expiration,
+ unsigned long long fileOffset,
+ unsigned int anonymityLevel,
+ const GNUNET_HashCode * fileId,
+ unsigned int size,
+ const DBlock * content);
/**
* Test if the file with the given ID is
@@ -81,7 +84,7 @@
*/
int
GNUNET_FS_ONDEMAND_test_indexed_file (GNUNET_Datastore_ServiceAPI * datastore,
- const GNUNET_HashCode * fileId);
+ const GNUNET_HashCode * fileId);
/**
* Unindex the file with the given ID. Removes the file from the
@@ -95,11 +98,12 @@
*/
int
GNUNET_FS_ONDEMAND_delete_indexed_content (struct GNUNET_GE_Context *cectx,
- GNUNET_Datastore_ServiceAPI * datastore,
- unsigned int blocksize, const
GNUNET_HashCode * fileId);
+ GNUNET_Datastore_ServiceAPI *
+ datastore, unsigned int blocksize,
+ const GNUNET_HashCode * fileId);
-int GNUNET_FS_ONDEMAND_init(GNUNET_CoreAPIForPlugins * capi);
+int GNUNET_FS_ONDEMAND_init (GNUNET_CoreAPIForPlugins * capi);
-int GNUNET_FS_ONDEMAND_done(void);
+int GNUNET_FS_ONDEMAND_done (void);
#endif
Modified: GNUnet/src/applications/fs/gap/pid_table.c
===================================================================
--- GNUnet/src/applications/fs/gap/pid_table.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/pid_table.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -189,7 +189,7 @@
{
unsigned int i;
- for (i = 0;i<size; i++)
+ for (i = 0; i < size; i++)
GNUNET_GE_ASSERT (ectx, table[i].rc == 0);
GNUNET_array_grow (table, size, 0);
stats = NULL;
Modified: GNUnet/src/applications/fs/gap/pid_table.h
===================================================================
--- GNUnet/src/applications/fs/gap/pid_table.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/pid_table.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -31,7 +31,7 @@
#include "gnunet_stats_service.h"
void GNUNET_FS_PT_init (struct GNUNET_GE_Context *ectx,
- GNUNET_Stats_ServiceAPI * s);
+ GNUNET_Stats_ServiceAPI * s);
void GNUNET_FS_PT_done (void);
Modified: GNUnet/src/applications/fs/gap/plan.c
===================================================================
--- GNUnet/src/applications/fs/gap/plan.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/plan.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -25,7 +25,7 @@
*
* TODO:
* - code to clean up plans (remove
- * plans for peers that we are no longer
+ * plans for peers that we are no longer
* connected to) -- using cron?
*/
@@ -41,12 +41,13 @@
* Linked list summarizing how good other peers
* were at producing responses for a client.
*/
-struct PeerHistoryList {
+struct PeerHistoryList
+{
/**
* This is a linked list.
*/
- struct PeerHistoryList * next;
+ struct PeerHistoryList *next;
/**
* Last time we transmitted a request to this peer.
@@ -81,13 +82,13 @@
/**
* Priority value used for last successful request.
*/
- unsigned int last_good_prio;
+ unsigned int last_good_prio;
/**
* (Relative) TTL used in the last request.
*/
int last_ttl_used;
-
+
/**
* Priority used for the last request.
*/
@@ -98,24 +99,25 @@
/**
* Linked list with information for each client.
*/
-struct ClientInfoList {
+struct ClientInfoList
+{
/**
* This is a linked list.
*/
- struct ClientInfoList * next;
+ struct ClientInfoList *next;
/**
* For which client is this data kept (NULL
* if the "client" is another peer).
*/
- struct GNUNET_ClientHandle * client;
+ struct GNUNET_ClientHandle *client;
/**
* List of the history of reactions of other peers
* to queries from this client.
*/
- struct PeerHistoryList * history;
+ struct PeerHistoryList *history;
/**
* If "client" is NULL, this is the peer for
@@ -130,12 +132,12 @@
* used to determine which peers should be considered for forwarding
* of the query.
*/
-struct PeerRankings
+struct PeerRankings
{
/**
* This is a linked list.
*/
- struct PeerRankings * next;
+ struct PeerRankings *next;
/**
* Peer that is being ranked.
@@ -160,20 +162,20 @@
};
-static GNUNET_CoreAPIForPlugins * coreAPI;
+static GNUNET_CoreAPIForPlugins *coreAPI;
/**
* Plan for query execution (for each peer, a list of
* requests and when we should consider transmitting
* them).
*/
-static struct QueryPlanList * queries;
+static struct QueryPlanList *queries;
/**
* Information about the performance of peers
* for requests from various clients.
*/
-static struct ClientInfoList * clients;
+static struct ClientInfoList *clients;
/**
* Find the entry in the client list corresponding
@@ -181,31 +183,29 @@
* exists, create one.
*/
static struct ClientInfoList *
-find_or_create_client_entry(struct GNUNET_ClientHandle * client,
- PID_INDEX peer)
+find_or_create_client_entry (struct GNUNET_ClientHandle *client,
+ PID_INDEX peer)
{
- struct ClientInfoList * cl;
-
+ struct ClientInfoList *cl;
+
cl = clients;
while (cl != NULL)
{
- if ( ( (cl->client != NULL) &&
- (cl->client == client) ) ||
- ( (cl->peer != 0) &&
- (cl->peer == peer)) )
- break;
+ if (((cl->client != NULL) &&
+ (cl->client == client)) || ((cl->peer != 0) && (cl->peer == peer)))
+ break;
cl = cl->next;
}
if (cl != NULL)
return cl;
- cl = GNUNET_malloc(sizeof(struct ClientInfoList));
- memset(cl, 0, sizeof(struct ClientInfoList));
+ cl = GNUNET_malloc (sizeof (struct ClientInfoList));
+ memset (cl, 0, sizeof (struct ClientInfoList));
cl->next = clients;
clients = cl;
cl->client = client;
cl->peer = peer;
return cl;
-}
+}
/**
* Find the entry in the history corresponding
@@ -213,26 +213,25 @@
* exists, create one.
*/
static struct PeerHistoryList *
-find_or_create_history_entry(struct ClientInfoList * cl,
- PID_INDEX responder)
+find_or_create_history_entry (struct ClientInfoList *cl, PID_INDEX responder)
{
- struct PeerHistoryList * hl;
+ struct PeerHistoryList *hl;
hl = cl->history;
while (hl != NULL)
{
if (hl->peer == responder)
- break;
+ break;
hl = hl->next;
}
if (hl != NULL)
return hl;
- hl = GNUNET_malloc(sizeof(struct PeerHistoryList));
- memset(hl, 0, sizeof(struct PeerHistoryList));
+ hl = GNUNET_malloc (sizeof (struct PeerHistoryList));
+ memset (hl, 0, sizeof (struct PeerHistoryList));
hl->next = cl->history;
cl->history = hl;
hl->peer = responder;
- GNUNET_FS_PT_change_rc(responder, 1);
+ GNUNET_FS_PT_change_rc (responder, 1);
return hl;
}
@@ -247,36 +246,33 @@
* @param prio priority to use for the request
*/
static void
-add_request(PID_INDEX target,
- struct RequestList * request,
- int ttl,
- unsigned int prio)
+add_request (PID_INDEX target,
+ struct RequestList *request, int ttl, unsigned int prio)
{
- struct QueryPlanList * qpl;
- struct QueryPlanEntry * entry;
- struct QueryPlanEntry * pos;
+ struct QueryPlanList *qpl;
+ struct QueryPlanEntry *entry;
+ struct QueryPlanEntry *pos;
unsigned int total;
/* find query plan for target */
qpl = queries;
- while ( (qpl != NULL) &&
- (qpl->peer != target) )
+ while ((qpl != NULL) && (qpl->peer != target))
qpl = qpl->next;
if (qpl == NULL)
{
- qpl = GNUNET_malloc(sizeof(struct QueryPlanList));
- memset(qpl, 0, sizeof(struct QueryPlanList));
+ qpl = GNUNET_malloc (sizeof (struct QueryPlanList));
+ memset (qpl, 0, sizeof (struct QueryPlanList));
qpl->peer = target;
- GNUNET_FS_PT_change_rc(target, 1);
+ GNUNET_FS_PT_change_rc (target, 1);
qpl->next = queries;
queries = qpl;
}
/* construct entry */
- entry = GNUNET_malloc(sizeof(struct QueryPlanEntry));
- memset(entry, 0, sizeof(struct QueryPlanEntry));
+ entry = GNUNET_malloc (sizeof (struct QueryPlanEntry));
+ memset (entry, 0, sizeof (struct QueryPlanEntry));
entry->request = request;
entry->prio = prio;
- entry->ttl = GNUNET_FS_HELPER_bound_ttl(ttl, prio);
+ entry->ttl = GNUNET_FS_HELPER_bound_ttl (ttl, prio);
/* insert entry into request plan entries list */
entry->plan_entries_next = request->plan_entries;
@@ -285,15 +281,15 @@
/* compute (random) insertion position in doubly-linked list */
total = 0;
pos = qpl->head;
- while (pos != NULL)
+ while (pos != NULL)
{
total++;
pos = pos->next;
}
- total = GNUNET_random_u32(GNUNET_RANDOM_QUALITY_WEAK, total + 1);
+ total = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, total + 1);
pos = qpl->head;
while (total-- > 0)
- pos = pos->next;
+ pos = pos->next;
/* insert into datastructure at pos */
if (pos == NULL)
{
@@ -313,38 +309,37 @@
/**
* Closure for rank_peers callback function.
*/
-struct RankingPeerContext {
- struct PeerRankings * rankings;
- struct ClientInfoList * info;
- struct RequestList * request;
+struct RankingPeerContext
+{
+ struct PeerRankings *rankings;
+ struct ClientInfoList *info;
+ struct RequestList *request;
};
/**
* Rank peers by their quality for a given
* request (using history with client,
* bandwidth availability, query proximity)
- *
+ *
* @param identity the id of the node
*/
static void
-rank_peers(const GNUNET_PeerIdentity *
- identity, void *data)
+rank_peers (const GNUNET_PeerIdentity * identity, void *data)
{
- struct RankingPeerContext * rpc = data;
- struct PeerRankings * rank;
- struct PeerHistoryList * history;
+ struct RankingPeerContext *rpc = data;
+ struct PeerRankings *rank;
+ struct PeerHistoryList *history;
- rank = GNUNET_malloc(sizeof(struct PeerRankings));
- memset(rank, 0, sizeof(struct PeerRankings));
- rank->peer = GNUNET_FS_PT_intern(identity);
+ rank = GNUNET_malloc (sizeof (struct PeerRankings));
+ memset (rank, 0, sizeof (struct PeerRankings));
+ rank->peer = GNUNET_FS_PT_intern (identity);
history = NULL;
if (rpc->info != NULL)
{
history = rpc->info->history;
- while ( (history != NULL) &&
- (history->peer != rank->peer) )
- history = history->next;
+ while ((history != NULL) && (history->peer != rank->peer))
+ history = history->next;
}
if (history != NULL)
{
@@ -355,17 +350,17 @@
/* what are good start values? */
}
- /* reserve response-bandwidth from core!
- (also, don't forget to unreserve for
+ /* reserve response-bandwidth from core!
+ (also, don't forget to unreserve for
peers that were not selected!) */
-
+
/* check query proximity */
/* generate score, ttl and priority */
- rank->prio = 42; /* FIXME */
- rank->ttl = 112; /* FIXME */
- rank->score = 1; /* FIXME */
+ rank->prio = 42; /* FIXME */
+ rank->ttl = 112; /* FIXME */
+ rank->score = 1; /* FIXME */
/* insert into ranking list */
rank->next = rpc->rankings;
@@ -380,18 +375,17 @@
* anonymous file-sharing module. It determines for each query where
* it should be forwarded (to which peers, to how many peers) and what
* its TTL and priority values should be.<p>
- *
+ *
* @param client maybe NULL, in which case peer is significant
* @param peer sender of the request (if not a local client)
* @param request to plan
- */
+ */
void
-GNUNET_FS_PLAN_request(struct GNUNET_ClientHandle * client,
- PID_INDEX peer,
- struct RequestList * request)
+GNUNET_FS_PLAN_request (struct GNUNET_ClientHandle *client,
+ PID_INDEX peer, struct RequestList *request)
{
- struct ClientInfoList * info;
- struct PeerRankings * rank;
+ struct ClientInfoList *info;
+ struct PeerRankings *rank;
struct RankingPeerContext rpc;
unsigned int target_count;
unsigned int i;
@@ -399,23 +393,20 @@
unsigned long long total_score;
unsigned long long selector;
- GNUNET_mutex_lock(GNUNET_FS_lock); /* needed? */
+ GNUNET_mutex_lock (GNUNET_FS_lock); /* needed? */
info = clients;
- while ( (info != NULL) &&
- ( (info->client != client) ||
- (info->peer != peer) ) )
+ while ((info != NULL) && ((info->client != client) || (info->peer != peer)))
info = info->next;
/* for all connected peers compute ranking */
rpc.info = info;
rpc.request = request;
rpc.rankings = NULL;
- total_peers = coreAPI->forAllConnectedNodes(rank_peers,
- &rpc);
+ total_peers = coreAPI->forAllConnectedNodes (rank_peers, &rpc);
/* use request type, priority, system load and
entropy of ranking to determine number of peers
to queue */
- target_count = 2; /* FIXME */
+ target_count = 2; /* FIXME */
if (target_count > total_peers)
target_count = total_peers;
@@ -426,40 +417,37 @@
rank = rpc.rankings;
while (rank != NULL)
{
- GNUNET_GE_ASSERT(NULL, rank->score > 0);
+ GNUNET_GE_ASSERT (NULL, rank->score > 0);
total_score += rank->score;
rank = rank->next;
}
/* select target_count peers */
- for (i=0;i<target_count;i++)
+ for (i = 0; i < target_count; i++)
{
- selector = GNUNET_random_u64(GNUNET_RANDOM_QUALITY_WEAK, total_score);
+ selector = GNUNET_random_u64 (GNUNET_RANDOM_QUALITY_WEAK, total_score);
rank = rpc.rankings;
while (rank != NULL)
- {
- if (rank->score > selector)
- {
- add_request(rank->peer,
- request,
- rank->ttl,
- rank->prio);
- total_score -= rank->score;
- rank->score = 0; /* mark as used */
- break;
- }
- selector -= rank->score;
- rank = rank->next;
- }
- }
+ {
+ if (rank->score > selector)
+ {
+ add_request (rank->peer, request, rank->ttl, rank->prio);
+ total_score -= rank->score;
+ rank->score = 0; /* mark as used */
+ break;
+ }
+ selector -= rank->score;
+ rank = rank->next;
+ }
+ }
/* free rpc.rankings list */
while (rpc.rankings != NULL)
{
rank = rpc.rankings;
rpc.rankings = rank->next;
- GNUNET_FS_PT_change_rc(rank->peer, -1);
- GNUNET_free(rank);
+ GNUNET_FS_PT_change_rc (rank->peer, -1);
+ GNUNET_free (rank);
}
- GNUNET_mutex_unlock(GNUNET_FS_lock);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
}
/**
@@ -469,41 +457,37 @@
* @return number of bytes written to the buffer
*/
static unsigned int
-try_add_request(struct RequestList * req,
- unsigned int prio,
- int ttl,
- void * buf,
- unsigned int available)
+try_add_request (struct RequestList *req,
+ unsigned int prio,
+ int ttl, void *buf, unsigned int available)
{
- P2P_gap_query_MESSAGE * msg = buf;
+ P2P_gap_query_MESSAGE *msg = buf;
unsigned int size;
- GNUNET_GE_ASSERT(NULL, req->key_count > 0);
- size = sizeof(P2P_gap_query_MESSAGE)
- + req->bloomfilter_size
- + (req->key_count - 1) * sizeof(GNUNET_HashCode);
+ GNUNET_GE_ASSERT (NULL, req->key_count > 0);
+ size = sizeof (P2P_gap_query_MESSAGE)
+ + req->bloomfilter_size + (req->key_count - 1) * sizeof (GNUNET_HashCode);
if (size > available)
return 0;
- msg->header.size = htons(size);
- msg->header.type = htons(GNUNET_P2P_PROTO_GAP_QUERY);
- msg->type = htonl(req->type);
- msg->priority = htonl(prio);
- msg->ttl = htonl(ttl);
- msg->filter_mutator = htonl(req->bloomfilter_mutator);
- msg->number_of_queries = htonl(req->key_count);
+ msg->header.size = htons (size);
+ msg->header.type = htons (GNUNET_P2P_PROTO_GAP_QUERY);
+ msg->type = htonl (req->type);
+ msg->priority = htonl (prio);
+ msg->ttl = htonl (ttl);
+ msg->filter_mutator = htonl (req->bloomfilter_mutator);
+ msg->number_of_queries = htonl (req->key_count);
msg->returnTo = *coreAPI->myIdentity; /* FIXME? */
- memcpy(&msg->queries[0],
- &req->queries[0],
- req->key_count * sizeof(GNUNET_HashCode));
+ memcpy (&msg->queries[0],
+ &req->queries[0], req->key_count * sizeof (GNUNET_HashCode));
if (req->bloomfilter != NULL)
- GNUNET_bloomfilter_get_raw_data(req->bloomfilter,
- (char*) &msg->queries[req->key_count],
- req->bloomfilter_size);
+ GNUNET_bloomfilter_get_raw_data (req->bloomfilter,
+ (char *) &msg->queries[req->key_count],
+ req->bloomfilter_size);
/* FIXME: update state tracking
- what queries were sent with
+ what queries were sent with
what priorities/ ttls / etc */
- req->last_request_time = GNUNET_get_time();
+ req->last_request_time = GNUNET_get_time ();
req->last_ttl_used = ttl;
req->value = prio;
@@ -521,79 +505,72 @@
* @return the number of bytes written to
* that buffer (must be a positive number).
*/
-static unsigned int
+static unsigned int
query_fill_callback (const GNUNET_PeerIdentity *
- receiver, void *position,
- unsigned int padding)
+ receiver, void *position, unsigned int padding)
{
- char * buf = position;
- struct QueryPlanList * pl;
- struct QueryPlanEntry * e;
- struct QueryPlanEntry * n;
- struct QueryPlanEntry * pos;
- struct QueryPlanEntry * prev;
- struct PeerHistoryList * hl;
- struct ClientInfoList * cl;
+ char *buf = position;
+ struct QueryPlanList *pl;
+ struct QueryPlanEntry *e;
+ struct QueryPlanEntry *n;
+ struct QueryPlanEntry *pos;
+ struct QueryPlanEntry *prev;
+ struct PeerHistoryList *hl;
+ struct ClientInfoList *cl;
PID_INDEX peer;
unsigned int off;
unsigned int ret;
-
+
off = 0;
- peer = GNUNET_FS_PT_intern(receiver);
- GNUNET_mutex_lock(GNUNET_FS_lock);
+ peer = GNUNET_FS_PT_intern (receiver);
+ GNUNET_mutex_lock (GNUNET_FS_lock);
pl = queries;
- while ( (pl != NULL) &&
- (pl->peer != peer) )
+ while ((pl != NULL) && (pl->peer != peer))
pl = pl->next;
if (pl != NULL)
{
e = pl->head;
- while ( (e != NULL) &&
- (padding - off >= sizeof(P2P_gap_query_MESSAGE)) )
- {
- ret = try_add_request(e->request,
- e->prio,
- e->ttl,
- &buf[off],
- padding - off);
- n = e->next;
- if (ret != 0)
- {
- /* remove e from e's doubly-linked list */
- if (e->prev != NULL)
- e->prev->next = e->next;
- else
- pl->head = e->next;
- if (e->next != NULL)
- e->next->prev = e->prev;
- else
- pl->tail = e->prev;
- /* remove e from singly-linked list of request */
- prev = NULL;
- pos = e->request->plan_entries;
- while (pos != e)
- {
- prev = pos;
- pos = pos->plan_entries_next;
- }
- if (prev == NULL)
- e->request->plan_entries = e->plan_entries_next;
- else
- prev->plan_entries_next = e->plan_entries_next;
- GNUNET_free(e);
- cl = find_or_create_client_entry(e->request->response_client,
- e->request->response_target);
- hl = find_or_create_history_entry(cl,
- peer);
- hl->last_request_time = GNUNET_get_time();
- hl->request_count++;
- }
- off += ret;
- e = n;
- }
- }
- GNUNET_mutex_unlock(GNUNET_FS_lock);
- GNUNET_FS_PT_change_rc(peer, -1);
+ while ((e != NULL) && (padding - off >= sizeof (P2P_gap_query_MESSAGE)))
+ {
+ ret = try_add_request (e->request,
+ e->prio, e->ttl, &buf[off], padding - off);
+ n = e->next;
+ if (ret != 0)
+ {
+ /* remove e from e's doubly-linked list */
+ if (e->prev != NULL)
+ e->prev->next = e->next;
+ else
+ pl->head = e->next;
+ if (e->next != NULL)
+ e->next->prev = e->prev;
+ else
+ pl->tail = e->prev;
+ /* remove e from singly-linked list of request */
+ prev = NULL;
+ pos = e->request->plan_entries;
+ while (pos != e)
+ {
+ prev = pos;
+ pos = pos->plan_entries_next;
+ }
+ if (prev == NULL)
+ e->request->plan_entries = e->plan_entries_next;
+ else
+ prev->plan_entries_next = e->plan_entries_next;
+ GNUNET_free (e);
+ cl = find_or_create_client_entry (e->request->response_client,
+ e->request->response_target);
+ hl = find_or_create_history_entry (cl, peer);
+ hl->last_request_time = GNUNET_get_time ();
+ hl->request_count++;
+ }
+ off += ret;
+ e = n;
+ }
+ }
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ GNUNET_FS_PT_change_rc (peer, -1);
return off;
}
@@ -604,41 +581,41 @@
static void
handle_client_exit (struct GNUNET_ClientHandle *client)
{
- struct ClientInfoList * pos;
- struct ClientInfoList * prev;
- struct PeerHistoryList * ph;
+ struct ClientInfoList *pos;
+ struct ClientInfoList *prev;
+ struct PeerHistoryList *ph;
- GNUNET_mutex_lock(GNUNET_FS_lock);
+ GNUNET_mutex_lock (GNUNET_FS_lock);
pos = clients;
prev = NULL;
while (pos != NULL)
{
if (pos->client == client)
- {
- if (prev == NULL)
- clients = pos->next;
- else
- prev->next = pos->next;
- while (pos->history != NULL)
- {
- ph = pos->history;
- pos->history = ph->next;
- GNUNET_FS_PT_change_rc(ph->peer, -1);
- GNUNET_free(ph);
- }
- GNUNET_FS_PT_change_rc(pos->peer, -1);
- GNUNET_free(pos);
- if (prev == NULL)
- pos = clients;
- else
- pos = prev->next;
- }
+ {
+ if (prev == NULL)
+ clients = pos->next;
+ else
+ prev->next = pos->next;
+ while (pos->history != NULL)
+ {
+ ph = pos->history;
+ pos->history = ph->next;
+ GNUNET_FS_PT_change_rc (ph->peer, -1);
+ GNUNET_free (ph);
+ }
+ GNUNET_FS_PT_change_rc (pos->peer, -1);
+ GNUNET_free (pos);
+ if (prev == NULL)
+ pos = clients;
+ else
+ pos = prev->next;
+ }
else
- {
- pos = pos->next;
- }
- }
- GNUNET_mutex_unlock(GNUNET_FS_lock);
+ {
+ pos = pos->next;
+ }
+ }
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
}
@@ -646,29 +623,27 @@
* Notify the plan that a request succeeded.
*/
void
-GNUNET_FS_PLAN_success(PID_INDEX responder,
- struct GNUNET_ClientHandle * client,
- PID_INDEX peer,
- const struct RequestList * success)
+GNUNET_FS_PLAN_success (PID_INDEX responder,
+ struct GNUNET_ClientHandle *client,
+ PID_INDEX peer, const struct RequestList *success)
{
- struct ClientInfoList * cl;
- struct PeerHistoryList * hl;
+ struct ClientInfoList *cl;
+ struct PeerHistoryList *hl;
- GNUNET_mutex_lock(GNUNET_FS_lock);
- cl = find_or_create_client_entry(client, peer);
- hl = find_or_create_history_entry(cl,
- responder);
+ GNUNET_mutex_lock (GNUNET_FS_lock);
+ cl = find_or_create_client_entry (client, peer);
+ hl = find_or_create_history_entry (cl, responder);
hl->response_count++;
hl->last_good_ttl = success->last_ttl_used;
hl->last_good_prio = success->value;
- hl->last_response_time = GNUNET_get_time();
+ hl->last_response_time = GNUNET_get_time ();
hl->response_count++;
- GNUNET_mutex_unlock(GNUNET_FS_lock);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
}
-int
-GNUNET_FS_PLAN_init(GNUNET_CoreAPIForPlugins * capi)
+int
+GNUNET_FS_PLAN_init (GNUNET_CoreAPIForPlugins * capi)
{
coreAPI = capi;
GNUNET_GE_ASSERT (capi->ectx,
@@ -677,44 +652,45 @@
GNUNET_GE_ASSERT (coreAPI->ectx,
GNUNET_SYSERR !=
coreAPI->
- connection_register_send_callback
(sizeof(P2P_gap_query_MESSAGE),
-
GNUNET_FS_GAP_QUERY_POLL_PRIORITY,
- &query_fill_callback));
+ connection_register_send_callback (sizeof
+ (P2P_gap_query_MESSAGE),
+
GNUNET_FS_GAP_QUERY_POLL_PRIORITY,
+ &query_fill_callback));
return 0;
}
int
-GNUNET_FS_PLAN_done()
+GNUNET_FS_PLAN_done ()
{
- struct QueryPlanList * qpl;
- struct QueryPlanEntry * el;
- struct QueryPlanEntry * pred;
+ struct QueryPlanList *qpl;
+ struct QueryPlanEntry *el;
+ struct QueryPlanEntry *pred;
while (queries != NULL)
{
qpl = queries;
queries = qpl->next;
while (qpl->head != NULL)
- {
- el = qpl->head;
- qpl->head = el->next;
- pred = el->request->plan_entries;
- if (pred == el)
- el->request->plan_entries = el->plan_entries_next;
- else
- {
- while (pred->plan_entries_next != el)
- pred = pred->plan_entries_next;
- pred->plan_entries_next = el->plan_entries_next;
- }
- GNUNET_free(el);
- }
- GNUNET_FS_PT_change_rc(qpl->peer, -1);
- GNUNET_free(qpl);
+ {
+ el = qpl->head;
+ qpl->head = el->next;
+ pred = el->request->plan_entries;
+ if (pred == el)
+ el->request->plan_entries = el->plan_entries_next;
+ else
+ {
+ while (pred->plan_entries_next != el)
+ pred = pred->plan_entries_next;
+ pred->plan_entries_next = el->plan_entries_next;
+ }
+ GNUNET_free (el);
+ }
+ GNUNET_FS_PT_change_rc (qpl->peer, -1);
+ GNUNET_free (qpl);
}
/* clean up clients */
while (clients != NULL)
- handle_client_exit(clients->client);
+ handle_client_exit (clients->client);
GNUNET_GE_ASSERT (coreAPI->ectx,
GNUNET_SYSERR !=
coreAPI->
@@ -722,8 +698,9 @@
GNUNET_GE_ASSERT (coreAPI->ectx,
GNUNET_SYSERR !=
coreAPI->
- connection_unregister_send_callback
(sizeof(P2P_gap_query_MESSAGE),
- &query_fill_callback));
+ connection_unregister_send_callback (sizeof
+
(P2P_gap_query_MESSAGE),
+
&query_fill_callback));
return 0;
}
Modified: GNUnet/src/applications/fs/gap/plan.h
===================================================================
--- GNUnet/src/applications/fs/gap/plan.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/plan.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -35,23 +35,21 @@
* Plan the transmission of the given request.
* Use the history of the request and the client
* to schedule the request for transmission.
- */
+ */
void
-GNUNET_FS_PLAN_request(struct GNUNET_ClientHandle * client,
- PID_INDEX peer,
- struct RequestList * request);
+GNUNET_FS_PLAN_request (struct GNUNET_ClientHandle *client,
+ PID_INDEX peer, struct RequestList *request);
/**
* Notify the plan that a request succeeded.
*/
void
-GNUNET_FS_PLAN_success(PID_INDEX responder,
- struct GNUNET_ClientHandle * client,
- PID_INDEX peer,
- const struct RequestList * success);
+GNUNET_FS_PLAN_success (PID_INDEX responder,
+ struct GNUNET_ClientHandle *client,
+ PID_INDEX peer, const struct RequestList *success);
-int GNUNET_FS_PLAN_init(GNUNET_CoreAPIForPlugins * capi);
+int GNUNET_FS_PLAN_init (GNUNET_CoreAPIForPlugins * capi);
-int GNUNET_FS_PLAN_done(void);
+int GNUNET_FS_PLAN_done (void);
#endif
Modified: GNUnet/src/applications/fs/gap/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/gap/querymanager.c 2008-02-06 07:42:25 UTC
(rev 6167)
+++ GNUnet/src/applications/fs/gap/querymanager.c 2008-02-06 07:44:26 UTC
(rev 6168)
@@ -43,32 +43,33 @@
/**
* Linked list with information for each client.
*/
-struct ClientDataList {
+struct ClientDataList
+{
/**
* This is a linked list.
*/
- struct ClientDataList * next;
+ struct ClientDataList *next;
/**
* For which client is this data kept?
*/
- struct GNUNET_ClientHandle * client;
+ struct GNUNET_ClientHandle *client;
/**
* List of active requests for the client.
*/
- struct RequestList * requests;
+ struct RequestList *requests;
};
-static GNUNET_CoreAPIForPlugins * coreAPI;
+static GNUNET_CoreAPIForPlugins *coreAPI;
/**
* List of all clients, their active requests and other
* per-client information.
*/
-static struct ClientDataList * clients;
+static struct ClientDataList *clients;
/**
* A client is asking us to run a query. The query should be issued
@@ -79,54 +80,52 @@
*/
void
GNUNET_FS_QUERYMANAGER_start_query (const GNUNET_HashCode * query,
- unsigned int key_count,
- unsigned int anonymityLevel,
- unsigned int type,
- struct GNUNET_ClientHandle * client,
- const GNUNET_PeerIdentity * target)
+ unsigned int key_count,
+ unsigned int anonymityLevel,
+ unsigned int type,
+ struct GNUNET_ClientHandle *client,
+ const GNUNET_PeerIdentity * target)
{
- struct ClientDataList * cl;
- struct RequestList * request;
+ struct ClientDataList *cl;
+ struct RequestList *request;
- GNUNET_GE_ASSERT(NULL, key_count > 0);
-
- request = GNUNET_malloc(sizeof(struct RequestList) + (key_count-1) *
sizeof(GNUNET_HashCode));
- memset(request, 0, sizeof(struct RequestList));
+ GNUNET_GE_ASSERT (NULL, key_count > 0);
+
+ request =
+ GNUNET_malloc (sizeof (struct RequestList) +
+ (key_count - 1) * sizeof (GNUNET_HashCode));
+ memset (request, 0, sizeof (struct RequestList));
request->anonymityLevel = anonymityLevel;
request->key_count = key_count;
request->type = type;
- request->primary_target = GNUNET_FS_PT_intern(target);
+ request->primary_target = GNUNET_FS_PT_intern (target);
request->response_client = client;
- memcpy(&request->queries[0],
- query,
- sizeof(GNUNET_HashCode)*key_count);
- GNUNET_mutex_lock(GNUNET_FS_lock);
+ memcpy (&request->queries[0], query, sizeof (GNUNET_HashCode) * key_count);
+ GNUNET_mutex_lock (GNUNET_FS_lock);
cl = clients;
- while ( (cl != NULL) &&
- (cl->client != client) )
+ while ((cl != NULL) && (cl->client != client))
cl = cl->next;
if (cl == NULL)
{
- cl = GNUNET_malloc(sizeof(struct ClientDataList));
- memset(cl, 0, sizeof(struct ClientDataList));
+ cl = GNUNET_malloc (sizeof (struct ClientDataList));
+ memset (cl, 0, sizeof (struct ClientDataList));
cl->next = clients;
clients = cl;
}
request->next = cl->requests;
cl->requests = request;
- GNUNET_FS_PLAN_request(client, 0, request);
- if (request->anonymityLevel == 0)
+ GNUNET_FS_PLAN_request (client, 0, request);
+ if (request->anonymityLevel == 0)
{
- request->last_dht_get = GNUNET_get_time();
+ request->last_dht_get = GNUNET_get_time ();
request->dht_back_off = MAX_DHT_DELAY;
- GNUNET_FS_DHT_execute_query(request->type,
- &request->queries[0]);
+ GNUNET_FS_DHT_execute_query (request->type, &request->queries[0]);
}
- GNUNET_mutex_unlock(GNUNET_FS_lock);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
}
/**
- * How many bytes should a bloomfilter be if
+ * How many bytes should a bloomfilter be if
* we have already seen entry_count responses?
* Note that GAP_BLOOMFILTER_K gives us the
* number of bits set per entry. Furthermore,
@@ -137,26 +136,26 @@
* not resize the filter, we should generally
* pick a slightly larger size than what the
* strict math would suggest.
- *
+ *
* @return must be a power of two and smaller
* or equal to 2^15.
*/
static unsigned int
-compute_bloomfilter_size(unsigned int entry_count)
+compute_bloomfilter_size (unsigned int entry_count)
{
unsigned short size;
unsigned short max = 1 << 15;
unsigned int ideal = (entry_count * GAP_BLOOMFILTER_K) / 8;
size = 8;
- while ( (size < max) &&
- (size < ideal) )
+ while ((size < max) && (size < ideal))
size *= 2;
return size;
}
-struct IteratorClosure {
- struct ResponseList * pos;
+struct IteratorClosure
+{
+ struct ResponseList *pos;
int mingle_number;
};
@@ -168,20 +167,17 @@
* @return GNUNET_YES if we have more,
* GNUNET_NO if this is the last entry
*/
-static int
-response_bf_iterator(GNUNET_HashCode * next,
- void *arg)
+static int
+response_bf_iterator (GNUNET_HashCode * next, void *arg)
{
- struct IteratorClosure * cls = arg;
- struct ResponseList * r = cls->pos;
+ struct IteratorClosure *cls = arg;
+ struct ResponseList *r = cls->pos;
if (NULL == r)
return GNUNET_NO;
- GNUNET_FS_HELPER_mingle_hash(&r->hash,
- cls->mingle_number,
- next);
+ GNUNET_FS_HELPER_mingle_hash (&r->hash, cls->mingle_number, next);
cls->pos = r->next;
- return GNUNET_YES;
+ return GNUNET_YES;
}
/**
@@ -200,81 +196,71 @@
* GNUNET_SYSERR on serious errors
*/
static int
-handle_response(PID_INDEX sender,
- struct GNUNET_ClientHandle * client,
- struct RequestList * rl,
- const GNUNET_HashCode * primary_key,
- GNUNET_CronTime expirationTime,
- unsigned int size,
- const DBlock * data,
- unsigned int * value)
+handle_response (PID_INDEX sender,
+ struct GNUNET_ClientHandle *client,
+ struct RequestList *rl,
+ const GNUNET_HashCode * primary_key,
+ GNUNET_CronTime expirationTime,
+ unsigned int size, const DBlock * data, unsigned int *value)
{
struct IteratorClosure ic;
- CS_fs_reply_content_MESSAGE * msg;
+ CS_fs_reply_content_MESSAGE *msg;
GNUNET_HashCode hc;
int ret;
unsigned int bf_size;
/* check that content matches query */
- ret = GNUNET_FS_SHARED_test_valid_new_response(rl,
- primary_key,
- size,
- data,
- &hc);
+ ret = GNUNET_FS_SHARED_test_valid_new_response (rl,
+ primary_key,
+ size, data, &hc);
if (ret != GNUNET_OK)
- return ret;
- if (sender == 0) /* dht produced response */
- rl->dht_back_off = MAX_DHT_DELAY; /* go back! */
+ return ret;
+ if (sender == 0) /* dht produced response */
+ rl->dht_back_off = MAX_DHT_DELAY; /* go back! */
/* send to client */
- msg = GNUNET_malloc(sizeof(CS_fs_reply_content_MESSAGE) + size);
- msg->header.size = htons(sizeof(CS_fs_reply_content_MESSAGE) + size);
- msg->header.type = htons(GNUNET_CS_PROTO_GAP_RESULT);
- msg->anonymityLevel = htonl(0); /* unknown */
- msg->expirationTime = GNUNET_htonll(expirationTime);
- memcpy(&msg[1],
- data,
- size);
- coreAPI->cs_send_to_client(client,
- &msg->header,
- (rl->type != GNUNET_ECRS_BLOCKTYPE_DATA)
- ? GNUNET_NO
- : GNUNET_YES);
- GNUNET_free(msg);
+ msg = GNUNET_malloc (sizeof (CS_fs_reply_content_MESSAGE) + size);
+ msg->header.size = htons (sizeof (CS_fs_reply_content_MESSAGE) + size);
+ msg->header.type = htons (GNUNET_CS_PROTO_GAP_RESULT);
+ msg->anonymityLevel = htonl (0); /* unknown */
+ msg->expirationTime = GNUNET_htonll (expirationTime);
+ memcpy (&msg[1], data, size);
+ coreAPI->cs_send_to_client (client,
+ &msg->header,
+ (rl->type != GNUNET_ECRS_BLOCKTYPE_DATA)
+ ? GNUNET_NO : GNUNET_YES);
+ GNUNET_free (msg);
- /* update *value */
+ /* update *value */
*value += 1 + rl->value;
- GNUNET_FS_PLAN_success(sender, client, 0, rl);
+ GNUNET_FS_PLAN_success (sender, client, 0, rl);
if (rl->type == GNUNET_ECRS_BLOCKTYPE_DATA)
- return GNUNET_OK; /* the end */
+ return GNUNET_OK; /* the end */
/* update bloom filter */
rl->bloomfilter_entry_count++;
- bf_size = compute_bloomfilter_size(rl->bloomfilter_entry_count);
- if (rl->bloomfilter == NULL)
+ bf_size = compute_bloomfilter_size (rl->bloomfilter_entry_count);
+ if (rl->bloomfilter == NULL)
{
- rl->bloomfilter_mutator
- = GNUNET_random_u32(GNUNET_RANDOM_QUALITY_WEAK, -1);
+ rl->bloomfilter_mutator
+ = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, -1);
rl->bloomfilter_size = bf_size;
- rl->bloomfilter = GNUNET_bloomfilter_init(NULL,
- NULL,
- rl->bloomfilter_size,
- GAP_BLOOMFILTER_K);
- }
+ rl->bloomfilter = GNUNET_bloomfilter_init (NULL,
+ NULL,
+ rl->bloomfilter_size,
+ GAP_BLOOMFILTER_K);
+ }
else if (rl->bloomfilter_size != bf_size)
{
- rl->bloomfilter_mutator
- = GNUNET_random_u32(GNUNET_RANDOM_QUALITY_WEAK, -1);
+ rl->bloomfilter_mutator
+ = GNUNET_random_u32 (GNUNET_RANDOM_QUALITY_WEAK, -1);
ic.pos = rl->responses;
ic.mingle_number = rl->bloomfilter_mutator;
- GNUNET_bloomfilter_resize(rl->bloomfilter,
- &response_bf_iterator,
- &ic,
- bf_size,
- GAP_BLOOMFILTER_K);
+ GNUNET_bloomfilter_resize (rl->bloomfilter,
+ &response_bf_iterator,
+ &ic, bf_size, GAP_BLOOMFILTER_K);
}
- GNUNET_FS_SHARED_mark_response_seen(rl,
- &hc);
+ GNUNET_FS_SHARED_mark_response_seen (rl, &hc);
/* we want more */
return GNUNET_NO;
@@ -282,11 +268,11 @@
/**
* Handle the given response (by forwarding it to
- * other peers as necessary).
+ * other peers as necessary).
*
* @param sender who send the response (good too know
* for future routing decisions)
- * @param primary_query hash code used for lookup
+ * @param primary_query hash code used for lookup
* (note that namespace membership may
* require additional verification that has
* not yet been performed; checking the
@@ -296,20 +282,20 @@
* @return how much was this content worth to us?
*/
unsigned int
-GNUNET_FS_QUERYMANAGER_handle_response(const GNUNET_PeerIdentity * sender,
- const GNUNET_HashCode * primary_query,
- GNUNET_CronTime expirationTime,
- unsigned int size,
- const DBlock * data)
+GNUNET_FS_QUERYMANAGER_handle_response (const GNUNET_PeerIdentity * sender,
+ const GNUNET_HashCode * primary_query,
+ GNUNET_CronTime expirationTime,
+ unsigned int size,
+ const DBlock * data)
{
- struct ClientDataList * cl;
- struct RequestList * rl;
- struct RequestList * prev;
+ struct ClientDataList *cl;
+ struct RequestList *rl;
+ struct RequestList *prev;
unsigned int value;
PID_INDEX rid;
- rid = GNUNET_FS_PT_intern(sender);
- GNUNET_mutex_lock(GNUNET_FS_lock);
+ rid = GNUNET_FS_PT_intern (sender);
+ GNUNET_mutex_lock (GNUNET_FS_lock);
value = 0;
cl = clients;
while (cl != NULL)
@@ -317,38 +303,35 @@
rl = cl->requests;
prev = NULL;
while (rl != NULL)
- {
- if (GNUNET_OK ==
- handle_response(rid,
- cl->client,
- rl,
- primary_query,
- expirationTime,
- size,
- data,
- &value))
- {
- if (prev != NULL)
- prev->next = rl->next;
- else
- cl->requests = rl->next;
- GNUNET_FS_SHARED_free_request_list(rl);
- if (prev == NULL)
- rl = cl->requests;
- else
- rl = prev->next;
- }
- else
- {
- prev = rl;
- rl = rl->next;
- }
- }
+ {
+ if (GNUNET_OK ==
+ handle_response (rid,
+ cl->client,
+ rl,
+ primary_query,
+ expirationTime, size, data, &value))
+ {
+ if (prev != NULL)
+ prev->next = rl->next;
+ else
+ cl->requests = rl->next;
+ GNUNET_FS_SHARED_free_request_list (rl);
+ if (prev == NULL)
+ rl = cl->requests;
+ else
+ rl = prev->next;
+ }
+ else
+ {
+ prev = rl;
+ rl = rl->next;
+ }
+ }
cl = cl->next;
}
- GNUNET_mutex_unlock(GNUNET_FS_lock);
- GNUNET_FS_PT_change_rc(rid, -1);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
+ GNUNET_FS_PT_change_rc (rid, -1);
return value;
}
@@ -357,34 +340,33 @@
* Frees all of the associated data structures.
*/
static void
-handle_client_exit (struct GNUNET_ClientHandle *client)
+handle_client_exit (struct GNUNET_ClientHandle *client)
{
- struct ClientDataList * cl;
- struct ClientDataList * prev;
- struct RequestList * rl;
+ struct ClientDataList *cl;
+ struct ClientDataList *prev;
+ struct RequestList *rl;
- GNUNET_mutex_lock(GNUNET_FS_lock);
+ GNUNET_mutex_lock (GNUNET_FS_lock);
cl = clients;
prev = NULL;
- while ( (cl != NULL) &&
- (cl->client != client) )
+ while ((cl != NULL) && (cl->client != client))
{
prev = cl;
cl = cl->next;
}
if (cl != NULL)
{
- while (cl->requests != NULL)
- {
- rl = cl->requests;
- cl->requests = rl->next;
- GNUNET_FS_SHARED_free_request_list(rl);
- }
+ while (cl->requests != NULL)
+ {
+ rl = cl->requests;
+ cl->requests = rl->next;
+ GNUNET_FS_SHARED_free_request_list (rl);
+ }
if (prev == NULL)
- clients = cl->next;
+ clients = cl->next;
else
- prev->next = cl->next;
- GNUNET_free(cl);
+ prev->next = cl->next;
+ GNUNET_free (cl);
}
GNUNET_mutex_unlock (GNUNET_FS_lock);
}
@@ -394,68 +376,61 @@
* repeat requests.
*/
static void
-repeat_requests_job(void * unused)
+repeat_requests_job (void *unused)
{
- struct ClientDataList * client;
- struct RequestList * request;
+ struct ClientDataList *client;
+ struct RequestList *request;
GNUNET_CronTime now;
- GNUNET_mutex_lock(GNUNET_FS_lock);
- now = GNUNET_get_time();
+ GNUNET_mutex_lock (GNUNET_FS_lock);
+ now = GNUNET_get_time ();
client = clients;
while (client != NULL)
{
request = client->requests;
while (request != NULL)
- {
- if ( (NULL == request->plan_entries) &&
- ( (request->expiration == 0) ||
- (request->expiration > now) ) &&
- (request->last_ttl_used * GNUNET_CRON_SECONDS +
- request->last_request_time > now) )
- GNUNET_FS_PLAN_request(client->client,
- 0,
- request);
+ {
+ if ((NULL == request->plan_entries) &&
+ ((request->expiration == 0) ||
+ (request->expiration > now)) &&
+ (request->last_ttl_used * GNUNET_CRON_SECONDS +
+ request->last_request_time > now))
+ GNUNET_FS_PLAN_request (client->client, 0, request);
- if ( (request->anonymityLevel == 0) &&
- (request->last_dht_get + request->dht_back_off < now) )
- {
- if (request->dht_back_off * 2 >
- request->dht_back_off)
- request->dht_back_off *= 2;
- request->last_dht_get = now;
- GNUNET_FS_DHT_execute_query(request->type,
- &request->queries[0]);
- }
- request = request->next;
- }
+ if ((request->anonymityLevel == 0) &&
+ (request->last_dht_get + request->dht_back_off < now))
+ {
+ if (request->dht_back_off * 2 > request->dht_back_off)
+ request->dht_back_off *= 2;
+ request->last_dht_get = now;
+ GNUNET_FS_DHT_execute_query (request->type,
+ &request->queries[0]);
+ }
+ request = request->next;
+ }
client = client->next;
}
- GNUNET_mutex_unlock(GNUNET_FS_lock);
+ GNUNET_mutex_unlock (GNUNET_FS_lock);
}
-int
-GNUNET_FS_QUERYMANAGER_init(GNUNET_CoreAPIForPlugins * capi)
+int
+GNUNET_FS_QUERYMANAGER_init (GNUNET_CoreAPIForPlugins * capi)
{
coreAPI = capi;
GNUNET_GE_ASSERT (capi->ectx,
GNUNET_SYSERR !=
capi->cs_exit_handler_register (&handle_client_exit));
- GNUNET_cron_add_job(capi->cron,
- &repeat_requests_job,
- CHECK_REPEAT_FREQUENCY,
- CHECK_REPEAT_FREQUENCY,
- NULL);
+ GNUNET_cron_add_job (capi->cron,
+ &repeat_requests_job,
+ CHECK_REPEAT_FREQUENCY, CHECK_REPEAT_FREQUENCY, NULL);
return 0;
}
int
-GNUNET_FS_QUERYMANAGER_done()
+GNUNET_FS_QUERYMANAGER_done ()
{
- GNUNET_cron_del_job(coreAPI->cron,
- &repeat_requests_job,
- CHECK_REPEAT_FREQUENCY,
- NULL);
+ GNUNET_cron_del_job (coreAPI->cron,
+ &repeat_requests_job, CHECK_REPEAT_FREQUENCY, NULL);
GNUNET_GE_ASSERT (coreAPI->ectx,
GNUNET_SYSERR !=
coreAPI->
Modified: GNUnet/src/applications/fs/gap/querymanager.h
===================================================================
--- GNUnet/src/applications/fs/gap/querymanager.h 2008-02-06 07:42:25 UTC
(rev 6167)
+++ GNUnet/src/applications/fs/gap/querymanager.h 2008-02-06 07:44:26 UTC
(rev 6168)
@@ -30,9 +30,9 @@
#include "gnunet_core.h"
#include "ecrs_core.h"
-int GNUNET_FS_QUERYMANAGER_init(GNUNET_CoreAPIForPlugins * capi);
+int GNUNET_FS_QUERYMANAGER_init (GNUNET_CoreAPIForPlugins * capi);
-int GNUNET_FS_QUERYMANAGER_done(void);
+int GNUNET_FS_QUERYMANAGER_done (void);
/**
@@ -44,19 +44,19 @@
*/
void
GNUNET_FS_QUERYMANAGER_start_query (const GNUNET_HashCode * query,
- unsigned int key_count,
- unsigned int anonymityLevel,
- unsigned int type,
- struct GNUNET_ClientHandle * client,
- const GNUNET_PeerIdentity * target);
+ unsigned int key_count,
+ unsigned int anonymityLevel,
+ unsigned int type,
+ struct GNUNET_ClientHandle *client,
+ const GNUNET_PeerIdentity * target);
/**
* Handle the given response (by forwarding it to
- * other peers as necessary).
+ * other peers as necessary).
*
* @param sender who send the response (good too know
* for future routing decisions)
- * @param primary_query hash code used for lookup
+ * @param primary_query hash code used for lookup
* (note that namespace membership may
* require additional verification that has
* not yet been performed; checking the
@@ -66,11 +66,11 @@
* @return how much was this content worth to us?
*/
unsigned int
-GNUNET_FS_QUERYMANAGER_handle_response(const GNUNET_PeerIdentity * sender,
- const GNUNET_HashCode * primary_query,
- GNUNET_CronTime expirationTime,
- unsigned int size,
- const DBlock * data);
+GNUNET_FS_QUERYMANAGER_handle_response (const GNUNET_PeerIdentity * sender,
+ const GNUNET_HashCode * primary_query,
+ GNUNET_CronTime expirationTime,
+ unsigned int size,
+ const DBlock * data);
#endif
Modified: GNUnet/src/applications/fs/gap/shared.c
===================================================================
--- GNUnet/src/applications/fs/gap/shared.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/shared.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -34,43 +34,43 @@
* plans for various peers and known responses.
*/
void
-GNUNET_FS_SHARED_free_request_list(struct RequestList * rl)
+GNUNET_FS_SHARED_free_request_list (struct RequestList *rl)
{
- struct ResponseList * repl;
- struct QueryPlanEntry * planl;
-
+ struct ResponseList *repl;
+ struct QueryPlanEntry *planl;
+
while (rl->responses != NULL)
{
repl = rl->responses;
rl->responses = repl->next;
- GNUNET_free(repl);
+ GNUNET_free (repl);
}
while (rl->plan_entries != NULL)
{
planl = rl->plan_entries;
rl->plan_entries = planl->plan_entries_next;
if (planl->next != NULL)
- planl->next->prev = planl->prev;
+ planl->next->prev = planl->prev;
else
- planl->list->tail = planl->prev;
+ planl->list->tail = planl->prev;
if (planl->prev != NULL)
- planl->prev->next = planl->next;
+ planl->prev->next = planl->next;
else
- planl->list->head = planl->next;
- GNUNET_free(planl);
+ planl->list->head = planl->next;
+ GNUNET_free (planl);
}
if (rl->bloomfilter != NULL)
- GNUNET_bloomfilter_free(rl->bloomfilter);
- GNUNET_FS_PT_change_rc(rl->primary_target, -1);
- GNUNET_FS_PT_change_rc(rl->response_target, -1);
- GNUNET_free(rl);
+ GNUNET_bloomfilter_free (rl->bloomfilter);
+ GNUNET_FS_PT_change_rc (rl->primary_target, -1);
+ GNUNET_FS_PT_change_rc (rl->response_target, -1);
+ GNUNET_free (rl);
}
/**
* Check if the given value is a valid
- * and new response for the given request list
+ * and new response for the given request list
* entry.
*
* @param hc set to the hash of the data if successful
@@ -78,51 +78,43 @@
* applicable, GNUNET_SYSERR on error
*/
int
-GNUNET_FS_SHARED_test_valid_new_response(struct RequestList * rl,
- const GNUNET_HashCode * primary_key,
- unsigned int size,
- const DBlock * data,
- GNUNET_HashCode * hc)
+GNUNET_FS_SHARED_test_valid_new_response (struct RequestList *rl,
+ const GNUNET_HashCode * primary_key,
+ unsigned int size,
+ const DBlock * data,
+ GNUNET_HashCode * hc)
{
- struct ResponseList * seen;
+ struct ResponseList *seen;
GNUNET_HashCode m;
int ret;
/* check that type and primary key match */
- if ( (rl->type != ntohl(data->type)) ||
- (0 != memcmp(primary_key,
- &rl->queries[0],
- sizeof(GNUNET_HashCode))) )
+ if ((rl->type != ntohl (data->type)) ||
+ (0 != memcmp (primary_key, &rl->queries[0], sizeof (GNUNET_HashCode))))
return GNUNET_NO;
/* check that content matches query */
- ret = GNUNET_EC_is_block_applicable_for_query(rl->type,
- size,
- data,
- &rl->queries[0],
- rl->key_count,
- &rl->queries[0]);
+ ret = GNUNET_EC_is_block_applicable_for_query (rl->type,
+ size,
+ data,
+ &rl->queries[0],
+ rl->key_count,
+ &rl->queries[0]);
if (ret != GNUNET_OK)
- return ret;
+ return ret;
/* check that this is a new response */
- GNUNET_hash(data, size,
- hc);
- GNUNET_FS_HELPER_mingle_hash(hc,
- rl->bloomfilter_mutator,
- &m);
- if ( (rl->bloomfilter != NULL) &&
- (GNUNET_YES == GNUNET_bloomfilter_test(rl->bloomfilter,
- &m)) )
- return GNUNET_NO; /* not useful */
+ GNUNET_hash (data, size, hc);
+ GNUNET_FS_HELPER_mingle_hash (hc, rl->bloomfilter_mutator, &m);
+ if ((rl->bloomfilter != NULL) &&
+ (GNUNET_YES == GNUNET_bloomfilter_test (rl->bloomfilter, &m)))
+ return GNUNET_NO; /* not useful */
seen = rl->responses;
while (seen != NULL)
{
- if (0 == memcmp(hc,
- &seen->hash,
- sizeof(GNUNET_HashCode)))
- return GNUNET_NO;
- seen = seen->next;
+ if (0 == memcmp (hc, &seen->hash, sizeof (GNUNET_HashCode)))
+ return GNUNET_NO;
+ seen = seen->next;
}
return GNUNET_OK;
}
@@ -133,15 +125,14 @@
* hash code as seen (update linked list and bloom filter).
*/
void
-GNUNET_FS_SHARED_mark_response_seen(struct RequestList * rl,
- GNUNET_HashCode * hc)
+GNUNET_FS_SHARED_mark_response_seen (struct RequestList *rl,
+ GNUNET_HashCode * hc)
{
- struct ResponseList * seen;
+ struct ResponseList *seen;
- GNUNET_bloomfilter_add(rl->bloomfilter,
- hc);
+ GNUNET_bloomfilter_add (rl->bloomfilter, hc);
/* update seen list */
- seen = GNUNET_malloc(sizeof(struct ResponseList));
+ seen = GNUNET_malloc (sizeof (struct ResponseList));
seen->hash = *hc;
seen->next = rl->responses;
rl->responses = seen;
@@ -155,9 +146,14 @@
* continue.
*/
int
-GNUNET_FS_HELPER_complete_value_from_database_callback (const GNUNET_HashCode
* key,
- const
GNUNET_DatastoreValue * value, void *closure,
- unsigned long long uid)
+GNUNET_FS_HELPER_complete_value_from_database_callback (const GNUNET_HashCode
+ * key,
+ const
+ GNUNET_DatastoreValue
+ * value,
+ void *closure,
+ unsigned long long
+ uid)
{
GNUNET_DatastoreValue *comp = closure;
@@ -165,25 +161,24 @@
(0 != memcmp (&value[1],
&comp[1],
ntohl (value->size) - sizeof (GNUNET_DatastoreValue))))
- return GNUNET_OK;
- *comp = *value;
+ return GNUNET_OK;
+ *comp = *value;
return GNUNET_SYSERR;
}
/**
- * Mingle hash with the mingle_number to
+ * Mingle hash with the mingle_number to
* produce different bits.
*/
-void
-GNUNET_FS_HELPER_mingle_hash(const GNUNET_HashCode * in,
- int mingle_number,
- GNUNET_HashCode * hc)
+void
+GNUNET_FS_HELPER_mingle_hash (const GNUNET_HashCode * in,
+ int mingle_number, GNUNET_HashCode * hc)
{
GNUNET_HashCode m;
- GNUNET_hash(&mingle_number, sizeof(int), &m);
- GNUNET_hash_xor(&m, in, hc);
+ GNUNET_hash (&mingle_number, sizeof (int), &m);
+ GNUNET_hash_xor (&m, in, hc);
}
@@ -197,14 +192,16 @@
* otherwise the ttl-limit for the given priority
*/
int
-GNUNET_FS_HELPER_bound_ttl(int ttl_in,
- unsigned int prio)
+GNUNET_FS_HELPER_bound_ttl (int ttl_in, unsigned int prio)
{
- if (ttl_in > ((unsigned long long) prio) * TTL_DECREMENT /
GNUNET_CRON_SECONDS)
+ if (ttl_in >
+ ((unsigned long long) prio) * TTL_DECREMENT / GNUNET_CRON_SECONDS)
{
- if (((unsigned long long) prio) * TTL_DECREMENT / GNUNET_CRON_SECONDS >=
(1 <<30) )
- return 1<<30;
- return (int) ((unsigned long long) prio) * TTL_DECREMENT /
GNUNET_CRON_SECONDS;
+ if (((unsigned long long) prio) * TTL_DECREMENT / GNUNET_CRON_SECONDS >=
+ (1 << 30))
+ return 1 << 30;
+ return (int) ((unsigned long long) prio) * TTL_DECREMENT /
+ GNUNET_CRON_SECONDS;
}
return ttl_in;
}
Modified: GNUnet/src/applications/fs/gap/shared.h
===================================================================
--- GNUnet/src/applications/fs/gap/shared.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/gap/shared.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -33,15 +33,16 @@
/**
* Linked list of responses that we have gotten for
* this request. Used to avoid forwarding the same
- * response to the client multiple times and to
+ * response to the client multiple times and to
* construct the bloom filter to block duplicates.
*/
-struct ResponseList {
+struct ResponseList
+{
/**
* This is a linked list.
*/
- struct ResponseList * next;
+ struct ResponseList *next;
/**
* Hash of the dblocks of the responses.
@@ -53,18 +54,19 @@
/**
* Linked list with the active requests of a client.
*/
-struct RequestList {
-
+struct RequestList
+{
+
/**
* This is a linked list.
*/
- struct RequestList * next;
+ struct RequestList *next;
/**
* Linked list of responses that we have
* already received for this request.
*/
- struct ResponseList * responses;
+ struct ResponseList *responses;
/**
* Linked list of query plan entries that this
@@ -74,19 +76,19 @@
* of a linked list that is constructed using
* the "plan_entries_next" field of QueryPlanEntry.
*/
- struct QueryPlanEntry * plan_entries;
+ struct QueryPlanEntry *plan_entries;
/**
* Bloomfilter for the query (maybe NULL).
*/
- struct GNUNET_BloomFilter * bloomfilter;
+ struct GNUNET_BloomFilter *bloomfilter;
/**
* NULL if this request is for another peer,
* otherwise the handle of the client for which
* this request is made.
*/
- struct GNUNET_ClientHandle * response_client;
+ struct GNUNET_ClientHandle *response_client;
/**
* Last time we tried to get a response for this
@@ -100,7 +102,7 @@
* DHT-get operation?
*/
GNUNET_CronTime dht_back_off;
-
+
/**
* When does this query record expire? (0 for never).
*/
@@ -124,7 +126,7 @@
/**
* Mutator used for the bloom filter.
- */
+ */
int bloomfilter_mutator;
/**
@@ -146,18 +148,18 @@
* If there is no peer that is suspected to have the result,
* the PID_INDEX will be zero.
*/
- PID_INDEX primary_target;
+ PID_INDEX primary_target;
/**
* Where to send a response (if we get one).
* Maybe zero (if we are the peer that cares).
*/
- PID_INDEX response_target;
+ PID_INDEX response_target;
/**
* (Relative) TTL used in the last request.
*/
- int last_ttl_used;
+ int last_ttl_used;
/**
* Priority used for the last request.
@@ -179,34 +181,35 @@
* simple linked list starting at the respective
* RequestList.
*/
-struct QueryPlanEntry {
+struct QueryPlanEntry
+{
/**
* This is a doubly-linked list.
*/
- struct QueryPlanEntry * next;
+ struct QueryPlanEntry *next;
/**
* This is a doubly-linked list.
*/
- struct QueryPlanEntry * prev;
+ struct QueryPlanEntry *prev;
/**
* Query plan that this entry belongs to.
*/
- struct QueryPlanList * list;
+ struct QueryPlanList *list;
/**
* Details about the request in the plan.
*/
- struct RequestList * request;
+ struct RequestList *request;
/**
* Other query plan entires for the same
* request (those entries will be part of
* other query plan lists).
*/
- struct QueryPlanEntry * plan_entries_next;
+ struct QueryPlanEntry *plan_entries_next;
/**
* Request priority that should be used.
@@ -215,7 +218,7 @@
/**
* Request TTL that should be used.
- */
+ */
int ttl;
};
@@ -224,27 +227,28 @@
/**
* Linked list of queries to consider for each peer.
*/
-struct QueryPlanList {
+struct QueryPlanList
+{
/**
* This is a linked list.
*/
- struct QueryPlanList * next;
+ struct QueryPlanList *next;
/**
* Head of the doubly-linked list of queries to consider.
*/
- struct QueryPlanEntry * head;
+ struct QueryPlanEntry *head;
/**
* Tail of the doubly-linked list of queries to consider.
*/
- struct QueryPlanEntry * tail;
+ struct QueryPlanEntry *tail;
/**
* For which peer is this the current plan?
*/
- PID_INDEX peer;
+ PID_INDEX peer;
};
@@ -252,19 +256,18 @@
* Lock used to synchronize access to
* all shared datastructures.
*/
-extern struct GNUNET_Mutex * GNUNET_FS_lock;
+extern struct GNUNET_Mutex *GNUNET_FS_lock;
/**
* Free the request list, including the associated
* list of pending requests, its entries in the
* plans for various peers and known responses.
*/
-void
-GNUNET_FS_SHARED_free_request_list(struct RequestList * rl);
+void GNUNET_FS_SHARED_free_request_list (struct RequestList *rl);
/**
* Check if the given value is a valid
- * and new response for the given request list
+ * and new response for the given request list
* entry.
*
* @param hc set to the hash of the data if successful
@@ -272,19 +275,19 @@
* applicable, GNUNET_SYSERR on error
*/
int
-GNUNET_FS_SHARED_test_valid_new_response(struct RequestList * rl,
- const GNUNET_HashCode * primary_key,
- unsigned int size,
- const DBlock * data,
- GNUNET_HashCode * hc);
+GNUNET_FS_SHARED_test_valid_new_response (struct RequestList *rl,
+ const GNUNET_HashCode * primary_key,
+ unsigned int size,
+ const DBlock * data,
+ GNUNET_HashCode * hc);
/**
* Mark the response corresponding to the given
* hash code as seen (update linked list and bloom filter).
*/
void
-GNUNET_FS_SHARED_mark_response_seen(struct RequestList * rl,
- GNUNET_HashCode * hc);
+GNUNET_FS_SHARED_mark_response_seen (struct RequestList *rl,
+ GNUNET_HashCode * hc);
/**
* If the data portion and type of the value match our value in the
@@ -293,21 +296,25 @@
* continue.
*/
int
-GNUNET_FS_HELPER_complete_value_from_database_callback (const GNUNET_HashCode
* key,
- const
GNUNET_DatastoreValue * value, void *closure,
- unsigned long long uid);
+GNUNET_FS_HELPER_complete_value_from_database_callback (const GNUNET_HashCode
+ * key,
+ const
+ GNUNET_DatastoreValue
+ * value,
+ void *closure,
+ unsigned long long
+ uid);
/**
- * Mingle hash with the mingle_number to
- * produce different bits. We use this
+ * Mingle hash with the mingle_number to
+ * produce different bits. We use this
* to generate many different bloomfilters
* for the same data.
*/
-void
-GNUNET_FS_HELPER_mingle_hash(const GNUNET_HashCode * in,
- int mingle_number,
- GNUNET_HashCode * hc);
+void
+GNUNET_FS_HELPER_mingle_hash (const GNUNET_HashCode * in,
+ int mingle_number, GNUNET_HashCode * hc);
/**
* The priority level imposes a bound on the maximum
@@ -318,8 +325,6 @@
* @return ttl_in if ttl_in is below the limit,
* otherwise the ttl-limit for the given priority
*/
-int
-GNUNET_FS_HELPER_bound_ttl(int ttl_in,
- unsigned int prio);
+int GNUNET_FS_HELPER_bound_ttl (int ttl_in, unsigned int prio);
#endif
Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/lib/fslib.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -34,7 +34,7 @@
/**
* How often should we automatically retry a request
- * that failed? (Note that searches are retried
+ * that failed? (Note that searches are retried
* indefinitely in any case; this only applies
* to upload/delete operations).
*/
@@ -105,7 +105,7 @@
};
/**
- * Retransmit all of the requests to gnunetd
+ * Retransmit all of the requests to gnunetd
* (used after a disconnect).
*/
static int
Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/fs/module/fs.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -361,9 +361,7 @@
GNUNET_EncName enc;
#endif
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
+ cectx = coreAPI->cs_create_client_log_context (sock);
if (ntohs (req->size) < sizeof (CS_fs_request_insert_MESSAGE))
{
GNUNET_GE_BREAK (ectx, 0);
@@ -475,9 +473,7 @@
int fnLen;
struct GNUNET_GE_Context *cectx;
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
+ cectx = coreAPI->cs_create_client_log_context (sock);
if (ntohs (req->size) < sizeof (CS_fs_request_init_index_MESSAGE))
{
GNUNET_GE_BREAK (ectx, 0);
@@ -526,9 +522,7 @@
const CS_fs_request_index_MESSAGE *ri;
struct GNUNET_GE_Context *cectx;
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
+ cectx = coreAPI->cs_create_client_log_context (sock);
if (ntohs (req->size) < sizeof (CS_fs_request_index_MESSAGE))
{
GNUNET_GE_BREAK (ectx, 0);
@@ -611,9 +605,7 @@
#endif
struct GNUNET_GE_Context *cectx;
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
+ cectx = coreAPI->cs_create_client_log_context (sock);
if (ntohs (req->size) < sizeof (CS_fs_request_delete_MESSAGE))
{
GNUNET_GE_BREAK (ectx, 0);
@@ -687,9 +679,7 @@
const CS_fs_request_unindex_MESSAGE *ru;
struct GNUNET_GE_Context *cectx;
- cectx =
- coreAPI->
- cs_create_client_log_context (sock);
+ cectx = coreAPI->cs_create_client_log_context (sock);
if (ntohs (req->size) != sizeof (CS_fs_request_unindex_MESSAGE))
{
GNUNET_GE_BREAK (ectx, 0);
Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c 2008-02-06 07:42:25 UTC
(rev 6167)
+++ GNUnet/src/applications/fs/module/ondemand.c 2008-02-06 07:44:26 UTC
(rev 6168)
@@ -377,13 +377,13 @@
{
case GNUNET_ECRS_BLOCKTYPE_ONDEMAND:
if (ntohl (dbv->size) != sizeof (OnDemandBlock))
- {
+ {
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
- }
+ }
odb = (const OnDemandBlock *) dbv;
break;
- case GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD:
+ case GNUNET_ECRS_BLOCKTYPE_ONDEMAND_OLD:
if (ntohl (dbv->size) != sizeof (OnDemandBlock72))
{
GNUNET_GE_BREAK (ectx, 0);
@@ -402,8 +402,8 @@
return GNUNET_SYSERR;
}
#else
- if ( (ntohl (dbv->size) != sizeof (OnDemandBlock)) ||
- (ntohl (dbv->type) != GNUNET_ECRS_BLOCKTYPE_ONDEMAND) )
+ if ((ntohl (dbv->size) != sizeof (OnDemandBlock)) ||
+ (ntohl (dbv->type) != GNUNET_ECRS_BLOCKTYPE_ONDEMAND))
{
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR;
Modified: GNUnet/src/applications/stats/clientapi.c
===================================================================
--- GNUnet/src/applications/stats/clientapi.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/stats/clientapi.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -164,7 +164,7 @@
case GNUNET_CS_PROTO_GAP_QUERY_START:
name = "CS_PROTO_gap_QUERY_START";
break;
- case GNUNET_CS_PROTO_GAP_RESULT :
+ case GNUNET_CS_PROTO_GAP_RESULT:
name = "CS_PROTO_gap_RESULT";
break;
case GNUNET_CS_PROTO_GAP_INSERT:
Modified: GNUnet/src/applications/testing/remote.c
===================================================================
--- GNUnet/src/applications/testing/remote.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/applications/testing/remote.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -37,7 +37,7 @@
const unsigned long long MIN_PORT_INCREMENT = 1;
const unsigned long long MAX_PORT_INCREMENT = -1;
const unsigned long long MIN_NUMBER_DAEMONS = 1;
-const unsigned long long MAX_NUMBER_DAEMONS = -1;
+const unsigned long long MAX_NUMBER_DAEMONS = -1;
static void
updatePort (struct GNUNET_GC_Configuration *cfg,
@@ -105,7 +105,7 @@
system (cmd);
- GNUNET_free(cmd);
+ GNUNET_free (cmd);
return GNUNET_OK;
}
@@ -213,26 +213,27 @@
"GNUNETD_HOME",
remote_config_path);
- while (hostnames[pos] != ' ' && pos>0)
+ while (hostnames[pos] != ' ' && pos > 0)
pos--;
if (pos != 0)
- {
- hostnames[pos]='\0';
- curr_host = &hostnames[pos+1];
- }
+ {
+ hostnames[pos] = '\0';
+ curr_host = &hostnames[pos + 1];
+ }
else
- {
- curr_host = &hostnames[pos];
- }
- printf("curr_host is %s\n",curr_host);
-
+ {
+ curr_host = &hostnames[pos];
+ }
+ printf ("curr_host is %s\n", curr_host);
+
for (j = 0; j < daemons_per_machine; ++j)
{
- length_temp = snprintf (NULL, 0, "%s%s%d", remote_pid_path, "pid",
j);
+ length_temp =
+ snprintf (NULL, 0, "%s%s%d", remote_pid_path, "pid", j);
temp_pid_file = GNUNET_malloc (length_temp + 1);
snprintf (temp_pid_file, length_temp + 1, "%s%s%d", remote_pid_path,
"pid", j);
-
+
GNUNET_GC_set_configuration_value_string (basecfg, NULL,
"GNUNETD", "PIDFILE",
temp_pid_file);
@@ -253,7 +254,7 @@
GNUNET_GE_BULK, "mkstemp",
temp_path);
GNUNET_GC_free (basecfg);
- GNUNET_free(temp_path);
+ GNUNET_free (temp_path);
break;
}
CLOSE (ret);
@@ -263,7 +264,7 @@
"Failed to write peer configuration file `%s'\n",
temp_path);
GNUNET_GC_free (basecfg);
- GNUNET_free(temp_path);
+ GNUNET_free (temp_path);
break;
}
@@ -275,16 +276,17 @@
curr_host, ssh_username);
}
GNUNET_free (temp);
- UNLINK(temp_path);
- GNUNET_free(temp_path);
+ UNLINK (temp_path);
+ GNUNET_free (temp_path);
if ((i < extra_daemons) && (j == daemons_per_machine - 1))
{
- length_temp = snprintf (NULL, 0, "%s%s%d", remote_pid_path,
"pid",j + 1);
+ length_temp =
+ snprintf (NULL, 0, "%s%s%d", remote_pid_path, "pid", j + 1);
temp_pid_file = GNUNET_malloc (length_temp + 1);
snprintf (temp_pid_file, length_temp + 1, "%s%s%d",
remote_pid_path, "pid", j + 1);
-
+
GNUNET_GC_set_configuration_value_string (basecfg, NULL,
"GNUNETD",
"PIDFILE",
@@ -305,7 +307,7 @@
GNUNET_GE_BULK, "mkstemp",
temp_path);
GNUNET_GC_free (basecfg);
- GNUNET_free(temp_path);
+ GNUNET_free (temp_path);
break;
}
CLOSE (ret);
@@ -315,7 +317,7 @@
"Failed to write peer configuration file `%s'\n",
temp_path);
GNUNET_GC_free (basecfg);
- GNUNET_free(temp_path);
+ GNUNET_free (temp_path);
break;
}
@@ -328,8 +330,8 @@
remote_config_path,
curr_host, ssh_username);
}
- UNLINK(temp_path);
- GNUNET_free(temp_path);
+ UNLINK (temp_path);
+ GNUNET_free (temp_path);
GNUNET_free (temp);
}
}
Modified: GNUnet/src/include/fs.h
===================================================================
--- GNUnet/src/include/fs.h 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/include/fs.h 2008-02-06 07:44:26 UTC (rev 6168)
@@ -72,14 +72,14 @@
/**
* Server to client: content (in response to a CS_fs_request_search_MESSAGE).
The
- * header is followed by the variable size data of a DBlock (as
+ * header is followed by the variable size data of a DBlock (as
* defined in ecrs_core.h).
*/
typedef struct
{
GNUNET_MessageHeader header;
- /**
+ /**
* Anonymity level for the content, maybe
* 0 if not known.
*/
@@ -192,7 +192,7 @@
} CS_fs_request_index_MESSAGE;
/**
- * Client to server: delete content. This struct is followed by
+ * Client to server: delete content. This struct is followed by
* the DBlock (of variable size) of the content that is to be deleted.
*/
typedef struct
@@ -249,7 +249,7 @@
* be determined from the header. This struct
* maybe followed by a bloom filter (size determined
* by the header) which includes hashes of responses
- * that should NOT be returned. If there is no
+ * that should NOT be returned. If there is no
* bloom filter, the filter_mutator
* should be zero.
*/
@@ -280,7 +280,7 @@
int filter_mutator;
/**
- * How many queries do we have (should be
+ * How many queries do we have (should be
* greater than zero).
*/
unsigned int number_of_queries;
@@ -300,7 +300,7 @@
/**
* Return message for search result. This struct
- * is always followed by a DBlock (see ecrs_core.h)
+ * is always followed by a DBlock (see ecrs_core.h)
* which contains the GNUNET_ECRS_BLOCKTYPE followed
* by the actual (encrypted) data.
*/
@@ -311,13 +311,13 @@
/**
* Always zero (for now).
*/
- unsigned int reserved; /* for 64-bit alignment */
+ unsigned int reserved; /* for 64-bit alignment */
/**
* When does this result expire? The given time
* is relative (and in big-endian).
*/
- unsigned long long expiration;
+ unsigned long long expiration;
} P2P_gap_reply_MESSAGE;
Modified: GNUnet/src/include/gnunet_core.h
===================================================================
--- GNUnet/src/include/gnunet_core.h 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/include/gnunet_core.h 2008-02-06 07:44:26 UTC (rev 6168)
@@ -302,7 +302,7 @@
*/
int (*connection_register_send_callback) (unsigned int
minimumPadding,
- unsigned int priority,
+ unsigned int priority,
GNUNET_BufferFillCallback
callback);
@@ -323,8 +323,8 @@
*
* @return GNUNET_OK
*/
- int (*register_notify_peer_disconnect)(GNUNET_NodeIteratorCallback callback,
- void * cls);
+ int (*register_notify_peer_disconnect) (GNUNET_NodeIteratorCallback
+ callback, void *cls);
/**
* Stop calling the given function whenever we get
@@ -333,8 +333,8 @@
* @return GNUNET_OK on success, GNUNET_SYSERR
* if this callback is not registered
*/
- int (*unregister_notify_peer_disconnect)(GNUNET_NodeIteratorCallback
callback,
- void * cls);
+ int (*unregister_notify_peer_disconnect) (GNUNET_NodeIteratorCallback
+ callback, void *cls);
/**
* Register a handler that is to be called for each
@@ -446,10 +446,10 @@
* @param amount how many bytes should we expect to receive?
* (negative amounts can be used to undo a (recent)
* reservation request
- * @return amount that could actually be reserved
+ * @return amount that could actually be reserved
*/
- int (*reserve_downstream_bandwidth)(const GNUNET_PeerIdentity * peer,
- int amount);
+ int (*reserve_downstream_bandwidth) (const GNUNET_PeerIdentity * peer,
+ int amount);
/**
* Offer the core a session for communication with the
@@ -559,11 +559,10 @@
*
* @param force GNUNET_YES if this message MUST be queued
*/
- int (*cs_send_to_client)(struct GNUNET_ClientHandle *
- handle,
- const GNUNET_MessageHeader *
- message, int force);
-
+ int (*cs_send_to_client) (struct GNUNET_ClientHandle *
+ handle,
+ const GNUNET_MessageHeader * message, int force);
+
/**
* Send a message to the client identified by the handle. Note that
* the core will typically buffer these messages as much as possible
Modified: GNUnet/src/include/gnunet_fs_lib.h
===================================================================
--- GNUnet/src/include/gnunet_fs_lib.h 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/include/gnunet_fs_lib.h 2008-02-06 07:44:26 UTC (rev 6168)
@@ -46,16 +46,15 @@
struct GNUNET_FS_SearchContext;
-struct GNUNET_FS_SearchContext *
-GNUNET_FS_create_search_context (struct
- GNUNET_GE_Context
- *ectx,
- struct
- GNUNET_GC_Configuration
- *cfg,
- struct
- GNUNET_Mutex
- *lock);
+struct GNUNET_FS_SearchContext *GNUNET_FS_create_search_context (struct
+
GNUNET_GE_Context
+ *ectx,
+ struct
+
GNUNET_GC_Configuration
+ *cfg,
+ struct
+ GNUNET_Mutex
+ *lock);
void GNUNET_FS_destroy_search_context (struct GNUNET_FS_SearchContext *ctx);
@@ -72,20 +71,19 @@
*/
int
GNUNET_FS_start_search (struct
- GNUNET_FS_SearchContext
- *ctx,
- const
- GNUNET_PeerIdentity *
- target,
- unsigned int type,
- unsigned int keyCount,
- const GNUNET_HashCode *
- keys,
- unsigned int
- anonymityLevel,
- GNUNET_DatastoreValueIterator
- callback,
- void *closure);
+ GNUNET_FS_SearchContext
+ *ctx,
+ const
+ GNUNET_PeerIdentity *
+ target,
+ unsigned int type,
+ unsigned int keyCount,
+ const GNUNET_HashCode *
+ keys,
+ unsigned int
+ anonymityLevel,
+ GNUNET_DatastoreValueIterator
+ callback, void *closure);
/**
* Insert a block. Note that while the API is VERY similar to
Modified: GNUnet/src/include/gnunet_remote_lib.h
===================================================================
--- GNUnet/src/include/gnunet_remote_lib.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/include/gnunet_remote_lib.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -44,7 +44,7 @@
struct GNUNET_remote_host
{
GNUNET_PeerIdentity identity;
- struct GNUNET_remote_host *next;
+ struct GNUNET_remote_host *next;
char *hostname;
unsigned long long controlPort;
@@ -63,12 +63,14 @@
* @param username username to use for ssh (assumed to be used with ssh-agent)
*/
int GNUNET_REMOTE_start_daemon (char *gnunetd_home,
- char *localConfigPath,char *configFileName,char
*remote_config_path,char *ip_address,
- char *username);
-
-int GNUNET_REMOTE_start_daemons(struct GNUNET_GC_Configuration
*newcfg,unsigned long long number_of_daemons);
+ char *localConfigPath, char *configFileName,
+ char *remote_config_path, char *ip_address,
+ char *username);
+int GNUNET_REMOTE_start_daemons (struct GNUNET_GC_Configuration *newcfg,
+ unsigned long long number_of_daemons);
+
#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
Modified: GNUnet/src/include/gnunet_util_containers.h
===================================================================
--- GNUnet/src/include/gnunet_util_containers.h 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/include/gnunet_util_containers.h 2008-02-06 07:44:26 UTC (rev
6168)
@@ -56,8 +56,7 @@
* @return GNUNET_YES if next was updated
* GNUNET_NO if there are no more entries
*/
-typedef int (*GNUNET_HashCodeIterator) (GNUNET_HashCode * next,
- void *arg);
+typedef int (*GNUNET_HashCodeIterator) (GNUNET_HashCode * next, void *arg);
/**
* @brief a GNUNET_Vector (ordered variable size set of elements), opaque
@@ -73,12 +72,11 @@
* element (number of bits set per element in the set)
* @return the bloomfilter
*/
-struct GNUNET_BloomFilter *
-GNUNET_bloomfilter_load (struct GNUNET_GE_Context
- *ectx,
- const char *filename,
- unsigned int size,
- unsigned int k);
+struct GNUNET_BloomFilter *GNUNET_bloomfilter_load (struct GNUNET_GE_Context
+ *ectx,
+ const char *filename,
+ unsigned int size,
+ unsigned int k);
/**
* Create a bloom filter from raw bits.
@@ -93,12 +91,11 @@
* element (number of bits set per element in the set)
* @return the bloomfilter
*/
-struct GNUNET_BloomFilter *
-GNUNET_bloomfilter_init (struct GNUNET_GE_Context
- *ectx,
- const char * data,
- unsigned int size,
- unsigned int k);
+struct GNUNET_BloomFilter *GNUNET_bloomfilter_init (struct GNUNET_GE_Context
+ *ectx,
+ const char *data,
+ unsigned int size,
+ unsigned int k);
/**
* Copy the raw data of this bloomfilter into
@@ -108,9 +105,8 @@
* @param size the size of the given data array
* @return GNUNET_SYSERR if the data array of the wrong size
*/
-int GNUNET_bloomfilter_get_raw_data(struct GNUNET_BloomFilter * bf,
- char * data,
- unsigned int size);
+int GNUNET_bloomfilter_get_raw_data (struct GNUNET_BloomFilter *bf,
+ char *data, unsigned int size);
/**
* Test if an element is in the filter.
Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/server/connection.c 2008-02-06 07:44:26 UTC (rev 6168)
@@ -262,14 +262,15 @@
};
-struct DisconnectNotificationList {
-
- struct DisconnectNotificationList * next;
+struct DisconnectNotificationList
+{
+ struct DisconnectNotificationList *next;
+
GNUNET_NodeIteratorCallback callback;
- void * cls;
-
+ void *cls;
+
};
@@ -607,12 +608,12 @@
/**
* Send callbacks for making better use of noise padding...
*/
-static struct SendCallbackList * scl_head;
+static struct SendCallbackList *scl_head;
/**
* Callbacks for disconnect notifications.
*/
-static struct DisconnectNotificationList * disconnect_notification_list;
+static struct DisconnectNotificationList *disconnect_notification_list;
/**
* Lock for the connection module.
@@ -715,13 +716,12 @@
* was disconnected.
*/
static void
-notify_disconnect(BufferEntry * be)
+notify_disconnect (BufferEntry * be)
{
- struct DisconnectNotificationList * l = disconnect_notification_list;
+ struct DisconnectNotificationList *l = disconnect_notification_list;
while (l != NULL)
{
- l->callback(&be->session.sender,
- l->cls);
+ l->callback (&be->session.sender, l->cls);
l = l->next;
}
}
@@ -1720,7 +1720,7 @@
#endif
be->status = STAT_DOWN;
be->time_established = 0;
- notify_disconnect(be);
+ notify_disconnect (be);
if (stats != NULL)
stats->change (stat_closedTransport, 1);
for (i = 0; i < be->sendBufferSize; i++)
@@ -1882,8 +1882,8 @@
stats->change (stat_transmitted, p);
be->available_send_window -= p;
be->lastSequenceNumberSend++;
- GNUNET_CORE_connection_reserve_downstream_bandwidth(&be->session.sender,
- 0);
+ GNUNET_CORE_connection_reserve_downstream_bandwidth (&be->session.
+ sender, 0);
if (be->idealized_limit > be->max_transmitted_limit)
be->max_transmitted_limit = be->idealized_limit;
else /* age */
@@ -1927,7 +1927,7 @@
be->session.tsession = NULL;
be->status = STAT_DOWN;
be->time_established = 0;
- notify_disconnect(be);
+ notify_disconnect (be);
if (stats != NULL)
stats->change (stat_closedTransport, 1);
transport->disconnect (tsession, __FILE__);
@@ -2247,7 +2247,7 @@
}
be->skey_remote_created = 0;
be->status = STAT_DOWN;
- notify_disconnect(be);
+ notify_disconnect (be);
be->time_established = 0;
be->idealized_limit = MIN_BPM_PER_PEER;
be->max_transmitted_limit = MIN_BPM_PER_PEER;
@@ -2546,8 +2546,8 @@
firstRound = GNUNET_YES;
for (u = 0; u < activePeerCount; u++)
{
-
GNUNET_CORE_connection_reserve_downstream_bandwidth(&entries[u]->session.sender,
- 0);
+ GNUNET_CORE_connection_reserve_downstream_bandwidth (&entries[u]->
+ session.sender, 0);
entries[u]->idealized_limit = 0;
}
while ((schedulableBandwidth > activePeerCount * 100) &&
@@ -2838,7 +2838,7 @@
total_send_buffer_size = 0;
connection_count = 0;
total_connection_lifetime = 0;
- GNUNET_mutex_lock (lock);
+ GNUNET_mutex_lock (lock);
for (i = 0; i < CONNECTION_MAX_HOSTS_; i++)
{
root = CONNECTION_buffer_[i];
@@ -2859,12 +2859,12 @@
GNUNET_free (tmp);
continue; /* no need to call 'send buffer' */
case STAT_UP:
- if ( (root->time_established < now) &&
- (root->time_established != 0) )
- {
- connection_count++;
- total_connection_lifetime += now - root->time_established;
- }
+ if ((root->time_established < now) &&
+ (root->time_established != 0))
+ {
+ connection_count++;
+ total_connection_lifetime += now - root->time_established;
+ }
updateCurBPS (root);
total_allowed_sent += root->max_bpm;
total_allowed_recv += root->idealized_limit;
@@ -3014,9 +3014,10 @@
stats->set (stat_total_allowed_now, total_allowed_now);
stats->set (stat_total_send_buffer_size, total_send_buffer_size);
if (connection_count > 0)
- stats->set(stat_avg_lifetime, total_connection_lifetime /
connection_count);
+ stats->set (stat_avg_lifetime,
+ total_connection_lifetime / connection_count);
else
- stats->set(stat_avg_lifetime, 0);
+ stats->set (stat_avg_lifetime, 0);
}
EXIT ();
}
@@ -3919,7 +3920,7 @@
int
GNUNET_CORE_connection_register_send_callback (unsigned int
minimumPadding,
- unsigned int priority,
+ unsigned int priority,
GNUNET_BufferFillCallback
callback)
{
@@ -3935,8 +3936,7 @@
GNUNET_mutex_lock (lock);
pos = scl_head;
prev = NULL;
- while ( (pos != NULL) &&
- (pos->priority > priority) )
+ while ((pos != NULL) && (pos->priority > priority))
{
prev = pos;
pos = pos->next;
@@ -4357,18 +4357,18 @@
* @return GNUNET_OK
*/
int
-GNUNET_CORE_connection_register_notify_peer_disconnect(GNUNET_NodeIteratorCallback
callback,
- void * cls)
+GNUNET_CORE_connection_register_notify_peer_disconnect
+ (GNUNET_NodeIteratorCallback callback, void *cls)
{
- struct DisconnectNotificationList * l;
+ struct DisconnectNotificationList *l;
- l = GNUNET_malloc(sizeof(struct DisconnectNotificationList));
+ l = GNUNET_malloc (sizeof (struct DisconnectNotificationList));
l->callback = callback;
l->cls = cls;
- GNUNET_mutex_lock(lock);
+ GNUNET_mutex_lock (lock);
l->next = disconnect_notification_list;
disconnect_notification_list = l;
- GNUNET_mutex_unlock(lock);
+ GNUNET_mutex_unlock (lock);
return GNUNET_OK;
}
@@ -4379,35 +4379,34 @@
* @return GNUNET_OK on success, GNUNET_SYSERR
* if this callback is not registered
*/
-int
-GNUNET_CORE_connection_unregister_notify_peer_disconnect(GNUNET_NodeIteratorCallback
callback,
- void * cls)
+int
+GNUNET_CORE_connection_unregister_notify_peer_disconnect
+ (GNUNET_NodeIteratorCallback callback, void *cls)
{
- struct DisconnectNotificationList * pos;
- struct DisconnectNotificationList * prev;
+ struct DisconnectNotificationList *pos;
+ struct DisconnectNotificationList *prev;
prev = NULL;
- GNUNET_mutex_lock(lock);
+ GNUNET_mutex_lock (lock);
pos = disconnect_notification_list;
while (pos != NULL)
{
- if ( (pos->callback == callback) &&
- (pos->cls == cls) )
- {
- if (prev == NULL)
- disconnect_notification_list = pos->next;
- else
- prev->next = pos->next;
- GNUNET_free(pos);
- GNUNET_mutex_unlock(lock);
- return GNUNET_OK;
- }
+ if ((pos->callback == callback) && (pos->cls == cls))
+ {
+ if (prev == NULL)
+ disconnect_notification_list = pos->next;
+ else
+ prev->next = pos->next;
+ GNUNET_free (pos);
+ GNUNET_mutex_unlock (lock);
+ return GNUNET_OK;
+ }
prev = pos;
pos = pos->next;
}
- GNUNET_mutex_unlock(lock);
+ GNUNET_mutex_unlock (lock);
return GNUNET_SYSERR;
-
+
}
/**
@@ -4420,40 +4419,40 @@
* @param timeframe in what time interval should the other
* peer be able to transmit the amount? Use zero
* when undoing a reservation
- * @return amount that could actually be reserved
+ * @return amount that could actually be reserved
*/
-int
-GNUNET_CORE_connection_reserve_downstream_bandwidth(const GNUNET_PeerIdentity
* peer,
- int amount)
+int
+GNUNET_CORE_connection_reserve_downstream_bandwidth (const GNUNET_PeerIdentity
+ * peer, int amount)
{
- BufferEntry * be;
+ BufferEntry *be;
unsigned long long available;
GNUNET_CronTime now;
GNUNET_CronTime delta;
- GNUNET_mutex_lock(lock);
- be = lookForHost(peer);
- if ( (be == NULL) ||
- (be->status != STAT_UP) )
+ GNUNET_mutex_lock (lock);
+ be = lookForHost (peer);
+ if ((be == NULL) || (be->status != STAT_UP))
{
- GNUNET_mutex_unlock(lock);
- return 0; /* not connected */
+ GNUNET_mutex_unlock (lock);
+ return 0; /* not connected */
}
- now = GNUNET_get_time();
+ now = GNUNET_get_time ();
delta = now - be->last_reservation_update;
- available = be->available_downstream + be->idealized_limit * delta /
GNUNET_CRON_MINUTES;
+ available =
+ be->available_downstream +
+ be->idealized_limit * delta / GNUNET_CRON_MINUTES;
if (amount < 0)
available -= amount;
if (available > be->idealized_limit * MAX_BUF_FACT)
available = be->idealized_limit * MAX_BUF_FACT;
- if ( (amount > 0) &&
- (available < amount) )
+ if ((amount > 0) && (available < amount))
amount = (int) available;
if (amount > 0)
available -= amount;
be->last_reservation_update = now;
- be->available_downstream = available;
- GNUNET_mutex_unlock(lock);
+ be->available_downstream = available;
+ GNUNET_mutex_unlock (lock);
return available;
}
Modified: GNUnet/src/server/connection.h
===================================================================
--- GNUnet/src/server/connection.h 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/server/connection.h 2008-02-06 07:44:26 UTC (rev 6168)
@@ -157,7 +157,7 @@
*/
int GNUNET_CORE_connection_register_send_callback (unsigned int
minimumPadding,
- unsigned int prio,
+ unsigned int prio,
GNUNET_BufferFillCallback
callback);
@@ -352,8 +352,9 @@
*
* @return GNUNET_OK
*/
-int
GNUNET_CORE_connection_register_notify_peer_disconnect(GNUNET_NodeIteratorCallback
callback,
- void * cls);
+int
+GNUNET_CORE_connection_register_notify_peer_disconnect
+(GNUNET_NodeIteratorCallback callback, void *cls);
/**
* Stop calling the given function whenever we get
@@ -362,8 +363,9 @@
* @return GNUNET_OK on success, GNUNET_SYSERR
* if this callback is not registered
*/
-int
GNUNET_CORE_connection_unregister_notify_peer_disconnect(GNUNET_NodeIteratorCallback
callback,
- void * cls);
+int
+GNUNET_CORE_connection_unregister_notify_peer_disconnect
+(GNUNET_NodeIteratorCallback callback, void *cls);
/**
@@ -373,10 +375,11 @@
* @param amount how many bytes should we expect to receive?
* (negative amounts can be used to undo a (recent)
* reservation request
- * @return amount that could actually be reserved
+ * @return amount that could actually be reserved
*/
-int GNUNET_CORE_connection_reserve_downstream_bandwidth(const
GNUNET_PeerIdentity * peer,
- int amount);
+int GNUNET_CORE_connection_reserve_downstream_bandwidth (const
+ GNUNET_PeerIdentity *
+ peer, int amount);
#endif
/* end of connection.h */
Modified: GNUnet/src/server/core.c
===================================================================
--- GNUnet/src/server/core.c 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/server/core.c 2008-02-06 07:44:26 UTC (rev 6168)
@@ -532,16 +532,16 @@
applicationCore.myIdentity = NULL; /* for now */
applicationCore.request_service = &GNUNET_CORE_request_service; /*
core.c */
applicationCore.release_service = &GNUNET_CORE_release_service; /*
core.c */
-
+
applicationCore.connection_send_plaintext =
&GNUNET_CORE_connection_send_plaintext; /* connection.c */
applicationCore.unicast = &GNUNET_CORE_connection_unicast; /*
connection.c */
applicationCore.connection_send_using_callback =
&GNUNET_CORE_connection_send_using_callback; /* connection.c */
applicationCore.forAllConnectedNodes =
&GNUNET_CORE_connection_iterate_peers; /* connection.c */
applicationCore.connection_register_send_callback =
&GNUNET_CORE_connection_register_send_callback; /* connection.c */
applicationCore.connection_unregister_send_callback =
&GNUNET_CORE_connection_unregister_send_callback; /* connection.c */
- applicationCore.reserve_downstream_bandwidth =
&GNUNET_CORE_connection_reserve_downstream_bandwidth; /* connection.c */
- applicationCore.register_notify_peer_disconnect =
&GNUNET_CORE_connection_register_notify_peer_disconnect; /* connection .c */
- applicationCore.unregister_notify_peer_disconnect =
&GNUNET_CORE_connection_unregister_notify_peer_disconnect; /* connection .c */
+ applicationCore.reserve_downstream_bandwidth =
&GNUNET_CORE_connection_reserve_downstream_bandwidth; /* connection.c */
+ applicationCore.register_notify_peer_disconnect =
&GNUNET_CORE_connection_register_notify_peer_disconnect; /* connection .c */
+ applicationCore.unregister_notify_peer_disconnect =
&GNUNET_CORE_connection_unregister_notify_peer_disconnect; /* connection
.c */
applicationCore.connection_register_send_notification_callback =
Modified: GNUnet/src/server/tcpserver.c
===================================================================
--- GNUnet/src/server/tcpserver.c 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/server/tcpserver.c 2008-02-06 07:44:26 UTC (rev 6168)
@@ -614,8 +614,8 @@
GNUNET_CORE_cs_create_client_log_context (struct GNUNET_ClientHandle *handle)
{
return GNUNET_GE_create_context_callback (GNUNET_GE_USER |
- GNUNET_GE_EVENTKIND |
- GNUNET_GE_ROUTEKIND,
+ GNUNET_GE_EVENTKIND |
+ GNUNET_GE_ROUTEKIND,
&logClientLogContext,
handle,
&freeClientLogContext,
Modified: GNUnet/src/server/tcpserver.h
===================================================================
--- GNUnet/src/server/tcpserver.h 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/server/tcpserver.h 2008-02-06 07:44:26 UTC (rev 6168)
@@ -127,9 +127,9 @@
*/
unsigned int GNUNET_CORE_cs_test_handler_registered (unsigned short type);
-struct GNUNET_GE_Context *
-GNUNET_CORE_cs_create_client_log_context (struct GNUNET_ClientHandle
- *handle);
+struct GNUNET_GE_Context *GNUNET_CORE_cs_create_client_log_context (struct
+
GNUNET_ClientHandle
+ *handle);
#endif
/* end of tcpserver.h */
Modified: GNUnet/src/setup/qt/setupWizard.h
===================================================================
--- GNUnet/src/setup/qt/setupWizard.h 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/setup/qt/setupWizard.h 2008-02-06 07:44:26 UTC (rev 6168)
@@ -38,7 +38,8 @@
prevClicked ();
void
abortClicked ();
- void linkHandler(const QUrl &link);
+ void
+ linkHandler (const QUrl & link);
protected:
QString
header ();
@@ -46,7 +47,8 @@
loadDefaults ();
int
saveConf ();
- void welcome();
+ void
+ welcome ();
unsigned int
curPage;
Modified: GNUnet/src/transports/http.c
===================================================================
--- GNUnet/src/transports/http.c 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/transports/http.c 2008-02-06 07:44:26 UTC (rev 6168)
@@ -623,7 +623,7 @@
next = pos->next;
STEP ();
curl_multi_remove_handle (curl_multi, pos->curl_put);
- http_requests_pending--;
+ http_requests_pending--;
STEP ();
signal_select ();
curl_easy_cleanup (pos->curl_put);
@@ -1043,12 +1043,13 @@
if (httpSession == NULL)
{
/* new http connection */
- if (stats != NULL) {
- if (0 == strcasecmp (MHD_HTTP_METHOD_PUT, method))
- stats->change(stat_put_received, 1);
- else
- stats->change(stat_get_received, 1);
- }
+ if (stats != NULL)
+ {
+ if (0 == strcasecmp (MHD_HTTP_METHOD_PUT, method))
+ stats->change (stat_put_received, 1);
+ else
+ stats->change (stat_get_received, 1);
+ }
GNUNET_mutex_lock (httplock);
for (i = 0; i < tsessionCount; i++)
{
@@ -1432,7 +1433,7 @@
http_requests_pending++;
GNUNET_mutex_unlock (curllock);
if (stats != NULL)
- stats->change(stat_get_issued, 1);
+ stats->change (stat_get_issued, 1);
STEP ();
if (mret != CURLM_OK)
{
@@ -1610,7 +1611,7 @@
http_requests_pending++;
GNUNET_mutex_unlock (curllock);
if (stats != NULL)
- stats->change(stat_put_issued, 1);
+ stats->change (stat_put_issued, 1);
STEP ();
if (mret != CURLM_OK)
{
@@ -1909,7 +1910,7 @@
STEP ();
GNUNET_mutex_lock (curllock);
curl_multi_remove_handle (curl_multi, pos->curl_put);
- http_requests_pending--;
+ http_requests_pending--;
GNUNET_mutex_unlock (curllock);
STEP ();
signal_select ();
@@ -2334,12 +2335,10 @@
stat_bytesSent = stats->create (gettext_noop ("# bytes sent via HTTP"));
stat_bytesDropped
= stats->create (gettext_noop ("# bytes dropped by HTTP (outgoing)"));
- stat_get_issued
- = stats->create (gettext_noop ("# HTTP GET issued"));
+ stat_get_issued = stats->create (gettext_noop ("# HTTP GET issued"));
stat_get_received
= stats->create (gettext_noop ("# HTTP GET received"));
- stat_put_issued
- = stats->create (gettext_noop ("# HTTP PUT issued"));
+ stat_put_issued = stats->create (gettext_noop ("# HTTP PUT issued"));
stat_put_received
= stats->create (gettext_noop ("# HTTP PUT received"));
}
Modified: GNUnet/src/util/boot/startup.c
===================================================================
--- GNUnet/src/util/boot/startup.c 2008-02-06 07:42:25 UTC (rev 6167)
+++ GNUnet/src/util/boot/startup.c 2008-02-06 07:44:26 UTC (rev 6168)
@@ -271,13 +271,13 @@
"GNUNET_HOME", "~/.gnunet",
&path);
GNUNET_free (path);
- if ( (GNUNET_YES == GNUNET_GC_have_configuration_value(*cfg,
- "TESTING",
- "WEAKRANDOM")) &&
- (GNUNET_YES == GNUNET_GC_get_configuration_value_yesno(*cfg,
- "TESTING",
- "WEAKRANDOM",
- GNUNET_NO)) )
+ if ((GNUNET_YES == GNUNET_GC_have_configuration_value (*cfg,
+ "TESTING",
+ "WEAKRANDOM")) &&
+ (GNUNET_YES == GNUNET_GC_get_configuration_value_yesno (*cfg,
+ "TESTING",
+ "WEAKRANDOM",
+ GNUNET_NO)))
{
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
}
Modified: GNUnet/src/util/containers/bloomfilter.c
===================================================================
--- GNUnet/src/util/containers/bloomfilter.c 2008-02-06 07:42:25 UTC (rev
6167)
+++ GNUnet/src/util/containers/bloomfilter.c 2008-02-06 07:44:26 UTC (rev
6168)
@@ -509,10 +509,8 @@
*/
struct GNUNET_BloomFilter *
GNUNET_bloomfilter_init (struct GNUNET_GE_Context
- *ectx,
- const char * data,
- unsigned int size,
- unsigned int k)
+ *ectx,
+ const char *data, unsigned int size, unsigned int k)
{
Bloomfilter *bf;
unsigned int ui;
@@ -545,15 +543,13 @@
* @param size the size of the given data array
* @return GNUNET_SYSERR if the data array is not big enough
*/
-int GNUNET_bloomfilter_get_raw_data(struct GNUNET_BloomFilter * bf,
- char * data,
- unsigned int size)
+int
+GNUNET_bloomfilter_get_raw_data (struct GNUNET_BloomFilter *bf,
+ char *data, unsigned int size)
{
if (bf->bitArraySize != size)
return GNUNET_SYSERR;
- memcpy(data,
- bf->bitArray,
- size);
+ memcpy (data, bf->bitArray, size);
return GNUNET_OK;
}
@@ -682,8 +678,7 @@
memset (bf->bitArray, 0, bf->bitArraySize);
if (bf->fd != -1)
makeEmptyFile (bf->fd, bf->bitArraySize * 4);
- while (GNUNET_YES == iterator(&hc,
- iterator_arg))
+ while (GNUNET_YES == iterator (&hc, iterator_arg))
GNUNET_bloomfilter_add (bf, &hc);
GNUNET_mutex_unlock (bf->lock);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6168 - in GNUnet/src: applications/chat applications/dht/module applications/fs/ecrs applications/fs/gap applications/fs/lib applications/fs/module applications/stats applications/testing include server setup/qt transports util/boot util/containers,
gnunet <=