gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r2781 - in GNUnet: . src/include src/transports src/util


From: grothoff
Subject: [GNUnet-SVN] r2781 - in GNUnet: . src/include src/transports src/util
Date: Wed, 10 May 2006 21:31:31 -0700 (PDT)

Author: grothoff
Date: 2006-05-10 21:31:27 -0700 (Wed, 10 May 2006)
New Revision: 2781

Modified:
   GNUnet/ChangeLog
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/transports/udp.c
   GNUnet/src/transports/udp6.c
   GNUnet/src/util/hashing.c
Log:
fixing 0-size UDP bug

Modified: GNUnet/ChangeLog
===================================================================
--- GNUnet/ChangeLog    2006-05-11 03:39:31 UTC (rev 2780)
+++ GNUnet/ChangeLog    2006-05-11 04:31:27 UTC (rev 2781)
@@ -1,3 +1,7 @@
+Wed May 10 22:11:17 PDT 2006
+       Fixing bug that possibly resulted in hanging the UDP transport;
+       found by Luigi Auriemma (thanks!).
+
 Sat May  6 00:17:59 PDT 2006
        Releasing GNUnet 0.7.0d.
 

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2006-05-11 03:39:31 UTC (rev 2780)
+++ GNUnet/src/include/gnunet_util.h    2006-05-11 04:31:27 UTC (rev 2781)
@@ -1469,9 +1469,10 @@
  * a.a or a.e (they're used elsewhere), and
  * be somewhat consistent. And of course, the
  * result should be a positive number.
+ * @return number between 0 and 65536
  */
-int distanceHashCode512(const HashCode512 * a,
-                       const HashCode512 * b);
+unsigned int distanceHashCode512(const HashCode512 * a,
+                                const HashCode512 * b);
 
 /**
  * compare two hashcodes.

Modified: GNUnet/src/transports/udp.c
===================================================================
--- GNUnet/src/transports/udp.c 2006-05-11 03:39:31 UTC (rev 2780)
+++ GNUnet/src/transports/udp.c 2006-05-11 04:31:27 UTC (rev 2781)
@@ -247,7 +247,21 @@
     }
     if (pending <= 0) {
       LOG(LOG_WARNING,
-         _("UDP: select returned, but ioctl reports 0 bytes available!\n"));
+         _("UDP: select returned, but ioctl reports %d bytes available!\n"),
+         pending);
+      if (pending == 0) {
+       /* maybe empty UDP packet was sent (see report on bug-gnunet,
+          5/11/6; read 0 bytes from UDP just to kill potential empty packet! */
+       memset(&incoming,
+              0, 
+              sizeof(struct sockaddr_in));
+       RECVFROM(udp_sock,
+                NULL,
+                0,
+                0,
+                (struct sockaddr * )&incoming,
+                &addrlen);     
+      }
       continue;
     }   
     if (pending >= 65536) {

Modified: GNUnet/src/transports/udp6.c
===================================================================
--- GNUnet/src/transports/udp6.c        2006-05-11 03:39:31 UTC (rev 2780)
+++ GNUnet/src/transports/udp6.c        2006-05-11 04:31:27 UTC (rev 2781)
@@ -230,6 +230,25 @@
       LOG_STRERROR(LOG_ERROR, "ioctl");
       continue;
     }
+    if (pending <= 0) {
+      LOG(LOG_WARNING,
+         _("UDP6: select returned, but ioctl reports %d bytes available!\n"),
+         pending);
+      if (pending == 0) {
+       /* maybe empty UDP packet was sent (see report on bug-gnunet,
+          5/11/6; read 0 bytes from UDP just to kill potential empty packet! */
+       memset(&incoming,
+              0, 
+              sizeof(struct sockaddr_in6));
+       RECVFROM(udp6_sock,
+                NULL,
+                0,
+                0,
+                (struct sockaddr * )&incoming,
+                &addrlen);     
+      }
+      continue;
+    }   
     if (pending >= 65536) {
       BREAK();
       continue;

Modified: GNUnet/src/util/hashing.c
===================================================================
--- GNUnet/src/util/hashing.c   2006-05-11 03:39:31 UTC (rev 2780)
+++ GNUnet/src/util/hashing.c   2006-05-11 04:31:27 UTC (rev 2781)
@@ -501,9 +501,9 @@
  * @returns a positive number which is a measure for
  *  hashcode proximity.
  */
-int distanceHashCode512(const HashCode512 * a,
-                       const HashCode512 * b) {
-  int x = (a->bits[1] - b->bits[1])>>16;
+unsigned int distanceHashCode512(const HashCode512 * a,
+                                const HashCode512 * b) {
+  unsigned int x = (a->bits[1] - b->bits[1])>>16;
   return ((x*x)>>16);
 }
 





reply via email to

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