-fix misc monitoring issues
authorChristian Grothoff <christian@grothoff.org>
Sun, 23 Nov 2014 20:12:32 +0000 (20:12 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 23 Nov 2014 20:12:32 +0000 (20:12 +0000)
src/transport/gnunet-service-transport_clients.c
src/transport/gnunet-service-transport_plugins.c
src/transport/gnunet-transport.c
src/transport/plugin_transport_tcp.c
src/transport/transport_api_monitor_peers.c
src/transport/transport_api_monitor_plugins.c
src/util/client.c

index 96b3e0bf3dda78374caba0ca387cf963d243f487..d0aba723d93c43c46a63f48436d22ce8409f0a5b 100644 (file)
@@ -1235,7 +1235,6 @@ send_peer_information (void *cls,
 }
 
 
-
 /**
  * Client asked to obtain information about a specific or all peers
  * Process the request.
@@ -1399,6 +1398,7 @@ plugin_session_info_cb (void *cls,
 
   if (0 == GNUNET_SERVER_notification_context_get_size (plugin_nc))
   {
+    fprintf (stderr, "UNSUB!\n");
     GST_plugins_monitor_subscribe (NULL, NULL);
     return;
   }
@@ -1463,9 +1463,9 @@ clients_handle_monitor_plugins (void *cls,
 {
   GNUNET_SERVER_client_mark_monitor (client);
   GNUNET_SERVER_disable_receive_done_warning (client);
-  if (0 == GNUNET_SERVER_notification_context_get_size (plugin_nc))
-    GST_plugins_monitor_subscribe (&plugin_session_info_cb, NULL);
   GNUNET_SERVER_notification_context_add (plugin_nc, client);
+  if (1 == GNUNET_SERVER_notification_context_get_size (plugin_nc))
+    GST_plugins_monitor_subscribe (&plugin_session_info_cb, NULL);
 }
 
 
@@ -1557,7 +1557,8 @@ GST_clients_stop ()
  * @param may_drop #GNUNET_YES if the message can be dropped / is payload
  */
 void
-GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
+GST_clients_broadcast (const struct GNUNET_MessageHeader *msg,
+                       int may_drop)
 {
   struct TransportClient *tc;
 
@@ -1579,7 +1580,8 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop)
  */
 void
 GST_clients_unicast (struct GNUNET_SERVER_Client *client,
-                     const struct GNUNET_MessageHeader *msg, int may_drop)
+                     const struct GNUNET_MessageHeader *msg,
+                     int may_drop)
 {
   struct TransportClient *tc;
 
@@ -1604,9 +1606,10 @@ GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer,
                                          enum GNUNET_TRANSPORT_PeerState state,
                                          struct GNUNET_TIME_Absolute state_timeout)
 {
+  static struct GNUNET_PeerIdentity all_zeros;
   struct PeerIterateResponseMessage *msg;
   struct MonitoringClient *mc;
-  static struct GNUNET_PeerIdentity all_zeros;
+
   msg = compose_address_iterate_response_message (peer, address);
   msg->state = htonl (state);
   msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout);
index e43b7057adbec29485131285b85c6a1d9420149f..c029fcbc6fc1fdf228da4447be945494e312cfca 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of GNUnet.
   (C) 2010-2014 Christian Grothoff (and other contributing authors)
