-fix docu
[oweals/gnunet.git] / src / core / gnunet-service-core_clients.c
index 98a55bef92e5103c71dd2c4da228fef281d18ab5..4098b45b18116c7da20bb6e6e9f6d2606bdf788a 100644 (file)
@@ -207,6 +207,8 @@ type_match (uint16_t type, struct GSC_Client *c)
  * Send a message to all of our current clients that have the right
  * options set.
  *
+ * @param sender origin of the message (used to check that this peer is
+ *        known to be connected to the respective client)
  * @param msg message to multicast
  * @param can_drop can this message be discarded if the queue is too long
  * @param options mask to use
@@ -341,13 +343,14 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
               "Client asked for transmission to `%s'\n",
               GNUNET_i2s (&req->peer));
 #endif
-  is_loopback = (0 ==
-                memcmp (&req->peer, &GSC_my_identity,
-                        sizeof (struct GNUNET_PeerIdentity)));
-  if ( (! is_loopback) &&
-       (GNUNET_YES !=
-       GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
-                                               &req->peer.hashPubKey)) )
+  is_loopback =
+      (0 ==
+       memcmp (&req->peer, &GSC_my_identity,
+               sizeof (struct GNUNET_PeerIdentity)));
+  if ((!is_loopback) &&
+      (GNUNET_YES !=
+       GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
+                                               &req->peer.hashPubKey)))
   {
     /* neighbour must have disconnected since request was issued,
      * ignore (client will realize it once it processes the
@@ -388,8 +391,8 @@ handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
     GSC_CLIENTS_solicit_request (car);
     GNUNET_SERVER_receive_done (client, GNUNET_OK);
     return;
-  }  
-  GSC_SESSIONS_queue_request (car);  
+  }
+  GSC_SESSIONS_queue_request (car);
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -606,15 +609,23 @@ GSC_CLIENTS_solicit_request (struct GSC_ClientActiveRequest *car)
   struct SendMessageReady smr;
 
   c = car->client_handle;
+  if (GNUNET_YES !=
+      GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
+                                              &car->target.hashPubKey))
+  {
+    /* connection has gone down since, drop request */
+    GNUNET_assert (0 !=
+                   memcmp (&car->target, &GSC_my_identity,
+                           sizeof (struct GNUNET_PeerIdentity)));
+    GSC_SESSIONS_dequeue_request (car);
+    GSC_CLIENTS_reject_request (car);
+    return;
+  }
   smr.header.size = htons (sizeof (struct SendMessageReady));
   smr.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_READY);
   smr.size = htons (car->msize);
   smr.smr_id = car->smr_id;
   smr.peer = car->target;
-  GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multihashmap_contains (c->connectmap,
-                                                         &car->
-                                                         target.hashPubKey));
   send_to_client (c, &smr.header, GNUNET_NO);
 }
 
@@ -650,7 +661,6 @@ GSC_CLIENTS_reject_request (struct GSC_ClientActiveRequest *car)
  * @param atsi_count number of entries in 'ats' array
  * @param tmap_old previous type map for the neighbour, NULL for disconnect
  * @param tmap_new updated type map for the neighbour, NULL for disconnect
- * @param is_new GNUNET_YES if this is a completely new neighbour
  */
 void
 GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,