gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r37501 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r37501 - gnunet/src/transport
Date: Fri, 8 Jul 2016 19:50:41 +0200

Author: grothoff
Date: 2016-07-08 19:50:41 +0200 (Fri, 08 Jul 2016)
New Revision: 37501

Modified:
   gnunet/src/transport/Makefile.am
   gnunet/src/transport/transport_api_core.c
Log:
get transport_api_core to compile

Modified: gnunet/src/transport/Makefile.am
===================================================================
--- gnunet/src/transport/Makefile.am    2016-07-08 17:39:10 UTC (rev 37500)
+++ gnunet/src/transport/Makefile.am    2016-07-08 17:50:41 UTC (rev 37501)
@@ -165,6 +165,7 @@
   transport_api.c transport.h \
   transport_api_address_to_string.c \
   transport_api_blacklist.c \
+  transport_api_core.c \
   transport_api_get_hello.c \
   transport_api_monitor_peers.c \
   transport_api_monitor_plugins.c \

Modified: gnunet/src/transport/transport_api_core.c
===================================================================
--- gnunet/src/transport/transport_api_core.c   2016-07-08 17:39:10 UTC (rev 
37500)
+++ gnunet/src/transport/transport_api_core.c   2016-07-08 17:50:41 UTC (rev 
37501)
@@ -121,7 +121,7 @@
  * Handle for the transport service (includes all of the
  * state for the transport service).
  */
-struct GNUNET_TRANSPORT_Handle
+struct GNUNET_TRANSPORT_CoreHandle
 {
 
   /**
@@ -191,16 +191,6 @@
 
 
 /**
- * Schedule the task to send one message, either from the control
- * list or the peer message queues  to the service.
- *
- * @param h transport service to schedule a transmission for
- */
-static void
-schedule_transmission (struct GNUNET_TRANSPORT_Handle *h);
-
-
-/**
  * Function that will schedule the job that will try
  * to connect us again to the client.
  *
@@ -207,7 +197,7 @@
  * @param h transport service to reconnect
  */
 static void
-disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h);
+disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_CoreHandle *h);
 
 
 /**
@@ -218,7 +208,7 @@
  * @return NULL if no such peer entry exists
  */
 static struct Neighbour *
