]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug #1939: --enable-epoll causes SSL to occationally hang
authorhno <>
Sun, 10 Jun 2007 17:02:23 +0000 (17:02 +0000)
committerhno <>
Sun, 10 Jun 2007 17:02:23 +0000 (17:02 +0000)
This patch makes comm_epoll support the "read_pending" flag, indicating
data has been buffered at the I/O layer and is immediately available for
processing without having to wait for an I/O event.

kqueue still needs fixing.

src/comm_epoll.cc
src/comm_kqueue.cc
src/comm_poll.cc
src/comm_select.cc

index eb12a432463009ce945398b065327a96438fcab8..4a78056e4c593e6fe5d59120ab506992dbe3d329 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_epoll.cc,v 1.15 2007/04/28 22:26:37 hno Exp $
+ * $Id: comm_epoll.cc,v 1.16 2007/06/10 11:02:23 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -152,8 +152,12 @@ commSetSelect(int fd, unsigned int type, PF * handler,
     // If read is an interest
 
     if (type & COMM_SELECT_READ) {
-        if (handler)
+        if (handler) {
+           // Hack to keep the events flowing if there is data immediately ready
+           if (F->flags.read_pending)
+               ev.events |= EPOLLOUT;
             ev.events |= EPOLLIN;
+       }
 
         F->read_handler = handler;
 
@@ -281,17 +285,17 @@ comm_select(int msec)
 
         // TODO: add EPOLLPRI??
 
-        if (cevents->events & (EPOLLIN|EPOLLHUP|EPOLLERR)) {
+        if (cevents->events & (EPOLLIN|EPOLLHUP|EPOLLERR) || F->flags.read_pending) {
             if ((hdl = F->read_handler) != NULL) {
                 debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): Calling read handler on FD " << fd);
                 PROF_start(comm_write_handler);
+                F->flags.read_pending = 0;
                 F->read_handler = NULL;
                 hdl(fd, F->read_data);
                 PROF_stop(comm_write_handler);
                 statCounter.select_fds++;
             } else {
                 debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): no read handler for FD " << fd);
-                fd_table[fd].flags.read_pending = 1;
                 // remove interest since no handler exist for this event.
                 commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0);
             }
@@ -306,7 +310,6 @@ comm_select(int msec)
                 PROF_stop(comm_read_handler);
                 statCounter.select_fds++;
             } else {
-                fd_table[fd].flags.write_pending = 1;
                 debugs(5, DEBUG_EPOLL ? 0 : 8, "comm_select(): no write handler for FD " << fd);
                 // remove interest since no handler exist for this event.
                 commSetSelect(fd, COMM_SELECT_WRITE, NULL, NULL, 0);
index d4f36d66da054160f10286539c245afb2e12184d..bfdb8acbf7ac7f329563ca2155cb21f7c04f2284 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_kqueue.cc,v 1.15 2007/04/28 22:26:37 hno Exp $
+ * $Id: comm_kqueue.cc,v 1.16 2007/06/10 11:02:23 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -45,6 +45,7 @@
  *
  * - delay pools
  * - deferred reads
+ * - flags.read_pending
  *
  * So, its not entirely useful in a production setup since if a read
  * is meant to be deferred it isn't (we're not even throwing the event
@@ -280,6 +281,7 @@ comm_select(int msec)
 
             if ((hdl = F->read_handler) != NULL) {
                 F->read_handler = NULL;
+               F->flags.read_pending = 0;
                 hdl(fd, F->read_data);
             }
 
index cc4a58a01bd4171d6e21ae7fefd2f14ca84547b0..421bc15f90b41c70f346c01e07bd513017068d44 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_poll.cc,v 1.21 2007/04/30 16:56:09 wessels Exp $
+ * $Id: comm_poll.cc,v 1.22 2007/06/10 11:02:23 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -524,6 +524,7 @@ comm_select(int msec)
                 else {
                     PROF_start(comm_read_handler);
                     F->read_handler = NULL;
+                   F->flags.read_pending = 0;
                     hdl(fd, F->read_data);
                     PROF_stop(comm_read_handler);
                     statCounter.select_fds++;
@@ -607,6 +608,7 @@ comm_select(int msec)
 
             if ((hdl = F->read_handler)) {
                 F->read_handler = NULL;
+               F->flags.read_pending = 0;
                 hdl(fd, F->read_data);
                 statCounter.select_fds++;
 
index 8eaa17ada0426405b516b2bc96829ac15da5d0bb..4017cd29121e249b2cf33c44c0dace455c9dd251 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_select.cc,v 1.79 2007/04/30 16:56:09 wessels Exp $
+ * $Id: comm_select.cc,v 1.80 2007/06/10 11:02:23 hno Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -568,6 +568,7 @@ comm_select(int msec)
 
                 else {
                     F->read_handler = NULL;
+                   F->flags.read_pending = 0;
                     commUpdateReadBits(fd, NULL);
                     hdl(fd, F->read_data);
                     statCounter.select_fds++;
@@ -663,6 +664,7 @@ comm_select(int msec)
 
             if ((hdl = F->read_handler)) {
                 F->read_handler = NULL;
+               F->flags.read_pending = 0;
                 commUpdateReadBits(fd, NULL);
                 hdl(fd, F->read_data);
                 statCounter.select_fds++;