[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r1306 - in GNUnet: . src/applications/identity src/applicat
From: |
grothoff |
Subject: |
[GNUnet-SVN] r1306 - in GNUnet: . src/applications/identity src/applications/topology_default |
Date: |
Thu, 7 Jul 2005 06:23:57 -0700 (PDT) |
Author: grothoff
Date: 2005-07-07 06:23:52 -0700 (Thu, 07 Jul 2005)
New Revision: 1306
Modified:
GNUnet/ChangeLog
GNUnet/src/applications/identity/identity.c
GNUnet/src/applications/topology_default/topology.c
Log:
fixes
Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog 2005-07-07 00:24:08 UTC (rev 1305)
+++ GNUnet/ChangeLog 2005-07-07 13:23:52 UTC (rev 1306)
@@ -1,3 +1,7 @@
+Thu Jul 7 15:22:21 CEST 2005
+ Fixed bug in identity, missing ntohs for protocol ID.
+ Fixed bug in topology, wrong calculation of saturation.
+
Wed Jul 6 22:34:30 CEST 2005
Fixed bugs in core with respect to possible infinite
recursion caused by fragmentation callbacks. Also
Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2005-07-07 00:24:08 UTC (rev
1305)
+++ GNUnet/src/applications/identity/identity.c 2005-07-07 13:23:52 UTC (rev
1306)
@@ -105,12 +105,12 @@
/**
* The current (allocated) size of knownHosts
*/
-static int max_ = 0;
+static int sizeOfHosts_ = 0;
/**
* The number of actual entries in knownHosts
*/
-static int count_;
+static int numberOfHosts_;
/**
* A lock for accessing knownHosts
@@ -172,7 +172,8 @@
static HostEntry * findHost(const PeerIdentity * id) {
int i;
- for (i=0;i<count_;i++)
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
+ for (i=0;i<numberOfHosts_;i++)
if ( (hostIdentityEquals(id,
&hosts_[i]->identity)) )
return hosts_[i];
@@ -193,6 +194,7 @@
char * fn;
unsigned int trust;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
MUTEX_LOCK(&lock_);
entry = findHost(identity);
if (entry == NULL) {
@@ -221,11 +223,11 @@
}
FREE(fn);
- if (count_ == max_)
+ if (numberOfHosts_ == sizeOfHosts_)
GROW(hosts_,
- max_,
- max_+32);
- hosts_[count_++] = entry;
+ sizeOfHosts_,
+ sizeOfHosts_+32);
+ hosts_[numberOfHosts_++] = entry;
}
for (i=0;i<entry->protocolCount;i++) {
if (entry->protocols[i] == protocol) {
@@ -304,6 +306,7 @@
unsigned int protoNumber;
char * fullname;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
GNUNET_ASSERT(sizeof(EncName) == 104);
if (2 == sscanf(filename,
"%103c.%u",
@@ -362,6 +365,7 @@
networkIdDirectory);
}
}
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
}
/**
@@ -392,9 +396,10 @@
int i;
int j;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
GNUNET_ASSERT(protocol != ANY_PROTOCOL_NUMBER);
MUTEX_LOCK(&lock_);
- for (i=0;i<count_;i++) {
+ for (i=0;i<numberOfHosts_;i++) {
if ( (hostIdentityEquals(identity,
&hosts_[i]->identity)) ) {
entry = hosts_[i];
@@ -434,10 +439,11 @@
entry->heloCount,
0);
}
- hosts_[i] = hosts_[--count_];
+ hosts_[i] = hosts_[--numberOfHosts_];
FREE(entry);
}
MUTEX_UNLOCK(&lock_);
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
return; /* deleted */
}
}
@@ -457,6 +463,7 @@
HostEntry * host;
int i;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
GNUNET_ASSERT(msg != NULL);
IFLOG(LOG_INFO,
hash2enc(&msg->senderIdentity.hashPubKey,
@@ -467,7 +474,7 @@
&enc,
ntohs(msg->protocol));
#endif
- fn = getHostFileName(&msg->senderIdentity,
+ fn = getHostFileName(&msg->senderIdentity,
ntohs(msg->protocol));
buffer = MALLOC(MAX_BUFFER_SIZE);
size = readFile(fn,
@@ -511,6 +518,7 @@
msg,
HELO_Message_size(msg));
MUTEX_UNLOCK(&lock_);
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
}
/**
@@ -537,6 +545,7 @@
int j;
int * perm;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
MUTEX_LOCK(&lock_);
if (YES == tryTemporaryList) {
if (protocol == ANY_PROTOCOL_NUMBER)
@@ -686,6 +695,7 @@
EncName hn;
HostEntry * entry;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
MUTEX_LOCK(&lock_);
entry = findHost(identity);
if (entry == NULL) {
@@ -731,6 +741,7 @@
cron_t now;
HostEntry * entry;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
MUTEX_LOCK(&lock_);
entry = findHost(identity);
if (entry == NULL) {
@@ -760,6 +771,7 @@
EncName enc;
#endif
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
MUTEX_LOCK(&lock_);
entry = findHost(identity);
if (entry == NULL) {
@@ -801,9 +813,10 @@
unsigned short proto;
HostEntry * entry;
+ GNUNET_ASSERT(numberOfHosts_ <= sizeOfHosts_);
count = 0;
MUTEX_LOCK(&lock_);
- for (i=0;i<count_;i++) {
+ for (i=0;i<numberOfHosts_;i++) {
entry = hosts_[i];
if (hostIdentityEquals(&entry->identity,
&myIdentity))
@@ -823,7 +836,7 @@
MUTEX_LOCK(&lock_);
/* we gave up the lock,
need to re-aquire entry (if possible)! */
- if (i >= count_)
+ if (i >= numberOfHosts_)
break;
entry = hosts_[i];
if (hostIdentityEquals(&entry->identity,
@@ -839,7 +852,7 @@
count++;
if (callback != NULL) {
hi = tempHosts[i]->senderIdentity;
- proto = tempHosts[i]->protocol;
+ proto = ntohs(tempHosts[i]->protocol);
MUTEX_UNLOCK(&lock_);
callback(&hi,
proto,
@@ -895,7 +908,7 @@
static void cronFlushTrustBuffer(void * unused) {
int i;
MUTEX_LOCK(&lock_);
- for (i=0;i<count_;i++)
+ for (i=0;i<numberOfHosts_;i++)
flushHostCredit(hosts_[i]);
MUTEX_UNLOCK(&lock_);
}
@@ -951,7 +964,7 @@
for (i=0;i<MAX_TEMP_HOSTS;i++)
tempHosts[i] = NULL;
tempHostsNextSlot = 0;
- count_ = 0;
+ numberOfHosts_ = 0;
initPrivateKey();
getPeerIdentity(getPublicPrivateKey(),
@@ -1017,7 +1030,7 @@
for (i=0;i<MAX_TEMP_HOSTS;i++)
FREENONNULL(tempHosts[i]);
MUTEX_DESTROY(&lock_);
- for (i=0;i<count_;i++) {
+ for (i=0;i<numberOfHosts_;i++) {
entry = hosts_[i];
for (j=0;j<entry->heloCount;j++)
FREE(entry->helos[j]);
@@ -1030,9 +1043,9 @@
FREE(entry);
}
GROW(hosts_,
- max_,
+ sizeOfHosts_,
0);
- count_ = 0;
+ numberOfHosts_ = 0;
FREE(networkIdDirectory);
networkIdDirectory = NULL;
Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2005-07-07 00:24:08 UTC
(rev 1305)
+++ GNUnet/src/applications/topology_default/topology.c 2005-07-07 13:23:52 UTC
(rev 1306)
@@ -99,9 +99,11 @@
* @param im updated structure used to select the peer
*/
static void scanHelperCount(const PeerIdentity * id,
- const unsigned short proto,
+ unsigned short proto,
int confirmed,
- IndexMatch * im) {
+ void * data) {
+ IndexMatch * im = data;
+
if (hostIdentityEquals(coreAPI->myIdentity, id))
return;
if (coreAPI->computeIndex(id) != im->index)
@@ -123,7 +125,9 @@
static void scanHelperSelect(const PeerIdentity * id,
unsigned short proto,
int confirmed,
- IndexMatch * im) {
+ void * data) {
+ IndexMatch * im = data;
+
if (hostIdentityEquals(coreAPI->myIdentity, id))
return;
if (coreAPI->computeIndex(id) != im->index)
@@ -155,7 +159,7 @@
indexMatch.matchCount = 0;
indexMatch.costSelector = 0;
identity->forEachHost(now,
- (HostIterator)&scanHelperCount,
+ &scanHelperCount,
&indexMatch);
if (indexMatch.matchCount == 0) {
LOG(LOG_EVERYTHING,
@@ -168,7 +172,7 @@
= randomi(indexMatch.costSelector/4)*4;
indexMatch.match = *(coreAPI->myIdentity);
identity->forEachHost(now,
- (HostIterator)&scanHelperSelect,
+ &scanHelperSelect,
&indexMatch);
if (hostIdentityEquals(coreAPI->myIdentity,
&indexMatch.match)) {
@@ -256,7 +260,11 @@
int slotCount;
int active;
unsigned int minint;
+ int autoconnect;
+ autoconnect = testConfigurationString("GNUNETD",
+ "DISABLE-AUTOCONNECT",
+ "YES");
slotCount = coreAPI->getSlotCount();
if (saturation > 0.001)
minint = (int) 1 / saturation;
@@ -268,9 +276,7 @@
if (weak_randomi(LIVE_SCAN_EFFECTIVENESS) != 0)
continue;
if ( (minint > coreAPI->isSlotUsed(i)) &&
- (! testConfigurationString("GNUNETD",
- "DISABLE-AUTOCONNECT",
- "YES")) )
+ (! autoconnect) )
scanForHosts(i);
}
if (weak_randomi(LIVE_PING_EFFECTIVENESS) == 0)
@@ -281,7 +287,7 @@
active = coreAPI->forAllConnectedNodes
(NULL,
NULL);
- saturation = 1.0 * slotCount / active;
+ saturation = 1.0 * active / slotCount;
}
static int estimateNetworkSize() {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r1306 - in GNUnet: . src/applications/identity src/applications/topology_default,
grothoff <=