gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5848 - GNUnet/src/applications/topology_default


From: gnunet
Subject: [GNUnet-SVN] r5848 - GNUnet/src/applications/topology_default
Date: Sun, 9 Dec 2007 19:44:41 -0700 (MST)

Author: grothoff
Date: 2007-12-09 19:44:41 -0700 (Sun, 09 Dec 2007)
New Revision: 5848

Modified:
   GNUnet/src/applications/topology_default/topology.c
Log:
fx

Modified: GNUnet/src/applications/topology_default/topology.c
===================================================================
--- GNUnet/src/applications/topology_default/topology.c 2007-12-10 02:41:34 UTC 
(rev 5847)
+++ GNUnet/src/applications/topology_default/topology.c 2007-12-10 02:44:41 UTC 
(rev 5848)
@@ -529,67 +529,72 @@
                      GNUNET_GE_IMMEDIATE,
                      "Could not read friends list `%s'\n", fn);
       GNUNET_free (fn);
-      return GNUNET_SYSERR;
+      fn = NULL;
+      if ( (friends_only) ||
+          (minimum_friend_count > 0) )
+       return GNUNET_SYSERR;
     }
-  data = GNUNET_malloc (size);
-  if (size != GNUNET_disk_file_read (ectx, fn, size, data))
+  if (fn != NULL) 
     {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
-                     _("Failed to read friends list from `%s'\n"), fn);
-      GNUNET_free (fn);
-      GNUNET_free (data);
-      return GNUNET_SYSERR;
-    }
-  GNUNET_free (fn);
-  pos = 0;
-  while ((pos < size) && isspace (data[pos]))
-    pos++;
-  while (pos <= size - sizeof (GNUNET_EncName))
-    {
-      memcpy (&enc, &data[pos], sizeof (GNUNET_EncName));
-      if (!isspace (enc.encoding[sizeof (GNUNET_EncName) - 1]))
-        {
-          GNUNET_GE_LOG (ectx,
-                         GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                         _
-                         ("Syntax error in topology specification, skipping 
bytes.\n"));
-          continue;
-        }
-      enc.encoding[sizeof (GNUNET_EncName) - 1] = '\0';
-      if (GNUNET_OK == GNUNET_enc_to_hash ((char *) &enc, &hc))
-        {
-          GNUNET_array_grow (friends, friendCount, friendCount + 1);
-          friends[friendCount - 1].hashPubKey = hc;
-        }
-      else
-        {
-          GNUNET_GE_LOG (ectx,
-                         GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                         _
-                         ("Syntax error in topology specification, skipping 
bytes `%s'.\n"),
-                         &enc);
-        }
-      pos = pos + sizeof (GNUNET_EncName);
+      data = GNUNET_malloc (size);
+      if (size != GNUNET_disk_file_read (ectx, fn, size, data))
+       {
+         GNUNET_GE_LOG (ectx,
+                        GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
+                        _("Failed to read friends list from `%s'\n"), fn);
+         GNUNET_free (fn);
+         GNUNET_free (data);
+         return GNUNET_SYSERR;
+       }
+      GNUNET_free (fn);    
+      pos = 0;
       while ((pos < size) && isspace (data[pos]))
-        pos++;
+       pos++;
+      while (pos <= size - sizeof (GNUNET_EncName))
+       {
+         memcpy (&enc, &data[pos], sizeof (GNUNET_EncName));
+         if (!isspace (enc.encoding[sizeof (GNUNET_EncName) - 1]))
+           {
+             GNUNET_GE_LOG (ectx,
+                            GNUNET_GE_WARNING | GNUNET_GE_BULK | 
GNUNET_GE_USER,
+                            _
+                            ("Syntax error in topology specification, skipping 
bytes.\n"));
+             continue;
+           }
+         enc.encoding[sizeof (GNUNET_EncName) - 1] = '\0';
+         if (GNUNET_OK == GNUNET_enc_to_hash ((char *) &enc, &hc))
+           {
+             GNUNET_array_grow (friends, friendCount, friendCount + 1);
+             friends[friendCount - 1].hashPubKey = hc;
+           }
+         else
+           {
+             GNUNET_GE_LOG (ectx,
+                            GNUNET_GE_WARNING | GNUNET_GE_BULK | 
GNUNET_GE_USER,
+                            _
+                            ("Syntax error in topology specification, skipping 
bytes `%s'.\n"),
+                            &enc);
+           }
+         pos = pos + sizeof (GNUNET_EncName);
+         while ((pos < size) && isspace (data[pos]))
+           pos++;
+       }
+      if ((minimum_friend_count > friendCount) && (friends_only == GNUNET_NO))
+       {
+         GNUNET_GE_LOG (ectx,
+                        GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                        _
+                        ("Fewer friends specified than required by minimum 
friend count. Will only connect to friends.\n"));
+       }
+      if ((minimum_friend_count > coreAPI->getSlotCount ()) &&
+         (friends_only == GNUNET_NO))
+       {
+         GNUNET_GE_LOG (ectx,
+                        GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+                        _
+                        ("More friendly connections required than target total 
number of connections.\n"));
+       }
     }
-  if ((minimum_friend_count > friendCount) && (friends_only == GNUNET_NO))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                     _
-                     ("Fewer friends specified than required by minimum friend 
count. Will only connect to friends.\n"));
-    }
-  if ((minimum_friend_count > coreAPI->getSlotCount ()) &&
-      (friends_only == GNUNET_NO))
-    {
-      GNUNET_GE_LOG (ectx,
-                     GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
-                     _
-                     ("More friendly connections required than target total 
number of connections.\n"));
-    }
-
   return 0;
 }
 
@@ -660,6 +665,9 @@
   coreAPI->releaseService (pingpong);
   pingpong = NULL;
   coreAPI = NULL;
+  GROW(friends,
+       friendCount,
+       0);
   return GNUNET_OK;
 }
 





reply via email to

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