gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r12174 - gnunet/src/transport
Date: Tue, 6 Jul 2010 15:15:20 +0200

Author: wachs
Date: 2010-07-06 15:15:20 +0200 (Tue, 06 Jul 2010)
New Revision: 12174

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-07-06 12:45:34 UTC 
(rev 12173)
+++ gnunet/src/transport/plugin_transport_http.c        2010-07-06 13:15:20 UTC 
(rev 12174)
@@ -237,6 +237,11 @@
   unsigned int send_active;
 
   /**
+   * connection disconnect forced (e.g. from transport)
+   */
+  unsigned int send_force_disconnect;
+
+  /**
    * is session connected to receive data?
    */
   unsigned int recv_connected;
@@ -247,6 +252,11 @@
   unsigned int recv_active;
 
   /**
+   * connection disconnect forced (e.g. from transport)
+   */
+  unsigned int recv_force_disconnect;
+
+  /**
    * entity managing sending data
    * outbound session: pointer to curl easy handle
    */
@@ -387,12 +397,12 @@
   struct Session * ps = *httpSessionCache;
   if (ps == NULL)
     return;
+
 #if DEBUG_CONNECTIONS
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection from peer `%s' was 
terminated\n",GNUNET_i2s(&ps->peercontext->identity));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: connection from peer 
`%s' was terminated\n", ps, GNUNET_i2s(&ps->peercontext->identity));
 #endif
   /* session set to inactive */
   //ps-> = GNUNET_NO;
-  //con->is_bad_request = GNUNET_NO;
 }
 
 static void mhd_write_mst_cb (void *cls,
@@ -468,6 +478,14 @@
   pc = ps->peercontext;
   msg = ps->pending_msgs_tail;
 
+  if (ps->send_force_disconnect)
+  {
+#if DEBUG_CONNECTIONS
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound forced to 
disconnect\n",ps);
+#endif
+    return -1;
+  }
+
   if (msg!=NULL)
   {
     if ((msg->size-msg->pos) <= max)
@@ -621,6 +639,15 @@
   /* Is it a PUT or a GET request */
   if (0 == strcmp (MHD_HTTP_METHOD_PUT, method))
   {
+    if (ps->recv_force_disconnect)
+    {
+#if DEBUG_CONNECTIONS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: inbound forced to 
disconnect\n",ps);
+#endif
+      ps->recv_connected = GNUNET_NO;
+      ps->recv_active = GNUNET_NO;
+      return MHD_NO;
+    }
     if ((*upload_data_size == 0) && (ps->recv_active==GNUNET_NO))
     {
       ps->recv_active = GNUNET_YES;
@@ -652,6 +679,15 @@
   }
   if ( 0 == strcmp (MHD_HTTP_METHOD_GET, method) )
   {
+    if (ps->send_force_disconnect)
+    {
+#if DEBUG_CONNECTIONS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Connection %X: outbound forced to 
disconnect\n",ps);
+#endif
+      ps->send_connected = GNUNET_NO;
+      ps->send_active = GNUNET_NO;
+      return MHD_NO;
+    }
     response = MHD_create_response_from_callback(-1,32 * 1024, 
&server_read_callback, ps, NULL);
     res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response);
     MHD_destroy_response (response);
@@ -1539,7 +1575,8 @@
     }
     if (ps->direction==INBOUND)
     {
-
+      ps->recv_force_disconnect = GNUNET_YES;
+      ps->send_force_disconnect = GNUNET_YES;
     }
     while (ps->pending_msgs_head!=NULL)
     {




reply via email to

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