gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r35071 - in gnunet/src: include transport


From: gnunet
Subject: [GNUnet-SVN] r35071 - in gnunet/src: include transport
Date: Tue, 3 Feb 2015 00:31:25 +0100

Author: grothoff
Date: 2015-02-03 00:31:25 +0100 (Tue, 03 Feb 2015)
New Revision: 35071

Modified:
   gnunet/src/include/gnunet_transport_plugin.h
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/gnunet-service-transport_neighbours.c
   gnunet/src/transport/gnunet-service-transport_neighbours.h
   gnunet/src/transport/gnunet-service-transport_plugins.c
   gnunet/src/transport/gnunet-service-transport_plugins.h
   gnunet/src/transport/plugin_transport_tcp.c
   gnunet/src/transport/test_transport_api_monitor_peers.c
Log:
dramatically simplify quota notification: avoid registration, simply always 
notify plugin

Modified: gnunet/src/include/gnunet_transport_plugin.h
===================================================================
--- gnunet/src/include/gnunet_transport_plugin.h        2015-02-02 23:16:13 UTC 
(rev 35070)
+++ gnunet/src/include/gnunet_transport_plugin.h        2015-02-02 23:31:25 UTC 
(rev 35071)
@@ -193,38 +193,6 @@
 
 
 /**
- * Function to be called by the plugin to be notified about changes to the 
quota
- * for a specific peer, plugin and session
- *
- * @param cls closure
- * @param peer the peer to be notified about
- * @param plugin the plugin to be notified about
- * @param session the session for include in the notification
- *
- */
-typedef void
-(*GNUNET_TRANSPORT_RegisterQuotaNotification) (void *cls,
-                                               const struct 
GNUNET_PeerIdentity *peer,
-                                               const char *plugin,
-                                               struct Session *session);
-
-
-/**
- * Function to be called by the plugin to stop notification about changes to 
the quota
- * for a specific peer, plugin and session
- *
- * @param cls closure
- * @param peer the peer to be notified about
- * @param plugin the plugin to be notified about
- * @param session the session for include in the notification
- */
-typedef void
-(*GNUNET_TRANSPORT_UnregisterQuotaNotification) (void *cls,
-                                                 const struct 
GNUNET_PeerIdentity *peer,
-                                                 const char *plugin,
-                                                 struct Session *session);
-
-/**
  * Function that returns a HELLO message.
  *
  * @return HELLO message (FIXME with what?)
@@ -307,16 +275,6 @@
   GNUNET_TRANSPORT_UpdateAddressMetrics update_address_metrics;
 
   /**
-   * FIXME: document!
-   */
-  GNUNET_TRANSPORT_RegisterQuotaNotification register_quota_notification;
-
-  /**
-   * FIXME: document!
-   */
-  GNUNET_TRANSPORT_UnregisterQuotaNotification unregister_quota_notification;
-
-  /**
    * What is the maximum number of connections that this transport
    * should allow?  Transports that do not have sessions (such as
    * UDP) can ignore this value.

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2015-02-02 23:16:13 UTC 
(rev 35070)
+++ gnunet/src/transport/gnunet-service-transport.c     2015-02-02 23:31:25 UTC 
(rev 35071)
@@ -989,8 +989,6 @@
   GST_ats_init ();
   GST_manipulation_init (GST_cfg);
   GST_plugins_load (&GST_manipulation_recv,
-                    &GST_neighbours_register_quota_notification,
-                    &GST_neighbours_unregister_quota_notification,
                     &plugin_env_address_change_notification,
                     &plugin_env_session_start,
                     &plugin_env_session_end,

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-02-02 
23:16:13 UTC (rev 35070)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c  2015-02-02 
23:31:25 UTC (rev 35071)
@@ -522,12 +522,7 @@
  */
 static struct GNUNET_SCHEDULER_Task * util_transmission_tk;
 
-/**
- * FIXME
- */
-static struct GNUNET_CONTAINER_MultiPeerMap *registered_quota_notifications;
 
-
 /**
  * FIXME
  */
@@ -2027,176 +2022,35 @@
 
 }
 
-struct QuotaNotificationRequest
-{
-  struct GNUNET_PeerIdentity peer;
-  struct Session *session;
-  char *plugin;
-};
 