-neighbour_find (struct GNUNET_TRANSPORT_Handle *h,
+neighbour_find (struct GNUNET_TRANSPORT_CoreHandle *h,
                 const struct GNUNET_PeerIdentity *peer)
 {
   return GNUNET_CONTAINER_multipeermap_get (h->neighbours,
@@ -236,11 +226,12 @@
 notify_excess_cb (void *cls)
 {
   struct Neighbour *n = cls;
-  struct GNUNET_TRANSPORT_Handle *h = n->h;
+  struct GNUNET_TRANSPORT_CoreHandle *h = n->h;
 
   if (NULL != h->neb_cb)
     h->neb_cb (h->cls,
-               &n->id);
+               &n->id,
+               n->handlers_cls);
 }
 
 
@@ -247,7 +238,7 @@
 /**
  * Iterator over hash map entries, for deleting state of a neighbour.
  *
- * @param cls the `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls the `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param key peer identity
  * @param value value in the hash map, the neighbour entry to delete
  * @return #GNUNET_YES if we should continue to
@@ -259,7 +250,7 @@
                  const struct GNUNET_PeerIdentity *key,
                   void *value)
 {
-  struct GNUNET_TRANSPORT_Handle *handle = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *handle = cls;
   struct Neighbour *n = value;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -297,7 +288,7 @@
  * the message queue.
  * Not every message queue implementation supports an error handler.
  *
- * @param cls closure with the `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure with the `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param error error code
  */
 static void
@@ -304,7 +295,7 @@
 mq_error_handler (void *cls,
                   enum GNUNET_MQ_Error error)
 {
-  struct GNUNET_TRANSPORT_Handle *h = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *h = cls;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Error receiving from transport service, disconnecting temporarily.\n");
@@ -315,7 +306,7 @@
 /**
  * Function we use for checking incoming HELLO messages.
  *
- * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param msg message received
  * @return #GNUNET_OK if message is well-formed
  */
@@ -339,7 +330,7 @@
 /**
  * Function we use for handling incoming HELLO messages.
  *
- * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param msg message received
  */
 static void
@@ -365,7 +356,7 @@
   struct GNUNET_TIME_Relative delay;
 
   n->timeout_task = NULL;
-  if (NULL != env)
+  if (NULL != n->env)
   {
     GNUNET_BANDWIDTH_tracker_consume (&n->out_tracker,
                                       n->env_size + n->traffic_overhead);
@@ -377,12 +368,13 @@
   if (0 == delay.rel_value_us)
   {
     n->is_ready = GNUNET_YES;
-    GNUNET_MQ_impl_send_continue (mq);
+    GNUNET_MQ_impl_send_continue (n->mq);
     return;
   }
   /* cannot send even a small message without violating
      quota, wait a before notifying MQ */
-  n->timeout_task = GNUNET_SCHEDULER_add_delayed (&notify_send_done,
+  n->timeout_task = GNUNET_SCHEDULER_add_delayed (delay,
+                                                  &notify_send_done,
                                                   n);
 }
 
@@ -405,7 +397,6 @@
   struct Neighbour *n = impl_state;
   struct GNUNET_TRANSPORT_CoreHandle *h = n->h;
   struct OutboundMessage *obm;
-  struct GNUNET_MQ_Envelope *env;
   uint16_t msize;
 
   GNUNET_assert (GNUNET_YES == n->is_ready);
@@ -420,18 +411,16 @@
                                     GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
                                     msg);
   obm->reserved = htonl (0);
-  obm->timeout =
-    GNUNET_TIME_relative_hton (GNUNET_TIME_absolute_get_remaining
-                               (th->timeout));
+  obm->timeout = GNUNET_TIME_relative_hton (GNUNET_TIME_UNIT_ZERO); /* FIXME: 
to be removed */
   obm->peer = n->id;
   GNUNET_assert (NULL == n->timeout_task);
   n->is_ready = GNUNET_NO;
   n->env_size = ntohs (msg->size);
-  GNUNET_MQ_notify_sent (env,
+  GNUNET_MQ_notify_sent (n->env,
                          &notify_send_done,
                          n);
   GNUNET_MQ_send (h->mq,
-                  env);
+                  n->env);
 }
 
 
@@ -489,7 +478,7 @@
 peer_mq_error_handler (void *cls,
                        enum GNUNET_MQ_Error error)
 {
-  struct Neighbour *n = cls;
+  /* struct Neighbour *n = cls; */
 
   GNUNET_break_op (0);
 }
@@ -496,6 +485,29 @@
 
 
 /**
+ * The outbound quota has changed in a way that may require
+ * us to reset the timeout.  Update the timeout.
+ *
+ * @param cls the `struct Neighbour` for which the timeout changed
+ */
+static void
+outbound_bw_tracker_update (void *cls)
+{
+  struct Neighbour *n = cls;
+  struct GNUNET_TIME_Relative delay;
+
+  if (NULL == n->timeout_task)
+    return;
+  delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker,
+                                              128);
+  GNUNET_SCHEDULER_cancel (n->timeout_task);
+  n->timeout_task = GNUNET_SCHEDULER_add_delayed (delay,
+                                                  &notify_send_done,
+                                                  n);
+}
+
+
+/**
  * Function we use for handling incoming connect messages.
  *
  * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
@@ -505,7 +517,7 @@
 handle_connect (void *cls,
                 const struct ConnectInfoMessage *cim)
 {
-  struct GNUNET_TRANSPORT_Handle *h = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *h = cls;
   struct Neighbour *n;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -560,7 +572,7 @@
 /**
  * Function we use for handling incoming disconnect messages.
  *
- * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param dim message received
  */
 static void
@@ -567,7 +579,7 @@
 handle_disconnect (void *cls,
                    const struct DisconnectInfoMessage *dim)
 {
-  struct GNUNET_TRANSPORT_Handle *h = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *h = cls;
   struct Neighbour *n;
 
   GNUNET_break (ntohl (dim->reserved) == 0);
@@ -591,7 +603,7 @@
 /**
  * Function we use for handling incoming send-ok messages.
  *
- * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param okm message received
  */
 static void
@@ -598,7 +610,7 @@
 handle_send_ok (void *cls,
                 const struct SendOkMessage *okm)
 {
-  struct GNUNET_TRANSPORT_Handle *h = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *h = cls;
   struct Neighbour *n;
   uint32_t bytes_msg;
   uint32_t bytes_physical;
@@ -633,7 +645,7 @@
 /**
  * Function we use for checking incoming "inbound" messages.
  *
- * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param im message received
  */
 static int
@@ -663,7 +675,7 @@
 /**
  * Function we use for handling incoming messages.
  *
- * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param im message received
  */
 static void
@@ -670,7 +682,7 @@
 handle_recv (void *cls,
              const struct InboundMessage *im)
 {
-  struct GNUNET_TRANSPORT_Handle *h = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *h = cls;
   const struct GNUNET_MessageHeader *imm
     = (const struct GNUNET_MessageHeader *) &im[1];
   struct Neighbour *n;
@@ -695,7 +707,7 @@
 /**
  * Function we use for handling incoming set quota messages.
  *
- * @param cls closure, a `struct GNUNET_TRANSPORT_Handle *`
+ * @param cls closure, a `struct GNUNET_TRANSPORT_CoreHandle *`
  * @param msg message received
  */
 static void
@@ -702,7 +714,7 @@
 handle_set_quota (void *cls,
                   const struct QuotaSetMessage *qm)
 {
-  struct GNUNET_TRANSPORT_Handle *h = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *h = cls;
   struct Neighbour *n;
 
   n = neighbour_find (h, &qm->peer);
@@ -747,7 +759,7 @@
   GNUNET_MQ_hd_fixed_size (set_quota,
                            GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA,
                            struct QuotaSetMessage);
-  struct GNUNET_TRANSPORT_Handle *h = cls;
+  struct GNUNET_TRANSPORT_CoreHandle *h = cls;
   struct GNUNET_MQ_MessageHandler handlers[] = {
     make_hello_handler (h),
     make_connect_handler (h),
@@ -777,7 +789,7 @@
   options = 0;
   if (h->check_self)
     options |= 1;
-  if (NULL != h->rec)
+  if (NULL != h->handlers)
     options |= 2;
   s->options = htonl (options);
   s->self = h->self;
@@ -793,7 +805,7 @@
  * @param h transport service to reconnect
  */
 static void
-disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
+disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_CoreHandle *h)
 {
   GNUNET_assert (NULL == h->reconnect_task);
   if (NULL != h->mq)
@@ -805,11 +817,6 @@
   GNUNET_CONTAINER_multipeermap_iterate (h->neighbours,
                                          &neighbour_delete,
                                          h);
-  if (NULL != h->quota_task)
-  {
-    GNUNET_SCHEDULER_cancel (h->quota_task);
-    h->quota_task = NULL;
-  }
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Scheduling task to reconnect to transport service in %s.\n",
        GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay,
@@ -830,7 +837,7 @@
  * @return NULL if disconnected, otherwise message queue for @a peer
  */
 struct GNUNET_MQ_Handle *
-GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_Handle *handle,
+GNUNET_TRANSPORT_core_get_mq (struct GNUNET_TRANSPORT_CoreHandle *handle,
                               const struct GNUNET_PeerIdentity *peer)
 {
   struct Neighbour *n;
@@ -862,9 +869,9 @@
                           const struct GNUNET_PeerIdentity *self,
                           const struct GNUNET_MQ_MessageHandler *handlers,
                           void *cls,
-                          GNUNET_TRANSPORT_NotifyConnect nc,
-                          GNUNET_TRANSPORT_NotifyDisconnect nd,
-                          GNUNET_TRANSPORT_NotifyExcessBandwidth neb)
+                          GNUNET_TRANSPORT_NotifyConnecT nc,
+                          GNUNET_TRANSPORT_NotifyDisconnecT nd,
+                          GNUNET_TRANSPORT_NotifyExcessBandwidtH neb)
 {
   struct GNUNET_TRANSPORT_CoreHandle *h;
   unsigned int i;
@@ -926,11 +933,6 @@
   }
   GNUNET_CONTAINER_multipeermap_destroy (handle->neighbours);
   handle->neighbours = NULL;
-  if (NULL != handle->quota_task)
-  {
-    GNUNET_SCHEDULER_cancel (handle->quota_task);
-    handle->quota_task = NULL;
-  }
   GNUNET_free_non_null (handle->handlers);
   handle->handlers = NULL;
   GNUNET_free (handle);




reply via email to

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