gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r10010 - gnunet/src/transport
Date: Fri, 15 Jan 2010 11:07:44 +0100

Author: grothoff
Date: 2010-01-15 11:07:44 +0100 (Fri, 15 Jan 2010)
New Revision: 10010

Modified:
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/transport/plugin_transport.h
   gnunet/src/transport/plugin_transport_tcp.c
Log:
further simplify API

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-01-15 10:07:33 UTC 
(rev 10009)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-01-15 10:07:44 UTC 
(rev 10010)
@@ -1285,83 +1285,6 @@
 
 
 /**
- * FIXME: document.
- */
-struct LookupHelloContext
-{
-  GNUNET_TRANSPORT_AddressCallback iterator;
-
-  void *iterator_cls;
-};
-
-
-/**
- * FIXME: document.
- */
-static int
-lookup_address_callback (void *cls,
-                         const char *tname,
-                         struct GNUNET_TIME_Absolute expiration,
-                         const void *addr, size_t addrlen)
-{
-  struct LookupHelloContext *lhc = cls;
-  lhc->iterator (lhc->iterator_cls, tname, addr, addrlen);
-  return GNUNET_OK;
-}
-
-
-/**
- * FIXME: document.
- */
-static void
-lookup_hello_callback (void *cls,
-                       const struct GNUNET_PeerIdentity *peer,
-                       const struct GNUNET_HELLO_Message *h, uint32_t trust)
-{
-  struct LookupHelloContext *lhc = cls;
-
-  if (peer == NULL)
-    {
-      lhc->iterator (lhc->iterator_cls, NULL, NULL, 0);
-      GNUNET_free (lhc);
-      return;
-    }
-  if (h == NULL)
-    return;
-  GNUNET_HELLO_iterate_addresses (h,
-                                  GNUNET_NO, &lookup_address_callback, lhc);
-}
-
-
-/**
- * Function that allows a transport to query the known
- * network addresses for a given peer.
- *
- * @param cls closure
- * @param timeout after how long should we time out?
- * @param target which peer are we looking for?
- * @param iter function to call for each known address
- * @param iter_cls closure for iter
- */
-static void
-plugin_env_lookup_address (void *cls,
-                           struct GNUNET_TIME_Relative timeout,
-                           const struct GNUNET_PeerIdentity *target,
-                           GNUNET_TRANSPORT_AddressCallback iter,
-                           void *iter_cls)
-{
-  struct LookupHelloContext *lhc;
-
-  lhc = GNUNET_malloc (sizeof (struct LookupHelloContext));
-  lhc->iterator = iter;
-  lhc->iterator_cls = iter_cls;
-  GNUNET_PEERINFO_for_all (cfg,
-                           sched,
-                           target, 0, timeout, &lookup_hello_callback, &lhc);
-}
-
-
-/**
  * Notify all of our clients about a peer connecting.
  */
 static void
@@ -1653,6 +1576,12 @@
    */
   struct ValidationList *e;
 
+  /**
+   * Context for peerinfo iteration.
+   * NULL after we are done processing peerinfo's information.
+   */
+  struct GNUNET_PEERINFO_IteratorContext *piter;
+
 };
 
 