-struct QNR_LookContext
+static void
+inbound_bw_tracker_update (void *cls)
 {
-  struct GNUNET_PeerIdentity peer;
-  struct Session *session;
-  const char *plugin;
-
-  struct QuotaNotificationRequest *res;
-};
-
-static int
-find_notification_request (void *cls, const struct GNUNET_PeerIdentity *key, 
void *value)
-{
-  struct QNR_LookContext *qnr_ctx = cls;
-  struct QuotaNotificationRequest *qnr = value;
-
-  if ((qnr->session == qnr_ctx->session) &&
-      (0 == memcmp (&qnr->peer,
-                    &qnr_ctx->peer,
-                    sizeof (struct GNUNET_PeerIdentity))) &&
-      (0 == strcmp(qnr_ctx->plugin, qnr->plugin)))
-  {
-    qnr_ctx->res = value;
-    return GNUNET_NO;
-  }
-  return GNUNET_YES;
-}
-
-
-void
-GST_neighbours_register_quota_notification (void *cls,
-                                            const struct GNUNET_PeerIdentity 
*peer,
-                                            const char *plugin,
-                                            struct Session *session)
-{
-  struct QuotaNotificationRequest *qnr;
-  struct QNR_LookContext qnr_ctx;
-
-  if (NULL == registered_quota_notifications)
-  {
-    return; /* init or shutdown */
-  }
-
-  qnr_ctx.peer = (*peer);
-  qnr_ctx.plugin = plugin;
-  qnr_ctx.session = session;
-  qnr_ctx.res = NULL;
-
-  GNUNET_CONTAINER_multipeermap_get_multiple (registered_quota_notifications,
-      peer, &find_notification_request, &qnr_ctx);
-  if (NULL != qnr_ctx.res)
-  {
-    GNUNET_break(0);
-    return;
-  }
-
-  qnr = GNUNET_new (struct QuotaNotificationRequest);
-  qnr->peer =  (*peer);
-  qnr->plugin = GNUNET_strdup (plugin);
-  qnr->session = session;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      "Adding notification for peer `%s' plugin `%s' session %p \n",
-      GNUNET_i2s (peer), plugin, session);
-
-  GNUNET_CONTAINER_multipeermap_put (registered_quota_notifications, peer,
-      qnr, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
-}
-
-
-void
-GST_neighbours_unregister_quota_notification(void *cls,
-                                             const struct GNUNET_PeerIdentity 
*peer,
-                                             const char *plugin,
-                                             struct Session *session)
-{
-  struct QNR_LookContext qnr_ctx;
-
-  if (NULL == registered_quota_notifications)
-  {
-    return; /* init or shutdown */
-  }
-
-  qnr_ctx.peer = (*peer);
-  qnr_ctx.plugin = plugin;
-  qnr_ctx.session = session;
-  qnr_ctx.res = NULL;
-
-  GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications,
-      &find_notification_request, &qnr_ctx);
-  if (NULL == qnr_ctx.res)
-  {
-    GNUNET_break(0);
-    return;
-  }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      "Removing notification for peer `%s' plugin `%s' session %p \n",
-      GNUNET_i2s (peer), plugin, session);
-
-  GNUNET_CONTAINER_multipeermap_remove (registered_quota_notifications, peer,
-      qnr_ctx.res);
-  GNUNET_free (qnr_ctx.res->plugin);
-  GNUNET_free (qnr_ctx.res);
-}
-
-
-static int
-notification_cb (void *cls,
-                 const struct GNUNET_PeerIdentity *key,
-                 void *value)
-{
-  /* struct NeighbourMapEntry *n = cls; */
-  struct QuotaNotificationRequest *qnr = value;
+  struct NeighbourMapEntry *n = cls;
   struct GNUNET_TRANSPORT_PluginFunctions *papi;
   struct GNUNET_TIME_Relative delay;
   int do_forward;
 
-  papi = GST_plugins_find(qnr->plugin);
-  if (NULL == papi)
-  {
-    GNUNET_break (0);
-    return GNUNET_OK;
-  }
-
-  delay = GST_neighbours_calculate_receive_delay (key, 0, &do_forward);
+  if (NULL == n->primary_address.address)
+    return; /* not active, ignore */
+  papi = GST_plugins_find (n->primary_address.address->transport_name);
+  GNUNET_assert (NULL != papi);
+  if (NULL == papi->update_inbound_delay)
+    return;
+  delay = GST_neighbours_calculate_receive_delay (&n->id,
+                                                  0,
+                                                  &do_forward);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      "New inbound delay for peer `%s' is %llu ms\n", GNUNET_i2s (key),
-      delay.rel_value_us / 1000);
-
-  if (NULL != papi->update_inbound_delay)
-    papi->update_inbound_delay (papi->cls, key, qnr->session, delay);
-  return GNUNET_OK;
+              "New inbound delay for peer `%s' is %llu ms\n",
+              GNUNET_i2s (&n->id),
+              delay.rel_value_us / 1000);
+  papi->update_inbound_delay (papi->cls,
+                              &n->id,
+                              n->primary_address.session,
+                              delay);
 }
 
 
