misc fixes
authorChristian Grothoff <christian@grothoff.org>
Mon, 18 Jan 2010 16:00:03 +0000 (16:00 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 18 Jan 2010 16:00:03 +0000 (16:00 +0000)
TODO
src/core/core_api_peer_get_info.c
src/include/gnunet_core_service.h
src/topology/gnunet-daemon-topology.c
src/util/container_meta_data.c
src/util/test_container_heap.c
src/util/test_container_meta_data.c

diff --git a/TODO b/TODO
index 02ba1ee1f96bf2769113503e0e90ab5a0ae1c955..ab1d9617237b597414b7928f901ca3be532c5fc1 100644 (file)
--- a/TODO
+++ b/TODO
@@ -67,6 +67,8 @@ Urgent items (before announcing ng.gnunet.org):
 * ARM:
   - need to get rid of synchronous API for service starts (cause all kinds of problems)
     [=> eliminate for need to tell ARM about service starts most of the time!]
+* HELLO:
+  - need function to test "equivalency" of HELLOs; use in topology!
 * Module features to implement:
   - advanced FS API parts
     + namespaces: fundamental namespace API
index aa6aff0400bfa9edda151e5415a3e093fb4dcd0c..23ae04f0163d0e960fc531cbc873c5c7ef2f6fd7 100644 (file)
@@ -64,7 +64,7 @@ receive_info (void *cls,
 
   if (msg == NULL)
     {
-      if (irc != NULL)
+      if (irc->info != NULL)
        irc->info (irc->info_cls, 
                   NULL, 0, 0, GNUNET_TIME_UNIT_FOREVER_REL, 0, 0);     
       GNUNET_CLIENT_disconnect (irc->client);
@@ -75,7 +75,7 @@ receive_info (void *cls,
        (ntohs (msg->size) != sizeof (struct ConfigurationInfoMessage)) )
     {
       GNUNET_break (0);
-      if (irc != NULL)
+      if (irc->info != NULL)
        irc->info (irc->info_cls, 
                   NULL, 0, 0, GNUNET_TIME_UNIT_FOREVER_REL, 0, 0);     
       GNUNET_CLIENT_disconnect (irc->client);
@@ -83,7 +83,7 @@ receive_info (void *cls,
       return;
     }
   cim = (const struct ConfigurationInfoMessage*) msg;
-  if (irc != NULL)
+  if (irc->info != NULL)
     irc->info (irc->info_cls,
               &cim->peer,
               ntohl (cim->bpm_in),
index b9869fde00592b8e957233326c3029642510b64b..94656b916e1271cd372b7efd85d3ed32e0e99085 100644 (file)
@@ -175,8 +175,10 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched,
 void GNUNET_CORE_disconnect (struct GNUNET_CORE_Handle *handle);
 
 
+// FIXME
 struct GNUNET_CORE_PeerRequestHandle;
 
+// FIXME
 struct GNUNET_CORE_PeerRequestHandle *
 GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched,
                                         const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -185,6 +187,7 @@ GNUNET_CORE_peer_request_connect (struct GNUNET_SCHEDULER_Handle *sched,
                                         void *cont_cls);
 
 
+// FIXME
 struct GNUNET_CORE_PeerRequestHandle *
 GNUNET_CORE_peer_request_disconnect (struct GNUNET_SCHEDULER_Handle *sched,
                                            const struct GNUNET_CONFIGURATION_Handle *cfg,
@@ -192,6 +195,7 @@ GNUNET_CORE_peer_request_disconnect (struct GNUNET_SCHEDULER_Handle *sched,
                                            GNUNET_SCHEDULER_Task cont,
                                            void *cont_cls);
 
+// FIXME
 void
 GNUNET_CORE_peer_request_cancel (struct GNUNET_CORE_PeerRequestHandle *req);
 
index 0e4bbffc90840a02468b8c36db01e391a2107ea1..407bea4a04c7bdd507f78c62d8170addea3617eb 100644 (file)
@@ -856,7 +856,6 @@ process_peer (void *cls,
   if (hello == NULL)
     {
       /* free existing HELLO, if any */
-      pos = find_peer (peer);
       if (NULL != (pos = find_peer (peer)))
        {
          GNUNET_free_non_null (pos->hello);
@@ -1063,11 +1062,9 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg)
          fl = make_peer (&pid,
                          NULL,
                          GNUNET_YES);
-#if DEBUG_TOPOLOGY
-         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                     "Found friend `%s' in configuration\n",
+         GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                     _("Found friend `%s' in configuration\n"),
                      GNUNET_i2s (&fl->id));
-#endif       
        }
       pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded);
       while ((pos < frstat.st_size) && isspace (data[pos]))
index 82847f7afcc6ff90f327f51bedc1e877f002c7b3..fadb0dede2feef8e3418a9c044237f72791d8f65 100644 (file)
@@ -519,7 +519,8 @@ GNUNET_CONTAINER_meta_data_get_thumbnail (const struct
        }
       pos = pos->next;
     }
-  if (match == NULL)
+  if ( (match == NULL) ||
+       (match->data_size == 0) )
     return 0;
   *thumb = GNUNET_malloc (match->data_size);
   memcpy (*thumb, match->data, match->data_size);
@@ -855,9 +856,11 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
       off -= pos->data_size;
       memcpy (&mdata[off], pos->data, pos->data_size);
       off -= plen;
-      memcpy (&mdata[off], pos->plugin_name, plen);
+      if (pos->plugin_name != NULL)
+       memcpy (&mdata[off], pos->plugin_name, plen);
       off -= mlen;
-      memcpy (&mdata[off], pos->mime_type, mlen);      
+      if (pos->mime_type != NULL)
+       memcpy (&mdata[off], pos->mime_type, mlen);      
       i++;
       pos = pos->next;
     }  
@@ -866,6 +869,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
   clen = 0;
   cdata = NULL;
   left = size;
+  pos = md->items;
   for (i=0;i<md->item_count;i++)
     {           
       comp = GNUNET_NO;
@@ -887,6 +891,7 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
          hdr->entries = htonl (md->item_count);
          if (GNUNET_YES == comp)
            {
+             GNUNET_assert (clen < left);
              hdr->version = htonl (2 | HEADER_COMPRESSED);
              memcpy (&hdr[1],
                      cdata, 
@@ -960,7 +965,8 @@ GNUNET_CONTAINER_meta_data_serialize (const struct GNUNET_CONTAINER_MetaData
       if (pos->plugin_name != NULL)
        left -= strlen (pos->plugin_name) + 1;
       if (pos->mime_type != NULL)
-       left -= strlen (pos->mime_type) + 1;      
+       left -= strlen (pos->mime_type) + 1;
+      pos = pos->next;
     }
   GNUNET_free (ent);
 
index b6e5f642a428335d668f0bb96ccfb2180db09c85..b24624ad8c194c2788a529c341d9acf8bae3849e 100644 (file)
@@ -51,6 +51,7 @@ check ()
 
   myHeap = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
   n1 = GNUNET_CONTAINER_heap_insert (myHeap, "11", 11);
+  GNUNET_assert (NULL != n1);
   GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
   GNUNET_assert (1 == GNUNET_CONTAINER_heap_get_size (myHeap));
   n2 = GNUNET_CONTAINER_heap_insert (myHeap, "78", 78);
@@ -66,6 +67,7 @@ check ()
   GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
 
   n4 = GNUNET_CONTAINER_heap_insert (myHeap, "50", 50);
+  GNUNET_CONTAINER_heap_update_cost (myHeap, n4, 0);
   GNUNET_assert (3 == GNUNET_CONTAINER_heap_get_size (myHeap));
   GNUNET_CONTAINER_heap_iterate (myHeap, &iterator_callback, NULL);
 
index 2cf3f2a093784347a012514fe8e7130caa85a805..b6196da148aeb4c3db9315f11ae9b0e2e54e4cf7 100644 (file)
@@ -262,6 +262,7 @@ testThumbnail ()
   EXTRACTOR_plugin_remove_all (ex);
   d = GNUNET_CONTAINER_meta_data_duplicate (m);
   GNUNET_CONTAINER_meta_data_destroy (m);
+  thumb = NULL;
   size = GNUNET_CONTAINER_meta_data_get_thumbnail (d, &thumb);
   if (size == 0)
     {