-  
+
   GNUnet is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
   by the Free Software Foundation; either version 3, or (at your
@@ -78,7 +78,6 @@ static struct TransportPlugin *plugins_head;
 static struct TransportPlugin *plugins_tail;
 
 
-
 /**
  * Load and initialize all plugins.  The respective functions will be
  * invoked by the plugins when the respective events happen.  The
index 24be066bc06acb286d0b4e52bcbbe45110af2992..4b1e683f600c00c6d37d0e538869d5307eed4934 100644 (file)
@@ -1599,9 +1599,12 @@ plugin_monitoring_cb (void *cls,
   const char *state;
   struct PluginMonitorAddress *addr;
 
+  fprintf (stderr, "E!\n");
   if ( (NULL == info) &&
        (NULL == session) )
     return; /* in sync with transport service */
+  if (NULL == info)
+    return; /* shutdown */
   if ( (NULL != cpid) &&
        (0 != memcmp (&info->address->peer,
                      cpid,
index ba8b5895ed73d32abf2fce52494ad9a1d5a46449..664dcbb7dafed5e3e49cdc0f6bf3cb1433b1e879 100644 (file)
@@ -475,7 +475,9 @@ notify_session_monitor (struct Plugin *plugin,
     return;
   memset (&info, 0, sizeof (info));
   info.state = state;
-  info.is_inbound = GNUNET_SYSERR; /* hard to say */
+  info.is_inbound = (0 != (GNUNET_HELLO_ADDRESS_INFO_INBOUND & session->address->local_info))
+    ? GNUNET_YES
+    : GNUNET_NO;
   info.num_msg_pending = session->msgs_in_queue;
   info.num_bytes_pending = session->bytes_in_queue;
   if (GNUNET_SCHEDULER_NO_TASK != session->receive_delay_task)
@@ -494,9 +496,9 @@ notify_session_monitor (struct Plugin *plugin,
  * address and that the next call to this function is allowed
  * to override the address again.
  *
- * @param cls closure ('struct Plugin*')
+ * @param cls closure (`struct Plugin *`)
  * @param addr binary address
- * @param addrlen length of the address
+ * @param addrlen length of @a addr
  * @return string representing the same address
  */
 static const char *
@@ -513,7 +515,7 @@ tcp_plugin_address_to_string (void *cls,
  * @param cls the `struct Plugin`
  * @param ucred credentials, if available, otherwise NULL
  * @param addr address
- * @param addrlen length of address
+ * @param addrlen length of @a addr
  * @return #GNUNET_YES to allow, #GNUNET_NO to deny, #GNUNET_SYSERR
  *   for unknown address family (will be denied).
  */
@@ -2194,10 +2196,11 @@ handle_tcp_nat_probe (void *cls,
     t4->options = htonl (TCP_OPTIONS_NONE);
     t4->t4_port = s4->sin_port;
     t4->ipv4_addr = s4->sin_addr.s_addr;
-    session->address = GNUNET_HELLO_address_allocate (
-        &tcp_nat_probe->clientIdentity, PLUGIN_NAME, &t4,
-        sizeof(struct IPv4TcpAddress),
-        GNUNET_HELLO_ADDRESS_INFO_NONE);
+    session->address = GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
+                                                      PLUGIN_NAME,
+                                                      &t4,
+                                                      sizeof(struct IPv4TcpAddress),
+                                                      GNUNET_HELLO_ADDRESS_INFO_NONE);
     break;
   case AF_INET6:
     s6 = vaddr;
@@ -2205,10 +2208,11 @@ handle_tcp_nat_probe (void *cls,
     t6->options = htonl (TCP_OPTIONS_NONE);
     t6->t6_port = s6->sin6_port;
     memcpy (&t6->ipv6_addr, &s6->sin6_addr, sizeof(struct in6_addr));
-    session->address = GNUNET_HELLO_address_allocate (
-        &tcp_nat_probe->clientIdentity,
-        PLUGIN_NAME, &t6, sizeof(struct IPv6TcpAddress),
-        GNUNET_HELLO_ADDRESS_INFO_NONE);
+    session->address = GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
+                                                      PLUGIN_NAME,
+                                                      &t6,
+                                                      sizeof(struct IPv6TcpAddress),
+                                                      GNUNET_HELLO_ADDRESS_INFO_NONE);
     break;
   default:
     GNUNET_break_op(0);
@@ -2305,8 +2309,10 @@ handle_tcp_welcome (void *cls,
         t4.t4_port = s4->sin_port;
         t4.ipv4_addr = s4->sin_addr.s_addr;
         address = GNUNET_HELLO_address_allocate (&wm->clientIdentity,
-            PLUGIN_NAME, &t4, sizeof(t4),
-            GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+                                                 PLUGIN_NAME,
+                                                 &t4,
+                                                 sizeof(t4),
+                                                 GNUNET_HELLO_ADDRESS_INFO_INBOUND);
       }
       else if (alen == sizeof(struct sockaddr_in6))
       {
index f1dab26e2677455e0ee4714346b61e399afb3a60..611580f688a6009b60650e951788efd13a3229a9 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2009, 2010 Christian Grothoff (and other contributing authors)
+     (C) 2009-2014 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
index 1bbb4c102d98b4e4684e7a34b51f36ba8990b4a4..d14323ec602893db5f778d1e73408f5b04461edd 100644 (file)
@@ -291,6 +291,7 @@ response_processor (void *cls,
   struct GNUNET_HELLO_Address addr;
   struct SearchContext rv;
 
+  fprintf (stderr, "R\n");
   if (NULL == msg)
   {
     reconnect_plugin_ctx (pm);
@@ -304,6 +305,10 @@ response_processor (void *cls,
             NULL,
             NULL,
             NULL);
+    GNUNET_CLIENT_receive (pm->client,
+                           &response_processor,
+                           pm,
+                           GNUNET_TIME_UNIT_FOREVER_REL);
     return;
   }
 
@@ -383,6 +388,10 @@ response_processor (void *cls,
                                                            ps));
     GNUNET_free (ps);
   }
+  GNUNET_CLIENT_receive (pm->client,
+                         &response_processor,
+                         pm,
+                         GNUNET_TIME_UNIT_FOREVER_REL);
 }
 
 
index 15d52ec60e6b7113dbd8715b5dcca53f7b431029..018411d1e17254369d4af993e7806c06951bebee 100644 (file)
@@ -217,7 +217,7 @@ struct GNUNET_CLIENT_Connection
 
   /**
    * Are we currently busy doing receive-processing?
-   * GNUNET_YES if so, GNUNET_NO if not.
+   * #GNUNET_YES if so, #GNUNET_NO if not.
    */
   int in_receive;