Author: grothoff Date: 2006-07-29 23:07:16 -0700 (Sat, 29 Jul 2006) New Revision: 3181
Modified: GNUnet/src/applications/fragmentation/fragmentation.c GNUnet/todo Log: fragmentation compiles Modified: GNUnet/src/applications/fragmentation/fragmentation.c =================================================================== --- GNUnet/src/applications/fragmentation/fragmentation.c 2006-07-30 06:01:28 UTC (rev 3180) +++ GNUnet/src/applications/fragmentation/fragmentation.c 2006-07-30 06:07:16 UTC (rev 3181) @@ -1,6 +1,6 @@ /* This file is part of GNUnet - (C) 2004 Christian Grothoff (and other contributing authors) + (C) 2004, 2006 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -42,7 +42,7 @@ * Message fragment. */ typedef struct { - P2P_MESSAGE_HEADER header; + MESSAGE_HEADER header; /** * Fragment identity. @@ -113,7 +113,7 @@ /** * Lock for the defragmentation cache. */ -static Mutex defragCacheLock; +static struct MUTEX * defragCacheLock; static void freeFL(FL * fl, int c) { @@ -137,18 +137,18 @@ * belong to the entry). It's a bit more complicated as the * collision list is also collapsed. */ -static void defragmentationPurgeCron() { +static void defragmentationPurgeCron(void * unused) { int i; FC * smf; FC * next; FC * last; - MUTEX_LOCK(&defragCacheLock); + MUTEX_LOCK(defragCacheLock); for (i=0;i<DEFRAG_BUCKET_COUNT;i++) { last = NULL; smf = defragmentationCache[i]; while (smf != NULL) { - if (smf->ttl < cronTime(NULL)) { + if (smf->ttl < get_time()) { /* free linked list of fragments */ freeFL(smf->head, 1); next = smf->next; @@ -164,7 +164,7 @@ } } /* while smf != NULL */ } /* for all buckets */ - MUTEX_UNLOCK(&defragCacheLock); + MUTEX_UNLOCK(defragCacheLock); } /** @@ -181,8 +181,7 @@ unsigned short len; char * msg; - GNUNET_ASSERT(pep != NULL); - + GE_ASSERT(NULL, pep != NULL); pos = pep->head; if (pos == NULL) return; @@ -257,9 +256,10 @@ FL * tmp; unsigned short end; - GNUNET_ASSERT(entry != NULL); - if (! hostIdentityEquals(sender, - &entry->sender)) + GE_ASSERT(NULL, entry != NULL); + if (0 != memcmp(sender, + &entry->sender, + sizeof(PeerIdentity))) return SYSERR; /* wrong fragment list, try another! */ if (ntohl(packet->id) != entry->id) return SYSERR; /* wrong fragment list, try another! */ @@ -281,9 +281,10 @@ /* find the after-frame */ end = ntohs(packet->off) + ntohs(packet->header.size) - sizeof(P2P_fragmentation_MESSAGE); if (end <= ntohs(packet->off)) { - LOG(LOG_DEBUG, - "Received invalid fragment at %s:%d\n", - __FILE__, __LINE__); + GE_LOG(NULL, + GE_DEVELOPER | GE_DEBUG | GE_BULK, + "Received invalid fragment at %s:%d\n", + __FILE__, __LINE__); return SYSERR; /* yuck! integer overflow! */ } @@ -362,7 +363,7 @@ pep->link = after; FINISH: - entry->ttl = cronTime(NULL) + DEFRAGMENTATION_TIMEOUT; + entry->ttl = get_time() + DEFRAGMENTATION_TIMEOUT; checkComplete(entry); return OK; } @@ -375,25 +376,26 @@ * @return SYSERR if the fragment is invalid */ static int processFragment(const PeerIdentity * sender, - const P2P_MESSAGE_HEADER * frag) { + const MESSAGE_HEADER * frag) { unsigned int hash; FC * smf; if (ntohs(frag->size) < sizeof(P2P_fragmentation_MESSAGE)) return SYSERR; - MUTEX_LOCK(&defragCacheLock); + MUTEX_LOCK(defragCacheLock); hash = sender->hashPubKey.bits[0] % DEFRAG_BUCKET_COUNT; smf = defragmentationCache[hash]; while (smf != NULL) { if (OK == tryJoin(smf, sender, (P2P_fragmentation_MESSAGE*) frag)) { - MUTEX_UNLOCK(&defragCacheLock); + MUTEX_UNLOCK(defragCacheLock); return OK; } - if (hostIdentityEquals(sender, - &smf->sender)) { + if (0 == memcmp(sender, + &smf->sender, + sizeof(PeerIdentity))) { freeFL(smf->head, 1); break; } @@ -403,7 +405,7 @@ smf = MALLOC(sizeof(FC)); smf->next = defragmentationCache[hash]; defragmentationCache[hash] = smf; - smf->ttl = cronTime(NULL) + DEFRAGMENTATION_TIMEOUT; + smf->ttl = get_time() + DEFRAGMENTATION_TIMEOUT; smf->sender = *sender; } smf->id = ntohl(((P2P_fragmentation_MESSAGE*)frag)->id); @@ -414,7 +416,7 @@ frag, ntohs(frag->size)); - MUTEX_UNLOCK(&defragCacheLock); + MUTEX_UNLOCK(defragCacheLock); return OK; } @@ -477,7 +479,7 @@ mlen = sizeof(P2P_fragmentation_MESSAGE) + ctx->len - pos; if (mlen > ctx->mtu) mlen = ctx->mtu; - GNUNET_ASSERT(mlen > sizeof(P2P_fragmentation_MESSAGE)); + GE_ASSERT(NULL, mlen > sizeof(P2P_fragmentation_MESSAGE)); frag->header.size = htons(mlen); frag->header.type = htons(P2P_PROTO_fragment); frag->id = id; @@ -489,10 +491,10 @@ coreAPI->unicast(&ctx->sender, &frag->header, EXTREME_PRIORITY, - ctx->transmissionTime - cronTime(NULL)); + ctx->transmissionTime - get_time()); pos += mlen - sizeof(P2P_fragmentation_MESSAGE); } - GNUNET_ASSERT(pos == ctx->len); + GE_ASSERT(NULL, pos == ctx->len); FREE(frag); FREE(ctx); return OK; @@ -514,8 +516,8 @@ FragmentBMC * fbmc; int xlen; - GNUNET_ASSERT(len > mtu); - GNUNET_ASSERT(mtu > sizeof(P2P_fragmentation_MESSAGE)); + GE_ASSERT(NULL, len > mtu); + GE_ASSERT(NULL, mtu > sizeof(P2P_fragmentation_MESSAGE)); fbmc = MALLOC(sizeof(FragmentBMC) + len); fbmc->mtu = mtu; fbmc->sender = *peer; @@ -560,15 +562,17 @@ } for (i=0;i<DEFRAG_BUCKET_COUNT;i++) defragmentationCache[i] = NULL; - MUTEX_CREATE(&defragCacheLock); - addCronJob((CronJob) &defragmentationPurgeCron, - 60 * cronSECONDS, - 60 * cronSECONDS, - NULL); - LOG(LOG_DEBUG, - _("`%s' registering handler %d\n"), - "fragmentation", - P2P_PROTO_fragment); + defragCacheLock = MUTEX_CREATE(NO); + cron_add_job(coreAPI->cron, + &defragmentationPurgeCron, + 60 * cronSECONDS, + 60 * cronSECONDS, + NULL); + GE_LOG(capi->ectx, + GE_INFO | GE_USER | GE_REQUEST, + _("`%s' registering handler %d\n"), + "fragmentation", + P2P_PROTO_fragment); capi->registerHandler(P2P_PROTO_fragment, &processFragment); @@ -584,9 +588,10 @@ coreAPI->unregisterHandler(P2P_PROTO_fragment, &processFragment); - delCronJob((CronJob) &defragmentationPurgeCron, - 60 * cronSECONDS, - NULL); + cron_del_job(coreAPI->cron, + &defragmentationPurgeCron, + 60 * cronSECONDS, + NULL); for (i=0;i<DEFRAG_BUCKET_COUNT;i++) { FC * pos = defragmentationCache[i]; while (pos != NULL) { @@ -600,7 +605,8 @@ coreAPI->releaseService(stats); stats = NULL; } - MUTEX_DESTROY(&defragCacheLock); + MUTEX_DESTROY(defragCacheLock); + defragCacheLock = NULL; coreAPI = NULL; } Modified: GNUnet/todo =================================================================== --- GNUnet/todo 2006-07-30 06:01:28 UTC (rev 3180) +++ GNUnet/todo 2006-07-30 06:07:16 UTC (rev 3181) @@ -25,8 +25,8 @@ * server: + needs testing, also likely to be missing features * applications: - + identity, session, transport compile - + for core: fragmentation, topology_default, pingpong, stats + + fragmentation, identity, session, transport compile + + for core: topology_default, pingpong, stats + for basics: advertising, bootstrap_http, state, getoption, traffic + for fs: datastore, fs, gap, sqstore_sqlite + rest: sqstore_mysql, dht, chat, kvstore_sqlite, _______________________________________________ GNUnet-SVN mailing list GNUnet-SVN@gnu.org http://lists.gnu.org/mailman/listinfo/gnunet-svn