@@ -1723,6 +1652,7 @@
   first_call = GNUNET_NO;
   if (chvc->e == NULL)
     {
+      chvc->piter = NULL;
       first_call = GNUNET_YES;
       chvc->e = GNUNET_malloc (sizeof (struct ValidationList));
       GNUNET_assert (GNUNET_OK ==
@@ -1858,12 +1788,12 @@
   memcpy (chvc->hello, hello, hsize);
   /* finally, check if HELLO was previously validated
      (continuation will then schedule actual validation) */
-  GNUNET_PEERINFO_for_all (cfg,
-                           sched,
-                           &target,
-                           0,
-                           HELLO_VERIFICATION_TIMEOUT,
-                           &check_hello_validated, chvc);
+  chvc->piter = GNUNET_PEERINFO_iterate (cfg,
+                                        sched,
+                                        &target,
+                                        0,
+                                        HELLO_VERIFICATION_TIMEOUT,
+                                        &check_hello_validated, chvc);
   return GNUNET_OK;
 }
 
@@ -2542,7 +2472,6 @@
   plug->env.my_identity = &my_identity;
   plug->env.cls = plug;
   plug->env.receive = &plugin_env_receive;
-  plug->env.lookup = &plugin_env_lookup_address;
   plug->env.notify_address = &plugin_env_notify_address;
   plug->env.notify_validation = &plugin_env_notify_validation;
   plug->env.default_quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / 
(60 * 1000);

Modified: gnunet/src/transport/plugin_transport.h
===================================================================
--- gnunet/src/transport/plugin_transport.h     2010-01-15 10:07:33 UTC (rev 
10009)
+++ gnunet/src/transport/plugin_transport.h     2010-01-15 10:07:44 UTC (rev 
10010)
@@ -145,25 +145,6 @@
 
 
 /**
- * Function that allows a transport to query the known
- * network addresses for a given peer.
- *
- * @param cls closure
- * @param timeout after how long should we time out?
- * @param target which peer are we looking for?
- * @param iter function to call for each known address
- * @param iter_cls closure for iter
- */
-typedef void (*GNUNET_TRANSPORT_LookupAddress) (void *cls,
-                                                struct GNUNET_TIME_Relative
-                                                timeout,
-                                                const struct
-                                                GNUNET_PeerIdentity * target,
-                                                
GNUNET_TRANSPORT_AddressCallback
-                                                iter, void *iter_cls);
-
-
-/**
  * The transport service will pass a pointer to a struct
  * of this type as the first and only argument to the
  * entry point of each transport plugin.
@@ -207,11 +188,6 @@
   GNUNET_TRANSPORT_PluginReceiveCallback receive;
 
   /**
-   * Address lookup function.
-   */
-  GNUNET_TRANSPORT_LookupAddress lookup;
-
-  /**
    * Function that must be called by each plugin to notify the
    * transport service about the addresses under which the transport
    * provided by the plugin can be reached.

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2010-01-15 10:07:33 UTC (rev 
10009)
+++ gnunet/src/transport/plugin_transport_tcp.c 2010-01-15 10:07:44 UTC (rev 
10010)
@@ -291,6 +291,12 @@
   struct GNUNET_TIME_Absolute last_quota_update;
 
   /**
+   * Context for our iteration to find HELLOs for this peer.  NULL
+   * after iteration has completed.
+   */
+  struct GNUNET_PEERINFO_IteratorContext *ic;
+
+  /**
    * Address of the other peer if WE initiated the connection
    * (and hence can be sure what it is), otherwise NULL.
    */
@@ -799,6 +805,11 @@
   else
     prev->next = session->next;
   /* clean up state */
+  if (session->ic != NULL)
+    {
+      GNUNET_PEERINFO_iterate_cancel (session->ic);
+      session->ic = NULL;
+    }
   if (session->transmit_handle != NULL)
     {
       GNUNET_CONNECTION_notify_transmit_ready_cancel 
(session->transmit_handle);
@@ -963,6 +974,7 @@
 
   if (peer == NULL)
     {
+      session->ic = NULL;
       /* last call, destroy session if we are still not
          connected */
       if (session->client != NULL)
@@ -1106,10 +1118,10 @@
       session->expecting_welcome = GNUNET_YES;
       session->pending_messages = pm;
       session->service_context = service_context;
-      GNUNET_PEERINFO_for_all (plugin->env->cfg,
-                               plugin->env->sched,
-                               target,
-                               0, timeout, &session_try_connect, session);
+      session->ic = GNUNET_PEERINFO_iterate (plugin->env->cfg,
+                                            plugin->env->sched,
+                                            target,
+                                            0, timeout, &session_try_connect, 
session);
       return;
     }
   GNUNET_assert (session != NULL);





reply via email to

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