gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r28211 - in libmicrohttpd: . src/examples src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r28211 - in libmicrohttpd: . src/examples src/microhttpd
Date: Sat, 20 Jul 2013 12:36:27 +0200

Author: grothoff
Date: 2013-07-20 12:36:26 +0200 (Sat, 20 Jul 2013)
New Revision: 28211

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/examples/benchmark_https.c
   libmicrohttpd/src/microhttpd/connection.c
   libmicrohttpd/src/microhttpd/connection.h
   libmicrohttpd/src/microhttpd/connection_https.c
   libmicrohttpd/src/microhttpd/daemon.c
Log:
-fix combining HTTPS and EPOLL

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2013-07-20 10:13:45 UTC (rev 28210)
+++ libmicrohttpd/ChangeLog     2013-07-20 10:36:26 UTC (rev 28211)
@@ -1,3 +1,6 @@
+Sat Jul 20 12:35:40 CEST 2013
+       Fixing combination of MHD_USE_SSL and MHD_USE_EPOLL_LINUX_ONLY. -CG
+
 Fri Jul 19 09:57:27 CEST 2013
        Fix issue where connections were not cleaned up when
        'MHD_run_from_select' was used.  Adding experimental

Modified: libmicrohttpd/src/examples/benchmark_https.c
===================================================================
--- libmicrohttpd/src/examples/benchmark_https.c        2013-07-20 10:13:45 UTC 
(rev 28210)
+++ libmicrohttpd/src/examples/benchmark_https.c        2013-07-20 10:36:26 UTC 
(rev 28211)
@@ -178,7 +178,7 @@
                                  "close");
   d = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_SUPPRESS_DATE_NO_CLOCK 
| MHD_USE_SSL
 #if EPOLL_SUPPORT
-                       | MHD_USE_EPOLL_LINUX_ONLY | MHD_USE_EPOLL_TURBO
+                       | MHD_USE_EPOLL_LINUX_ONLY  | MHD_USE_EPOLL_TURBO
 #endif
                        ,
                         atoi (argv[1]),

Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c   2013-07-20 10:13:45 UTC (rev 
28210)
+++ libmicrohttpd/src/microhttpd/connection.c   2013-07-20 10:36:26 UTC (rev 
28211)
@@ -2017,6 +2017,46 @@
 
 
 /**
+ * Clean up the state of the given connection and move it into the
+ * clean up queue for final disposal.
+ *
+ * @param connection handle for the connection to clean up
+ */
+static void
+cleanup_connection (struct MHD_Connection *connection)
+{
+  struct MHD_Daemon *daemon = connection->daemon;
+
+  if (NULL != connection->response)
+    {
+      MHD_destroy_response (connection->response);
+      connection->response = NULL;
+    }
+  if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+       (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) )         
+    MHD_PANIC ("Failed to acquire cleanup mutex\n");           
+  if (connection->connection_timeout == daemon->connection_timeout)
+    XDLL_remove (daemon->normal_timeout_head,
+                daemon->normal_timeout_tail,
+                connection);
+  else
+    XDLL_remove (daemon->manual_timeout_head,
+                daemon->manual_timeout_tail,
+                connection);
+  DLL_remove (daemon->connections_head,
+             daemon->connections_tail,
+             connection);
+  DLL_insert (daemon->cleanup_head,
+             daemon->cleanup_tail,
+             connection);
+  if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
+       (0 != pthread_mutex_unlock(&daemon->cleanup_connection_mutex)) )        
        
+    MHD_PANIC ("Failed to release cleanup mutex\n");       
+  connection->in_idle = MHD_NO;
+}
+
+
+/**
  * This function was created to handle per-connection processing that
  * has to happen even if the socket cannot be read or written to. 
  *
@@ -2378,7 +2418,8 @@
             }
           continue;
         case MHD_CONNECTION_CLOSED:
-         goto cleanup_connection;
+         cleanup_connection (connection);
+         return MHD_NO;
         default:
           EXTRA_CHECK (0);
           break;
@@ -2431,8 +2472,28 @@
       /* This connection is finished, nothing left to do */
       break;
     }
+#if EPOLL_SUPPORT
+  return MHD_connection_epoll_update_ (connection);
+#else
+  return MHD_YES;
+#endif
+}
 
+
 #if EPOLL_SUPPORT
