adding Ludo's gnunet-download-manager.scm back to SVN HEAD
[oweals/gnunet.git] / src / core / core_api.c
index 878e25a2e18a1bac12419c4fefaf1566c4f92331..66df134fb1acaf7c5ace5f77f1f02c79a954bf14 100644 (file)
@@ -421,7 +421,7 @@ disconnect_and_free_peer_entry (void *cls, const GNUNET_HashCode * key,
                  GNUNET_CONTAINER_multihashmap_remove (h->peers, key, pr));
   GNUNET_assert (pr->pending_head == NULL);
   GNUNET_assert (pr->pending_tail == NULL);
-  GNUNET_assert (pr->ch = h);
+  GNUNET_assert (pr->ch == h);
   GNUNET_assert (pr->queue_size == 0);
   GNUNET_assert (pr->timeout_task == GNUNET_SCHEDULER_NO_TASK);
   GNUNET_assert (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK);
@@ -781,7 +781,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
   const struct GNUNET_MessageHeader *em;
   const struct SendMessageReady *smr;
   const struct GNUNET_CORE_MessageHandler *mh;
-  const struct GNUNET_ATS_Informationats;
+  const struct GNUNET_ATS_Information *ats;
   GNUNET_CORE_StartupCallback init;
   struct PeerRecord *pr;
   struct GNUNET_CORE_TransmitHandle *th;
@@ -864,8 +864,8 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
     cnm = (const struct ConnectNotifyMessage *) msg;
     ats_count = ntohl (cnm->ats_count);
     if (msize !=
-       sizeof (struct ConnectNotifyMessage) +
-       ats_count * sizeof (struct GNUNET_ATS_Information))
+        sizeof (struct ConnectNotifyMessage) +
+        ats_count * sizeof (struct GNUNET_ATS_Information))
     {
       GNUNET_break (0);
       reconnect_later (h);
@@ -896,11 +896,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
                    GNUNET_CONTAINER_multihashmap_put (h->peers,
                                                       &cnm->peer.hashPubKey, pr,
                                                       GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
-    ats = (const struct GNUNET_ATS_Information*) &cnm[1];
+    ats = (const struct GNUNET_ATS_Information *) &cnm[1];
     if (NULL != h->connects)
-      h->connects (h->cls, &cnm->peer, 
-                  ats,
-                  ats_count);
+      h->connects (h->cls, &cnm->peer, ats, ats_count);
     break;
   case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT:
     if (msize != sizeof (struct DisconnectNotifyMessage))
@@ -949,8 +947,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
          sizeof (struct NotifyTrafficMessage) +
          ats_count * sizeof (struct GNUNET_ATS_Information) +
          sizeof (struct GNUNET_MessageHeader)) ||
-        (GNUNET_ATS_ARRAY_TERMINATOR !=
-         ntohl ((&ntm->ats)[ats_count].type)))
+        (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
     {
       GNUNET_break (0);
       reconnect_later (h);
@@ -986,23 +983,22 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
         continue;
       if ((mh->expected_size != ntohs (em->size)) && (mh->expected_size != 0))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   "Unexpected message size for message of type %u\n",
-                   mh->type);
-        GNUNET_break (0);
+        GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                    "Unexpected message size %u for message of type %u from peer `%4s'\n",
+                    htons (em->size), mh->type, GNUNET_i2s (&ntm->peer));
+        GNUNET_break_op (0);
         continue;
       }
       if (GNUNET_OK !=
           h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats,
-                                     ats_count))
+                                      ats_count))
       {
         /* error in processing, do not process other messages! */
         break;
       }
     }
     if (NULL != h->inbound_notify)
-      h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats,
-                        ats_count);
+      h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats, ats_count);
     break;
   case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND:
     if (msize < sizeof (struct NotifyTrafficMessage))
@@ -1023,8 +1019,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg)
          sizeof (struct NotifyTrafficMessage) +
          ats_count * sizeof (struct GNUNET_ATS_Information) +
          sizeof (struct GNUNET_MessageHeader)) ||
-        (GNUNET_ATS_ARRAY_TERMINATOR !=
-         ntohl ((&ntm->ats)[ats_count].type)))
+        (GNUNET_ATS_ARRAY_TERMINATOR != ntohl ((&ntm->ats)[ats_count].type)))
     {
       GNUNET_break (0);
       reconnect_later (h);
@@ -1428,15 +1423,12 @@ GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork,
     GNUNET_free (minp);
   }
 
-  /* Order entries by deadline, but SKIP 'HEAD' if
-   * we're in the 'ready_peer_*' DLL */
+  /* Order entries by deadline, but SKIP 'HEAD' (as we may have transmitted
+   * that request already or might even already be approved to transmit that
+   * message to core) */
   pos = pr->pending_head;
-  if ((pr->prev != NULL) || (pr->next != NULL) ||
-      (pr == handle->ready_peer_head))
-  {
-    GNUNET_assert (pos != NULL);
+  if (pos != NULL)
     pos = pos->next;            /* skip head */
-  }
 
   /* insertion sort */
   prev = pos;