gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r11434 - gnunet/src/transport
Date: Wed, 19 May 2010 14:15:42 +0200

Author: wachs
Date: 2010-05-19 14:15:42 +0200 (Wed, 19 May 2010)
New Revision: 11434

Modified:
   gnunet/src/transport/plugin_transport_http.c
Log:


Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c        2010-05-19 08:58:01 UTC 
(rev 11433)
+++ gnunet/src/transport/plugin_transport_http.c        2010-05-19 12:15:42 UTC 
(rev 11434)
@@ -188,6 +188,7 @@
 
 static unsigned int locked;
 
+
 /**
  * Finds a http session in our linked list using peer identity as a key
  * @param peer peeridentity
@@ -217,7 +218,7 @@
  * @param peer peeridentity
  * @return http session corresponding to peer identity
  */
-static struct Session * find_session_by_ip( struct sockaddr_in * addr )
+static struct Session * find_session_by_ip( char * ip )
 {
   /*
   struct Session * cur;
@@ -311,6 +312,7 @@
   struct sockaddr_in  *addrin;
   struct sockaddr_in6 *addrin6;
   char * address = NULL;
+  struct Session * cs;
 
   if ( GNUNET_YES == locked )
   {
@@ -350,11 +352,34 @@
     return MHD_NO;
   }
 
-  /* create current session object */
-  current_session = GNUNET_malloc ( sizeof( struct Session) );
-  current_session->ip = address;
-  current_session->next = NULL;
+  /* get existing session for this address */
+  cs = NULL;
+  if (plugin->session_count > 0)
+  {
+    cs = plugin->sessions;
+    while ( NULL != cs)
+    {
+      if ( 0 == strcmp(address,cs->ip))
+      {
+        /* existing session for this address found */
+        break;
+      }
+      cs = cs->next;
+    }
+  }
 
+  if (cs != NULL )
+  {
+    /* session to this addresse already existing */
+    current_session = cs;
+  }
+  else
+  {
+    /* create new session object */
+    current_session = GNUNET_malloc ( sizeof( struct Session) );
+    current_session->ip = address;
+    current_session->next = NULL;
+  }
   /* Every connection is accepted, nothing more to do here */
   return MHD_YES;
 }




reply via email to

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