+/**
+ * Perform epoll processing, possibly moving the connection back into
+ * the epoll set if needed.
+ *
+ * @param connection connection to process
+ * @return MHD_YES if we should continue to process the
+ *         connection (not dead yet), MHD_NO if it died
+ */ 
+int
+MHD_connection_epoll_update_ (struct MHD_Connection *connection)
+{
+  struct MHD_Daemon *daemon = connection->daemon;
+
   if ( (0 != (daemon->options & MHD_USE_EPOLL_LINUX_ONLY)) &&  
        (0 == (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET)) &&
        ( (0 == (connection->epoll_state & MHD_EPOLL_STATE_WRITE_READY)) ||
@@ -2457,43 +2518,15 @@
                      STRERROR (errno));
 #endif
          connection->state = MHD_CONNECTION_CLOSED;
-         goto cleanup_connection;
+         cleanup_connection (connection);
+         return MHD_NO;
        }
       connection->epoll_state |= MHD_EPOLL_STATE_IN_EPOLL_SET;
     }
-#endif
   connection->in_idle = MHD_NO;
   return MHD_YES;
-
- cleanup_connection:
-  if (NULL != connection->response)
-    {
-      MHD_destroy_response (connection->response);
-      connection->response = NULL;
-    }
-  if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-       (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) )         
-    MHD_PANIC ("Failed to acquire cleanup mutex\n");           
-  if (connection->connection_timeout == daemon->connection_timeout)
-    XDLL_remove (daemon->normal_timeout_head,
-                daemon->normal_timeout_tail,
-                connection);
-  else
-    XDLL_remove (daemon->manual_timeout_head,
-                daemon->manual_timeout_tail,
-                connection);
-  DLL_remove (daemon->connections_head,
-             daemon->connections_tail,
-             connection);
-  DLL_insert (daemon->cleanup_head,
-             daemon->cleanup_tail,
-             connection);
-  if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
-       (0 != pthread_mutex_unlock(&daemon->cleanup_connection_mutex)) )        
        
-    MHD_PANIC ("Failed to release cleanup mutex\n");       
-  connection->in_idle = MHD_NO;
-  return MHD_NO;
 }
+#endif
 
 
 /**

Modified: libmicrohttpd/src/microhttpd/connection.h
===================================================================
--- libmicrohttpd/src/microhttpd/connection.h   2013-07-20 10:13:45 UTC (rev 
28210)
+++ libmicrohttpd/src/microhttpd/connection.h   2013-07-20 10:36:26 UTC (rev 
28211)
@@ -93,4 +93,18 @@
                      enum MHD_RequestTerminationCode termination_code);
 
 
+#if EPOLL_SUPPORT
+/**
+ * Perform epoll processing, possibly moving the connection back into
+ * the epoll set if needed.
+ *
+ * @param connection connection to process
+ * @return MHD_YES if we should continue to process the
+ *         connection (not dead yet), MHD_NO if it died
+ */ 
+int
+MHD_connection_epoll_update_ (struct MHD_Connection *connection);
 #endif
+
+
+#endif

Modified: libmicrohttpd/src/microhttpd/connection_https.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection_https.c     2013-07-20 10:13:45 UTC 
(rev 28210)
+++ libmicrohttpd/src/microhttpd/connection_https.c     2013-07-20 10:36:26 UTC 
(rev 28211)
@@ -131,6 +131,7 @@
 static int
 MHD_tls_connection_handle_idle (struct MHD_Connection *connection)
 {
+  struct MHD_Daemon *daemon = connection->daemon;
   unsigned int timeout;
 
 #if DEBUG_STATES
@@ -145,7 +146,7 @@
     {
       /* on newly created connections we might reach here before any reply has 
been received */
     case MHD_TLS_CONNECTION_INIT:
-      return MHD_YES;
+      break;
       /* close connection if necessary */
     case MHD_CONNECTION_CLOSED:
       gnutls_bye (connection->tls_session, GNUTLS_SHUT_RDWR);
@@ -156,7 +157,7 @@
        return MHD_YES;
       return MHD_connection_handle_idle (connection);
     }
-  return MHD_YES;
+  return MHD_connection_epoll_update_ (connection);
 }
 
 

Modified: libmicrohttpd/src/microhttpd/daemon.c
===================================================================
--- libmicrohttpd/src/microhttpd/daemon.c       2013-07-20 10:13:45 UTC (rev 
28210)
+++ libmicrohttpd/src/microhttpd/daemon.c       2013-07-20 10:36:26 UTC (rev 
28211)
@@ -400,7 +400,9 @@
   if ( (GNUTLS_E_AGAIN == res) ||
        (GNUTLS_E_INTERRUPTED == res) )
     {
+      fprintf (stderr, "RAGAIN!\n");
       errno = EINTR;
+      connection->epoll_state &= ~MHD_EPOLL_STATE_READ_READY;
       return -1;
     }
   if (res < 0)
@@ -438,7 +440,9 @@
   if ( (GNUTLS_E_AGAIN == res) ||
        (GNUTLS_E_INTERRUPTED == res) )
     {
+      fprintf (stderr, "WAGAIN!\n");
       errno = EINTR;
+      connection->epoll_state &= ~MHD_EPOLL_STATE_WRITE_READY;
       return -1;
     }
   return res;




reply via email to

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