-indent, doxygen
[oweals/gnunet.git] / src / dv / gnunet-service-dv.c
index 7d5f24e6e01d658f22ca8b834354c9c0d3cddedd..67db7072bd10e59a61eba4ea22dd8a3c285876dd 100644 (file)
@@ -637,7 +637,7 @@ core_transmit_notify (void *cls, size_t size, void *buf)
     dn->cth =
       GNUNET_CORE_notify_transmit_ready (core_api,
                                         GNUNET_YES /* cork */,
-                                        0 /* priority */,
+                                        GNUNET_CORE_PRIO_BEST_EFFORT,
                                         GNUNET_TIME_UNIT_FOREVER_REL,
                                         &dn->peer,
                                         msize,
@@ -705,7 +705,7 @@ forward_payload (struct DirectNeighbor *target,
   if (NULL == target->cth)
     target->cth = GNUNET_CORE_notify_transmit_ready (core_api,
                                                     GNUNET_YES /* cork */,
-                                                    0 /* priority */,
+                                                    GNUNET_CORE_PRIO_BEST_EFFORT,
                                                     GNUNET_TIME_UNIT_FOREVER_REL,
                                                     &target->peer,
                                                     msize,
@@ -1321,6 +1321,12 @@ handle_ats_update (void *cls,
   uint32_t distance;
   enum GNUNET_ATS_Network_Type network = GNUNET_ATS_NET_UNSPECIFIED;
 
+  if (NULL == address)
+  {
+    /* ATS service temporarily disconnected */
+    return;
+  }
+
   if (GNUNET_NO == active)
     return;
   distance = get_atsi_distance (ats, ats_count);
@@ -1539,6 +1545,7 @@ handle_set_union_result (void *cls,
                         enum GNUNET_SET_Status status)
 {
   struct DirectNeighbor *neighbor = cls;
+  struct DirectNeighbor *dn;
   struct Target *target;
   char *status_str;
 
@@ -1575,9 +1582,7 @@ handle_set_union_result (void *cls,
       GNUNET_break_op (0);
       return;
     }
-    if (GNUNET_YES ==
-        GNUNET_CONTAINER_multipeermap_contains (direct_neighbors,
-                                                &((struct Target *) element->data)->peer))
+    if ( (NULL != (dn = GNUNET_CONTAINER_multipeermap_get (direct_neighbors, &((struct Target *) element->data)->peer))) && (DIRECT_NEIGHBOR_COST == dn->distance) )
     {
       /* this is a direct neighbor of ours, we do not care about routes
          to this peer */
@@ -1775,6 +1780,7 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
   const struct GNUNET_MessageHeader *payload;
   struct Route *route;
   struct DirectNeighbor *neighbor;
+  struct DirectNeighbor *dn;
   struct Target *target;
   uint32_t distance;
   char me[5];
@@ -1812,8 +1818,9 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
                   &my_identity,
                   sizeof (struct GNUNET_PeerIdentity)))
   {
-    if (NULL != GNUNET_CONTAINER_multipeermap_get (direct_neighbors,
-                                                   &rm->sender))
+    if ((NULL
+        != (dn = GNUNET_CONTAINER_multipeermap_get (direct_neighbors,
+            &rm->sender))) && (DIRECT_NEIGHBOR_COST == dn->distance))
     {
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Discarding DV message, as %s is a direct neighbor\n",
@@ -1854,6 +1861,7 @@ handle_dv_route_message (void *cls, const struct GNUNET_PeerIdentity *peer,
       {
         GNUNET_break_op (0);
         GNUNET_free (target);
+        return GNUNET_SYSERR;
       }
       add_new_route (target, neighbor);
     }