-static int
-free_notification_cb (void *cls,
-                      const struct GNUNET_PeerIdentity *key,
-                      void *value)
-{
-  /* struct NeighbourMapEntry *n = cls; */
-  struct QuotaNotificationRequest *qnr = value;
-
-  GNUNET_break (GNUNET_OK == GNUNET_CONTAINER_multipeermap_remove 
(registered_quota_notifications, key,
-      qnr));
-  GNUNET_free(qnr->plugin);
-  GNUNET_free(qnr);
-
-  return GNUNET_OK;
-}
-
-
-static void
-inbound_bw_tracker_update (void *cls)
-{
-  struct NeighbourMapEntry *n = cls;
-
-  /* Quota was updated, tell plugins to update the time to receive next */
-  GNUNET_CONTAINER_multipeermap_get_multiple (registered_quota_notifications,
-      &n->id, &notification_cb, n);
-}
-
-
 /**
  * Create a fresh entry in the neighbour map for the given peer
  *
@@ -2220,11 +2074,15 @@
   n->util_payload_bytes_sent = 0;
   n->util_total_bytes_recv = 0;
   n->util_total_bytes_sent = 0;
-  GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, &inbound_bw_tracker_update, n,
+  GNUNET_BANDWIDTH_tracker_init (&n->in_tracker,
+                                 &inbound_bw_tracker_update,
+                                 n,
                                  GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
                                  MAX_BANDWIDTH_CARRY_S);
   n->task = GNUNET_SCHEDULER_add_now (&master_task, n);
-  set_state_and_timeout (n, GNUNET_TRANSPORT_PS_NOT_CONNECTED, 
GNUNET_TIME_UNIT_FOREVER_ABS);
+  set_state_and_timeout (n,
+                         GNUNET_TRANSPORT_PS_NOT_CONNECTED,
+                         GNUNET_TIME_UNIT_FOREVER_ABS);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONTAINER_multipeermap_put (neighbours,
                                                     &n->id, n,
@@ -3900,7 +3758,6 @@
 GST_neighbours_start (unsigned int max_fds)
 {
   neighbours = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE, 
GNUNET_NO);
-  registered_quota_notifications = GNUNET_CONTAINER_multipeermap_create 
(NEIGHBOUR_TABLE_SIZE, GNUNET_NO);
   util_transmission_tk = GNUNET_SCHEDULER_add_delayed 
(UTIL_TRANSMISSION_INTERVAL,
       utilization_transmission, NULL);
 }
@@ -3967,12 +3824,6 @@
       GNUNET_HELLO_address_free (cur->address);
     GNUNET_free (cur);
   }
-
-  GNUNET_CONTAINER_multipeermap_iterate (registered_quota_notifications,
-                                         &free_notification_cb, NULL);
-  GNUNET_CONTAINER_multipeermap_destroy (registered_quota_notifications);
-  registered_quota_notifications = NULL;
-
   neighbours = NULL;
 }
 

Modified: gnunet/src/transport/gnunet-service-transport_neighbours.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.h  2015-02-02 
23:16:13 UTC (rev 35070)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.h  2015-02-02 
23:31:25 UTC (rev 35071)
@@ -102,28 +102,7 @@
                      GST_NeighbourSendContinuation cont, void *cont_cls);
 
 
-
 /**
- * FIXME
- */
-void
-GST_neighbours_register_quota_notification (void *cls,
-                                           const struct GNUNET_PeerIdentity 
*peer,
-                                           const char *plugin,
-                                           struct Session *session);
-
-
-/**
- * FIXME
- */
-void
-GST_neighbours_unregister_quota_notification (void *cls,
-                                              const struct GNUNET_PeerIdentity 
*peer,
-                                              const char *plugin,
-                                              struct Session *session);
-
-
-/**
  * We have received a message from the given sender.
  * How long should we delay before receiving more?
  * (Also used to keep the peer marked as live).

Modified: gnunet/src/transport/gnunet-service-transport_plugins.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.c     2015-02-02 
23:16:13 UTC (rev 35070)
+++ gnunet/src/transport/gnunet-service-transport_plugins.c     2015-02-02 
23:31:25 UTC (rev 35071)
@@ -85,8 +85,6 @@
  * plugin that caused the call.
  *
  * @param recv_cb function to call when data is received
- * @param register_quota_cb function to call to register a quota callback
- * @param unregister_quota_cb function to call to unregister a quota callback
  * @param address_cb function to call when our public addresses changed
  * @param session_start_cb function to call when a session was created
  * @param session_end_cb function to call when a session was terminated
@@ -95,8 +93,6 @@
  */
 void
 GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
