-makefile for new test_stream_local (commented)
[oweals/gnunet.git] / src / transport / gnunet-service-transport_clients.c
index 3cc5aac34aa162da9fcf110355298c75901d6207..227f4f093c782393d54a8393f7e0bb34f28a7609 100644 (file)
@@ -210,7 +210,7 @@ setup_client (struct GNUNET_SERVER_Client *client)
   tc->client = client;
 
 #if DEBUG_TRANSPORT
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %X connected\n", tc);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc);
 #endif
   return tc;
 }
@@ -264,7 +264,7 @@ setup_monitoring_client (struct GNUNET_SERVER_Client *client,
   GNUNET_SERVER_notification_context_add (nc, client);
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Client %X started monitoring of the peer `%s'\n",
+              "Client %p started monitoring of the peer `%s'\n",
               mc, GNUNET_i2s (peer));
   return mc;
 }
@@ -309,7 +309,7 @@ transmit_to_client_callback (void *cls, size_t size, void *buf)
       break;
 #if DEBUG_TRANSPORT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                "Transmitting message of type %u to client %X.\n",
+                "Transmitting message of type %u to client %p.\n",
                 ntohs (msg->type), tc);
 #endif
     GNUNET_CONTAINER_DLL_remove (tc->message_queue_head, tc->message_queue_tail,
@@ -405,7 +405,7 @@ client_disconnect_notification (void *cls, struct GNUNET_SERVER_Client *client)
     return;
 #if DEBUG_TRANSPORT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
-              "Client %X disconnected, cleaning up.\n", tc);
+              "Client %p disconnected, cleaning up.\n", tc);
 #endif
   while (NULL != (mqe = tc->message_queue_head))
   {
@@ -482,19 +482,15 @@ clients_handle_start (void *cls, struct GNUNET_SERVER_Client *client,
   tc = lookup_client (client);
 
 #if DEBUG_TRANSPORT
-  if (tc != NULL)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
-                "Client %X sent START\n", tc);
-  else
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
-                "Client %X sent START\n", tc);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+              "Client %p sent START\n", tc);
 #endif
   if (tc != NULL)
   {
     /* got 'start' twice from the same client, not allowed */
 #if DEBUG_TRANSPORT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
-                "TransportClient %X ServerClient %X  sent multiple START messages\n",
+                "TransportClient %p ServerClient %p sent multiple START messages\n",
                 tc, tc->client);
 #endif
     GNUNET_break (0);
@@ -792,6 +788,10 @@ clients_handle_address_to_string (void *cls,
     return;
   }
   GNUNET_SERVER_disable_receive_done_warning (client);
+  if ((NULL == address) || (0 == address_len))
+  {
+    GNUNET_break_op (0);
+  }
   papi->address_pretty_printer (papi->cls, plugin_name, address, address_len,
                                 numeric, rtimeout, &transmit_address_to_client,
                                 tc);
@@ -884,7 +884,6 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
   struct GNUNET_SERVER_TransmitContext *tc;
   struct AddressIterateMessage *msg;
   struct GNUNET_HELLO_Address *address;
-  struct MonitoringClient *mc;
 
   if (ntohs (message->type) != GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE)
   {
@@ -899,6 +898,16 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
     return;
   }
   msg = (struct AddressIterateMessage *) message;
+  if ( (GNUNET_YES != ntohl (msg->one_shot)) &&
+       (NULL != lookup_monitoring_client (client)) )
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
+               "ServerClient %p tried to start monitoring twice\n",
+               client);
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
   GNUNET_SERVER_disable_receive_done_warning (client);
   tc = GNUNET_SERVER_transmit_context_create (client);
   if (0 == memcmp (&msg->peer, &all_zeros, sizeof (struct GNUNET_PeerIdentity)))
@@ -914,23 +923,10 @@ clients_handle_address_iterate (void *cls, struct GNUNET_SERVER_Client *client,
       output_address (tc, &msg->peer, NULL, 0, address);
   }
   if (GNUNET_YES != ntohl (msg->one_shot))
-  {
-    mc = lookup_monitoring_client (client);
-    if (mc != NULL)
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
-                  "ServerClient %X tried to start monitoring twice (MonitoringClient %X)\n",
-                  client, mc);
-      GNUNET_break (0);
-      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
-      return;
-    }
     setup_monitoring_client (client, &msg->peer);
-    GNUNET_SERVER_receive_done (client, GNUNET_OK);
-    return;
-  }
-  GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
-                                             GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);
+  else
+    GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
+                                               GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE_RESPONSE);  
   GNUNET_SERVER_transmit_context_run (tc, GNUNET_TIME_UNIT_FOREVER_REL);
 }