gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r33793 - gnunet/src/transport
Date: Mon, 23 Jun 2014 20:05:57 +0200

Author: grothoff
Date: 2014-06-23 20:05:57 +0200 (Mon, 23 Jun 2014)
New Revision: 33793

Modified:
   gnunet/src/transport/plugin_transport_tcp.c
Log:
-simplify logic, just use clearly working direct method to extract session from 
server's client handle

Modified: gnunet/src/transport/plugin_transport_tcp.c
===================================================================
--- gnunet/src/transport/plugin_transport_tcp.c 2014-06-23 17:49:20 UTC (rev 
33792)
+++ gnunet/src/transport/plugin_transport_tcp.c 2014-06-23 18:05:57 UTC (rev 
33793)
@@ -235,11 +235,6 @@
   struct GNUNET_PeerIdentity target;
 
   /**
-   * API requirement.
-   */
-  struct SessionHeader header;
-
-  /**
    * Pointer to the global plugin struct.
    */
   struct Plugin *plugin;
@@ -497,9 +492,10 @@
                          socklen_t addrlen)
 {
   struct Plugin *plugin = cls;
-  LOG(GNUNET_ERROR_TYPE_DEBUG,
-      "Accepting new incoming TCP connection from `%s'\n",
-      GNUNET_a2s (addr, addrlen));
+
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Accepting new incoming TCP connection from `%s'\n",
+       GNUNET_a2s (addr, addrlen));
   if (plugin->cur_connections >= plugin->max_connections)
     return GNUNET_NO;
   plugin->cur_connections++;
@@ -743,40 +739,6 @@
 
 
 /**
- * Closure for #session_lookup_by_client_it().
- */
-struct SessionClientCtx
-{
-  /**
-   * Client we are looking for.
-   */
-  const struct GNUNET_SERVER_Client *client;
-
-  /**
-   * Session that was found.
-   */
-  struct Session *ret;
-};
-
-
-static int
-session_lookup_by_client_it (void *cls,
-                             const struct GNUNET_PeerIdentity *key,
-                             void *value)
-{
-  struct SessionClientCtx *sc_ctx = cls;
-  struct Session *s = value;
-
-  if (s->client == sc_ctx->client)
-  {
-    sc_ctx->ret = s;
-    return GNUNET_NO;
-  }
-  return GNUNET_YES;
-}
-
-
-/**
  * Find the session handle for the given client.
  * Currently uses both the hashmap and the client
  * context, as the client context is new and the
@@ -790,17 +752,7 @@
 lookup_session_by_client (struct Plugin *plugin,
                           struct GNUNET_SERVER_Client *client)
 {
-  struct Session *ret;
-  struct SessionClientCtx sc_ctx;
-
-  ret = GNUNET_SERVER_client_get_user_context (client, struct Session);
-  sc_ctx.client = client;
-  sc_ctx.ret = NULL;
-  GNUNET_CONTAINER_multipeermap_iterate (plugin->sessionmap,
-      &session_lookup_by_client_it, &sc_ctx);
-  /* check both methods yield the same result */
-  GNUNET_break(ret == sc_ctx.ret);
-  return sc_ctx.ret;
+  return GNUNET_SERVER_client_get_user_context (client, struct Session);
 }
 
 




reply via email to

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