-                  GNUNET_TRANSPORT_RegisterQuotaNotification register_quota_cb,
-                  GNUNET_TRANSPORT_UnregisterQuotaNotification 
unregister_quota_cb,
                   GNUNET_TRANSPORT_AddressNotification address_cb,
                   GNUNET_TRANSPORT_SessionStart session_start_cb,
                   GNUNET_TRANSPORT_SessionEnd session_end_cb,
@@ -145,15 +141,13 @@
     plug->env.session_end = session_end_cb;
     plug->env.get_address_type = address_type_cb;
     plug->env.update_address_metrics = metric_update_cb;
-    plug->env.register_quota_notification = register_quota_cb;
-    plug->env.unregister_quota_notification = unregister_quota_cb;
     plug->env.max_connections = tneigh;
     plug->env.stats = GST_stats;
     GNUNET_CONTAINER_DLL_insert (plugins_head, plugins_tail, plug);
   }
   GNUNET_free (plugs);
   next = plugins_head;
-  while (next != NULL)
+  while (NULL != next)
   {
     plug = next;
     next = plug->next;

Modified: gnunet/src/transport/gnunet-service-transport_plugins.h
===================================================================
--- gnunet/src/transport/gnunet-service-transport_plugins.h     2015-02-02 
23:16:13 UTC (rev 35070)
+++ gnunet/src/transport/gnunet-service-transport_plugins.h     2015-02-02 
23:31:25 UTC (rev 35071)
@@ -50,8 +50,6 @@
  */
 void
 GST_plugins_load (GNUNET_TRANSPORT_PluginReceiveCallback recv_cb,
-                  GNUNET_TRANSPORT_RegisterQuotaNotification register_quota_cb,
-                  GNUNET_TRANSPORT_UnregisterQuotaNotification 
unregister_quota_cb,
                   GNUNET_TRANSPORT_AddressNotification address_cb,
                   GNUNET_TRANSPORT_SessionStart session_start_cb,
                   GNUNET_TRANSPORT_SessionEnd session_end_cb,

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2015-02-02 23:16:13 UTC (rev 
35070)
+++ gnunet/src/transport/plugin_transport_tcp.c 2015-02-02 23:31:25 UTC (rev 
35071)
@@ -845,10 +845,6 @@
     GNUNET_SERVER_notify_transmit_ready_cancel (session->transmit_handle);
     session->transmit_handle = NULL;
   }
-  plugin->env->unregister_quota_notification (plugin->env->cls,
-                                              &session->target,
-                                              PLUGIN_NAME,
-                                              session);
   session->plugin->env->session_end (session->plugin->env->cls,
                                      session->address,
                                      session);
@@ -1054,10 +1050,6 @@
                             session,
                             GNUNET_TRANSPORT_SS_HANDSHAKE);
   }
-  plugin->env->register_quota_notification (plugin->env->cls,
-                                            &address->peer,
-                                            PLUGIN_NAME,
-                                            session);
   return session;
 }
 

Modified: gnunet/src/transport/test_transport_api_monitor_peers.c
===================================================================
--- gnunet/src/transport/test_transport_api_monitor_peers.c     2015-02-02 
23:16:13 UTC (rev 35070)
+++ gnunet/src/transport/test_transport_api_monitor_peers.c     2015-02-02 
23:31:25 UTC (rev 35071)
@@ -386,6 +386,7 @@
 
 static void
 monitor1_cb (void *cls,
+             const struct GNUNET_PeerIdentity *peer,
              const struct GNUNET_HELLO_Address *address,
              enum GNUNET_TRANSPORT_PeerState state,
              struct GNUNET_TIME_Absolute state_timeout)
@@ -411,6 +412,7 @@
 
 static void
 monitor2_cb (void *cls,
+             const struct GNUNET_PeerIdentity *peer,
              const struct GNUNET_HELLO_Address *address,
              enum GNUNET_TRANSPORT_PeerState state,
              struct GNUNET_TIME_Absolute state_timeout)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]