- refactorind reverting last fix
authorMatthias Wachs <wachs@net.in.tum.de>
Tue, 29 May 2012 09:05:12 +0000 (09:05 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Tue, 29 May 2012 09:05:12 +0000 (09:05 +0000)
src/transport/plugin_transport_http.c
src/transport/plugin_transport_http.h
src/transport/plugin_transport_http_server.c

index 2bc82d8f04997ad4912e99d9426d685ebdbd9683..d55cdb76b108f026672409c6e2ea5372379cf573 100644 (file)
@@ -601,6 +601,8 @@ delete_session (struct Session *s)
     s->msg_tk = NULL;
   }
   GNUNET_free (s->addr);
+  GNUNET_free_non_null (s->server_recv);
+  GNUNET_free_non_null (s->server_send);
   GNUNET_free (s);
 }
 
index 8ec47fe4c4f08d28fc34e0bd7384590c25fa87f8..c3c9367ad7b81ed48e831259e37330760131db15 100644 (file)
@@ -305,6 +305,24 @@ struct IPv6HttpAddress
 };
 GNUNET_NETWORK_STRUCT_END
 
+
+struct ServerConnection
+{
+  /* _RECV or _SEND */
+  int direction;
+
+  /* Should this connection get disconnected? GNUNET_YES/NO  */
+  int disconnect;
+
+  /* The session this server connection belongs to */
+  struct Session *session;
+
+  /* The MHD connection */
+  struct MHD_Connection *mhd_conn;
+};
+
+
+
 /**
  * Session handle for connections.
  */
@@ -417,12 +435,12 @@ struct Session
   /**
    * Client send handle
    */
-  void *server_recv;
+  struct ServerConnection *server_recv;
 
   /**
    * Client send handle
    */
-  void *server_send;
+  struct ServerConnection *server_send;
 };
 
 /**
index d8383b0a9d82ed1293916b387b6577f76308089c..58c8fd2158727cd99ee701105b6879632a7e53c8 100644 (file)
 
 static struct Plugin * p;
 
-struct ServerConnection
-{
-  /* _RECV or _SEND */
-  int direction;
-
-  /* should this connection get disconnected? GNUNET_YES/NO  */
-  int disconnect;
-
-  struct Session *session;
-  struct MHD_Connection *mhd_conn;
-};
-
 /**
  * Function that queries MHD's select sets and
  * starts the task waiting for them.
@@ -540,14 +528,9 @@ create:
   s = create_session (plugin, &target, a, a_len);
   GNUNET_assert (NULL != s);
   s->ats_address_network_type = ats.value;
-
   s->inbound = GNUNET_YES;
   s->next_receive = GNUNET_TIME_UNIT_ZERO_ABS;
   s->tag = tag;
-  if (0 == strcmp (MHD_HTTP_METHOD_PUT, method))
-    s->server_recv = s;
-  if (0 == strcmp (MHD_HTTP_METHOD_GET, method))
-    s->server_send = s;
   GNUNET_CONTAINER_DLL_insert (plugin->server_semi_head,
                                plugin->server_semi_tail, s);
   goto found;
@@ -853,24 +836,15 @@ server_disconnect_cb (void *cls, struct MHD_Connection *connection,
 int
 server_disconnect (struct Session *s)
 {
-  struct Plugin *plugin = s->plugin;
-  struct Session *t = plugin->head;
-
-  while (t != NULL)
+  if (s->server_send != NULL)
   {
-    if (t->inbound == GNUNET_YES)
-    {
-      if (t->server_send != NULL)
-      {
-        ((struct ServerConnection *) t->server_send)->disconnect = GNUNET_YES;
-      }
-      if (t->server_send != NULL)
-      {
-        ((struct ServerConnection *) t->server_send)->disconnect = GNUNET_YES;
-      }
-    }
-    t = t->next;
+    ((struct ServerConnection *) s->server_send)->disconnect = GNUNET_YES;
+  }
+  if (s->server_recv != NULL)
+  {
+    ((struct ServerConnection *) s->server_recv)->disconnect = GNUNET_YES;
   }
+
   return GNUNET_OK;
 }