RE: [squid-users] bug 1991/1939 and kqueue

2011-05-12 Thread Ming Fu
My SSL is OpenSSL 0.9.8n.

Looking at the epoll code, the logic seems that if read is pending, the squid 
needs something to trigger a read on the socket that is pending. But as there 
might not be incoming data to push kqueue/epoll into a read event for a long 
time. The code instead asking for a write event. The write event is almost sure 
an immediate trigger as the chance of write buffer full is low. However, once 
the write triggers and the read pending is on, a read callback is called 
instead of write.

I will put in the epoll logic to kqueue. Will report its effect.

Ming 

-Original Message-
From: Amos Jeffries [mailto:squ...@treenet.co.nz] 
Sent: Wednesday, May 11, 2011 10:22 PM
To: squid-users@squid-cache.org
Subject: Re: [squid-users] bug 1991/1939 and kqueue

On 12/05/11 07:21, Ming Fu wrote:
 Hi,

 I was looking into the fix for 1939 on Linux epoll. I am wondering if 
 similarly apply the same modification to kqueue will do the same magic for 
 1991.  On Linux epoll that fix seems to enable write monitoring whenever 
 read_pending is present. I don't understand the logic, but if it works for 
 Linux, would it work for FreeBSD as well?

 Regards,
 Ming


Thank you for taking an interest in fixing bugs!

Which version(s) or Squid and OpenSSL are you replicating it with?

The logic goes that if there is read pending, then SSL might have 
something buffered needing to write. I suspect it may be a higher level 
problem with SSL omitting a write somewhere or a flags we omit to 
disable OpenSSl buffering. But if Henrik failed to find it, could be hard.

Nothing beats experiments for finding things out. Try it and see.

Amos
-- 
Please be using
   Current Stable Squid 2.7.STABLE9 or 3.1.12
   Beta testers wanted for 3.2.0.7 and 3.1.12.1


RE: [squid-users] bug 1991/1939 and kqueue

2011-05-12 Thread Ming Fu
Hi,

Here is a patch for bug 1991 on FreeBSD compiled with kqueue. It fixed the 
websites that previously won't load through sslbump on FreeBSD with kqueue 
enabled.


--- /home/fming/work/squid-3.1.12.1-20110506/src/comm_kqueue.cc 2011-05-06 
00:27:39.0 -0400
+++ comm_kqueue.cc  2011-05-12 10:03:49.0 -0400
@@ -198,7 +198,11 @@
 assert(F-flags.open);
 
 if (type  COMM_SELECT_READ) {
+if (F-flags.read_pending)
+kq_update_events(fd, EVFILT_WRITE, handler);
+ 
 kq_update_events(fd, EVFILT_READ, handler);
+
 F-read_handler = handler;
 F-read_data = client_data;
 }
@@ -291,31 +295,24 @@
 continue;/* XXX! */
 }
 
-switch (ke[i].filter) {
-
-case EVFILT_READ:
-
+if (ke[i].filter == EVFILT_READ || F-flags.read_pending) {
 if ((hdl = F-read_handler) != NULL) {
 F-read_handler = NULL;
 F-flags.read_pending = 0;
 hdl(fd, F-read_data);
 }
+}
 
-break;
-
-case EVFILT_WRITE:
-
+if (ke[i].filter == EVFILT_WRITE) {
 if ((hdl = F-write_handler) != NULL) {
 F-write_handler = NULL;
 hdl(fd, F-write_data);
 }
+}
 
-break;
-
-default:
-/* Bad! -- adrian */
+if (ke[i].filter != EVFILT_WRITE  ke[i].filter != EVFILT_READ) {
+/* Bad! -- adrian */
 debugs(5, 1, comm_select: kevent returned   ke[i].filter  
!);
-break;
 }
 }





[squid-users] bug 1991/1939 and kqueue

2011-05-11 Thread Ming Fu
Hi,

I was looking into the fix for 1939 on Linux epoll. I am wondering if similarly 
apply the same modification to kqueue will do the same magic for 1991.  On 
Linux epoll that fix seems to enable write monitoring whenever read_pending is 
present. I don't understand the logic, but if it works for Linux, would it work 
for FreeBSD as well?

Regards,
Ming



Re: [squid-users] bug 1991/1939 and kqueue

2011-05-11 Thread Amos Jeffries

On 12/05/11 07:21, Ming Fu wrote:

Hi,

I was looking into the fix for 1939 on Linux epoll. I am wondering if similarly 
apply the same modification to kqueue will do the same magic for 1991.  On 
Linux epoll that fix seems to enable write monitoring whenever read_pending is 
present. I don't understand the logic, but if it works for Linux, would it work 
for FreeBSD as well?

Regards,
Ming



Thank you for taking an interest in fixing bugs!

Which version(s) or Squid and OpenSSL are you replicating it with?

The logic goes that if there is read pending, then SSL might have 
something buffered needing to write. I suspect it may be a higher level 
problem with SSL omitting a write somewhere or a flags we omit to 
disable OpenSSl buffering. But if Henrik failed to find it, could be hard.


Nothing beats experiments for finding things out. Try it and see.

Amos
--
Please be using
  Current Stable Squid 2.7.STABLE9 or 3.1.12
  Beta testers wanted for 3.2.0.7 and 3.1.12.1