gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r5054 - in GNUnet/src: applications/advertising application


From: gnunet
Subject: [GNUnet-SVN] r5054 - in GNUnet/src: applications/advertising applications/sqstore_sqlite applications/topology_default transports
Date: Thu, 14 Jun 2007 22:56:56 -0600 (MDT)

Author: grothoff
Date: 2007-06-14 22:56:56 -0600 (Thu, 14 Jun 2007)
New Revision: 5054

Modified:
   GNUnet/src/applications/advertising/advertising.c
   GNUnet/src/applications/sqstore_sqlite/sqlite.c
   GNUnet/src/applications/topology_default/topology.c
   GNUnet/src/transports/tcp_helper.c
Log:
going over all callers to find weak_randomi issue, addressing all possible 
candidates

Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c   2007-06-14 09:20:16 UTC 
(rev 5053)
+++ GNUnet/src/applications/advertising/advertising.c   2007-06-15 04:56:56 UTC 
(rev 5054)
@@ -442,7 +442,8 @@
     sd->n--;
     return OK; /* don't advertise NAT addresses via broadcast */
   }
-  if (weak_randomi(sd->n) != 0)
+  if ( (sd->n != 0) &&
+       (weak_randomi(sd->n) != 0) )
     return OK;
 #if DEBUG_ADVERTISING
   IF_GELOG(ectx,
@@ -477,7 +478,8 @@
      we get a probability of 1/n for this, which
      is what we want: fewer attempts to contact fresh
      peers as the network grows): */
-  if (weak_randomi(sd->n) != 0)
+  if ( (sd->n != 0) &&
+       (weak_randomi(sd->n) != 0) )
     return OK;
 
   /* establish short-lived connection, send, tear down */
@@ -527,14 +529,16 @@
  */
 static void
 broadcasthelloTransport(TransportAPI * tapi,
-                       const int * prob) {
+                       void * cls) {
+  const int * prob = cls;
   SendData sd;
   cron_t now;
 
   if (os_network_monitor_get_load(coreAPI->load_monitor,
                                  Upload) > 100)
     return; /* network load too high... */
-  if (0 != weak_randomi(*prob))
+  if ( ((*prob) != 0) &&
+       (0 != weak_randomi(*prob)) )
     return; /* ignore */
   now = get_time();
   sd.n = identity->forEachHost(now,
@@ -580,8 +584,9 @@
     return; /* CPU load too high... */
   i = transport->forEach(NULL,
                         NULL);
-  transport->forEach((TransportCallback)&broadcasthelloTransport,
-                    &i);
+  if (i > 0) 
+    transport->forEach(&broadcasthelloTransport,
+                      &i);
 }
 
 typedef struct {
@@ -595,7 +600,8 @@
   if (os_network_monitor_get_load(coreAPI->load_monitor,
                                  Upload) > 100)
     return; /* network load too high... */
-  if (weak_randomi(fcc->prob) != 0)
+  if ( (fcc->prob != 0) &&
+       (weak_randomi(fcc->prob) != 0) )
     return; /* only forward with a certain chance */
   if (equalsHashCode512(&peer->hashPubKey,
                        &fcc->msg->senderIdentity.hashPubKey))

Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c     2007-06-14 09:20:16 UTC 
(rev 5053)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c     2007-06-15 04:56:56 UTC 
(rev 5054)
@@ -1094,14 +1094,15 @@
   sqlite3_bind_blob(stmt, 6, key, sizeof(HashCode512), SQLITE_TRANSIENT);
   sqlite3_bind_blob(stmt, 7, &value[1], contentSize, SQLITE_TRANSIENT);
   n = sqlite3_step(stmt);
-  sqlite3_reset(stmt);
   if (n != SQLITE_DONE) {
     LOG_SQLITE(dbh,
               GE_ERROR | GE_ADMIN | GE_USER | GE_BULK,
               "sqlite_query");
+    sqlite3_reset(stmt);
     MUTEX_UNLOCK(db->DATABASE_Lock_);
     return SYSERR;
   }
+  sqlite3_reset(stmt);
   db->lastSync++;
   db->payload += getContentDatastoreSize(value);
   MUTEX_UNLOCK(db->DATABASE_Lock_);

Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2007-06-14 09:20:16 UTC 
(rev 5053)
+++ GNUnet/src/applications/topology_default/topology.c 2007-06-15 04:56:56 UTC 
(rev 5054)
@@ -193,7 +193,7 @@
   }
   if (indexMatch.costSelector > 0)
     indexMatch.costSelector
-      = weak_randomi(indexMatch.costSelector/4)*4;
+      = weak_randomi64(indexMatch.costSelector);
   indexMatch.match = *(coreAPI->myIdentity);
   identity->forEachHost(now,
                        &scanHelperSelect,

Modified: GNUnet/src/transports/tcp_helper.c
===================================================================
--- GNUnet/src/transports/tcp_helper.c  2007-06-14 09:20:16 UTC (rev 5053)
+++ GNUnet/src/transports/tcp_helper.c  2007-06-15 04:56:56 UTC (rev 5054)
@@ -465,11 +465,11 @@
     = htons(0);
   welcome.clientIdentity
     = *(coreAPI->myIdentity);
-  if (SYSERR == select_write(selector,
-                            s,                 
-                            &welcome.header,
-                            NO,
-                            YES)) {
+  if (OK != select_write(selector,
+                        s,                     
+                        &welcome.header,
+                        NO,
+                        YES)) {
 #if DEBUG_TCP
     GE_LOG(ectx,
           GE_DEBUG | GE_USER | GE_BULK,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]