fix #4895: set highbit always for the returned cn, not just on the second call
authorChristian Grothoff <christian@grothoff.org>
Wed, 15 Feb 2017 16:49:59 +0000 (17:49 +0100)
committerChristian Grothoff <christian@grothoff.org>
Wed, 15 Feb 2017 16:49:59 +0000 (17:49 +0100)
src/cadet/gnunet-service-cadet-new_tunnels.c

index 1b7e4d9d31709886a8775178095f8191a2761cb9..5b3abde576f5b2a38ac70b8dc6ed5608ecf3ba31 100644 (file)
@@ -1888,12 +1888,12 @@ get_next_free_ctn (struct CadetTunnel *t)
   ctn = ntohl (t->next_ctn.cn);
   while (NULL !=
          GNUNET_CONTAINER_multihashmap32_get (t->channels,
-                                              ctn))
+                                              ctn | highbit))
   {
-    ctn = ((ctn + 1) & (~ HIGH_BIT)) | highbit;
+    ctn = ((ctn + 1) & (~ HIGH_BIT));
   }
-  t->next_ctn.cn = htonl (((ctn + 1) & (~ HIGH_BIT)) | highbit);
-  ret.cn = htonl (ctn);
+  t->next_ctn.cn = htonl ((ctn + 1) & (~ HIGH_BIT));
+  ret.cn = htonl (ctn | highbit);
   return ret;
 }