benluteijn / cherokee

Automatically exported from code.google.com/p/cherokee
0 stars 1 forks source link

kqueue not working properly on FreeBSD 7.1-PRERELEASE #223

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'v compiled Cherokee Version: 0.10.1 on my fbsd box. When using kqueue
polling I'm getting timeouts with non existing url's( no 404 page).
Switching to "poll" solves the problem (getting 404 page).

[root@p4 ~]# cherokee -i
Compilation
 Version: 0.10.1
 Compiled on: Nov 14 2008 13:15:51
 Arguments to configure:  '--enable-readdir_r' '--disable-static'
'--localstatedir=/var' '--with-wwwroot=/usr/www/cherokee'
'--sysconfdir=/usr/local/etc'

Installation
 Deps dir: /usr/local/share/cherokee/deps
 Data dir: /usr/local/share/cherokee
 Icons dir: /usr/local/share/cherokee/icons
 Themes dir: /usr/local/share/cherokee/themes
 Plug-in dir: /usr/local/lib/cherokee

Plug-ins
 Built-in:

Support
 IPv6: yes
 OpenSSL: yes
 GnuTLS: no
 Pthreads: yes
 Tracing: no
 sendfile(): yes
 syslog(): yes
 Polling methods: select poll kqueue

------------------

[root@p4 ~]# uname -a
FreeBSD p4 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #2: Thu Nov 13 22:17:07
CET 2008     root@p4:/usr/obj/usr/src/sys/P4  i386

Original issue reported on code.google.com by sec....@gmail.com on 14 Nov 2008 at 1:16

GoogleCodeExporter commented 9 years ago

Original comment by alobbs on 14 Nov 2008 at 2:27

GoogleCodeExporter commented 9 years ago

Original comment by ste...@konink.de on 14 Nov 2008 at 2:31

GoogleCodeExporter commented 9 years ago
has there been any movement with this bug? i know using kqueue with rtorrent on 
freebsd makes a MASSIVE 
difference so i'd really like to be able to use it here.

Original comment by Wonslung@gmail.com on 12 Oct 2009 at 10:55

GoogleCodeExporter commented 9 years ago
Ok, I'm having the same problem. If I use "Automático" in the admin interface
(Avanzado->conexiones) cherokee woks properly, but if I select "Kqueue", the 
server 
doesn't respond fast. In the log error we can see "[30/12/2009 09:36:57.464] 
(error) 
fdpoll-kqueue.c:177 - kevent returned: 'Interrupted system call'" (there are 
more 
than one lines with this error).

There are the data of my server and cherokee:

server# cherokee -i
Compilation
 Version: 0.99.38
 Compiled on: Dec 28 2009 10:47:48
 Arguments to configure:  '--with-wwwroot=/usr/local/www/cherokee' '--localstatedir=/
var' '--disable-static' '--with-mysql=no' '--with-ldap=no' '--with-geoip=yes' 
'--
with-ffmpeg=no' '--prefix=/usr/local' '--mandir=/usr/local/man' '--infodir=/usr/
local/info/' '--build=amd64-portbld-freebsd7.1' 'build_alias=amd64-portbld-
freebsd7.1' 'CC=cc' 'CFLAGS=-O2 -fno-strict-aliasing -pipe' 
'LDFLAGS=-L/usr/local/
lib -pthread -rpath=/usr/local/lib' 'CPPFLAGS=-I/usr/local/include '

Installation
 Deps dir: /usr/local/share/cherokee/deps
 Data dir: /usr/local/share/cherokee
 Icons dir: /usr/local/share/cherokee/icons
 Themes dir: /usr/local/share/cherokee/themes
 Plug-in dir: /usr/local/lib/cherokee

Plug-ins
 Built-in:

Support
 IPv6: yes
 Pthreads: yes
 Tracing: no
 sendfile(): yes
 syslog(): yes
 Polling methods: select poll kqueue
----

server# uname -a
FreeBSD server.u-u.com 7.1-RELEASE FreeBSD 7.1-RELEASE #1: Sun Feb  8 16:35:00 
CET 
2009     root@stock.ovh.net:/usr/obj/usr/src/sys/OVH  amd64
-----

I hope this can be useful.

Thanks ;)

Original comment by gimmeash...@indahouserulez.com on 30 Dec 2009 at 1:02

GoogleCodeExporter commented 9 years ago
has any progress been made on this?  I use FreeBSD and OpenSolaris server. I 
would 
REALLY like to have kqueue working on FreeBSD.  I'm stuck using poll on both of 
these 
platforms....

Original comment by Wonslung@gmail.com on 15 Mar 2010 at 5:55

GoogleCodeExporter commented 9 years ago
(gdb) thread apply all bt

Thread 11 (Thread 800f08040 (LWP 101179)):
#0  0x00000008008c523c in __error () from /lib/libthr.so.3
#1  0x00000008008c4f2c in __error () from /lib/libthr.so.3
#2  0x00000008008c022b in pthread_mutex_getyieldloops_np () from 
/lib/libthr.so.3
#3  0x00000008007a7342 in cherokee_thread_step_MULTI_THREAD (thd=0x800f32580, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1651
#4  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#5  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
Error accessing memory address 0x7ffffebf7000: Bad address.

Thread 10 (Thread 800f08200 (LWP 101174)):
#0  0x00000008008c523c in __error () from /lib/libthr.so.3
#1  0x00000008008c4f2c in __error () from /lib/libthr.so.3
#2  0x00000008008c022b in pthread_mutex_getyieldloops_np () from 
/lib/libthr.so.3
#3  0x00000008007a7342 in cherokee_thread_step_MULTI_THREAD (thd=0x800f32700, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1651
#4  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#5  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
Error accessing memory address 0x7ffffedf8000: Bad address.

Thread 9 (Thread 800f083c0 (LWP 101170)):
#0  0x00000008008c523c in __error () from /lib/libthr.so.3
#1  0x00000008008c4f2c in __error () from /lib/libthr.so.3
#2  0x00000008008c022b in pthread_mutex_getyieldloops_np () from 
/lib/libthr.so.3
#3  0x00000008007a7342 in cherokee_thread_step_MULTI_THREAD (thd=0x800f32880, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1651
#4  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#5  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
Error accessing memory address 0x7ffffeff9000: Bad address.

Thread 8 (Thread 800f08580 (LWP 101077)):
#0  0x0000000800d3a9dc in kevent () from /lib/libc.so.7
#1  0x0000000800668018 in _watch (fdp=0x800f28a50, timeout_msecs=Variable 
"timeout_msecs" is not available.
) at fdpoll-kqueue.c:168
#2  0x00000008007a735c in cherokee_thread_step_MULTI_THREAD (thd=0x800f32a00, 
dont_block=15778888)
    at thread.c:1655
#3  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#4  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#5  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffff1fa000: Bad address.

Thread 7 (Thread 800f08740 (LWP 101073)):
#0  0x00000008008c523c in __error () from /lib/libthr.so.3
#1  0x00000008008c4f2c in __error () from /lib/libthr.so.3
#2  0x00000008008c022b in pthread_mutex_getyieldloops_np () from 
/lib/libthr.so.3
#3  0x00000008007a7342 in cherokee_thread_step_MULTI_THREAD (thd=0x800f32b80, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1651
#4  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#5  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffff3fb000: Bad address.

Thread 6 (Thread 800f08900 (LWP 101029)):
#0  0x00000008008c523c in __error () from /lib/libthr.so.3
#1  0x00000008008c4f2c in __error () from /lib/libthr.so.3
#2  0x00000008008c022b in pthread_mutex_getyieldloops_np () from 
/lib/libthr.so.3
#3  0x00000008007a7342 in cherokee_thread_step_MULTI_THREAD (thd=0x800f32d00, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1651
#4  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#5  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffff5fc000: Bad address.

Thread 5 (Thread 800f08ac0 (LWP 100942)):
#0  0x00000008008c523c in __error () from /lib/libthr.so.3
#1  0x00000008008c4f2c in __error () from /lib/libthr.so.3
#2  0x00000008008c022b in pthread_mutex_getyieldloops_np () from 
/lib/libthr.so.3
#3  0x00000008007a7342 in cherokee_thread_step_MULTI_THREAD (thd=0x800f32e80, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1651
#4  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#5  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffff7fd000: Bad address.

Thread 4 (Thread 800f08c80 (LWP 100465)):
#0  0x00000008008c523c in __error () from /lib/libthr.so.3
#1  0x00000008008c4f2c in __error () from /lib/libthr.so.3
#2  0x00000008008c022b in pthread_mutex_getyieldloops_np () from 
/lib/libthr.so.3
#3  0x00000008007a7342 in cherokee_thread_step_MULTI_THREAD (thd=0x800f9d180, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1651
#4  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#5  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#6  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffff9fe000: Bad address.

Thread 3 (Thread 800f08e40 (LWP 100208)):
#0  0x0000000800d3a9dc in kevent () from /lib/libc.so.7
#1  0x0000000800668018 in _watch (fdp=0x800f270f0, timeout_msecs=Variable 
"timeout_msecs" is not available.
) at fdpoll-kqueue.c:168
#2  0x00000008007a71e6 in cherokee_thread_step_MULTI_THREAD (thd=0x800f2d300, 
dont_block=Variable "dont_block" is not available.
) at thread.c:1683
#3  0x00000008007a798a in thread_routine (data=Variable "data" is not available.
) at thread.c:97
#4  0x00000008008bb4b1 in pthread_getprio () from /lib/libthr.so.3
#5  0x0000000000000000 in ?? ()
Error accessing memory address 0x7fffffbff000: Bad address.

Thread 2 (Thread 800f021c0 (LWP 100772)):
#0  0x0000000800d3a9dc in kevent () from /lib/libc.so.7
#1  0x0000000800668018 in _watch (fdp=0x800f27080, timeout_msecs=Variable 
"timeout_msecs" is not available.
) at fdpoll-kqueue.c:168
#2  0x00000008007a735c in cherokee_thread_step_MULTI_THREAD (thd=0x800f2d180, 
dont_block=15778888)
    at thread.c:1655
#3  0x00000008007a2500 in cherokee_server_step (srv=0x800f0c300) at 
server.c:1130
#4  0x0000000000401797 in main (argc=1, argv=Variable "argv" is not available.
) at main_worker.c:367
#0  0x00000008008c523c in __error () from /lib/libthr.so.3

Original comment by ste...@konink.de on 3 May 2010 at 2:51

GoogleCodeExporter commented 9 years ago
(gdb) up
#1  0x0000000800668018 in _watch (fdp=0x800f270f0, timeout_msecs=Variable 
"timeout_msecs" is not available.
) at fdpoll-kqueue.c:168
168             n_events = kevent(fdp->kqueue,
(gdb) list
163             timeout.tv_nsec = ( timeout_msecs % 1000L ) * 1000000L;
164
165             /* Get the events of the file descriptors with
166              * activity
167              */
168             n_events = kevent(fdp->kqueue,
169                               fdp->changelist,
170                               fdp->nchanges,
171                               fdp->changelist,
172                               FDPOLL(fdp)->nfiles,

Original comment by ste...@konink.de on 3 May 2010 at 2:56

GoogleCodeExporter commented 9 years ago
Oh the horror... master will not like!!

Index: cherokee/fdpoll-kqueue.c
===================================================================
--- cherokee/fdpoll-kqueue.c    (revision 5026)
+++ cherokee/fdpoll-kqueue.c    (working copy)
@@ -243,13 +243,13 @@
        if ((rw == FDPOLL_MODE_WRITE) &&
            (fdp->fdinterest[fd] == FDPOLL_MODE_READ))
        {
-               return _add_change (fdp, fd, FDPOLL_MODE_READ, EV_DELETE);
+               _add_change (fdp, fd, FDPOLL_MODE_READ, EV_DELETE);
        }

        if ((rw == FDPOLL_MODE_READ) &&
            (fdp->fdinterest[fd] == FDPOLL_MODE_WRITE))
        {
-               return _add_change (fdp, fd, FDPOLL_MODE_WRITE, EV_DELETE);
+               _add_change (fdp, fd, FDPOLL_MODE_WRITE, EV_DELETE);
        }

        return _add_change (fdp, fd, rw, EV_ADD);

Original comment by ste...@konink.de on 4 May 2010 at 2:48

GoogleCodeExporter commented 9 years ago
The patch makes pretty good sense to me.
It seems you caught the bug.. and, this was a nasty one!

Good stuff. Excellent work Stefan!! :-)

Original comment by alobbs on 4 May 2010 at 5:14

GoogleCodeExporter commented 9 years ago
It's applied upstream now:

   http://svn.cherokee-project.com/changeset/5027

Cherokee 0.99.49 will ship the patch. Most likely, it'll be released today.

Original comment by alobbs on 4 May 2010 at 5:21

GoogleCodeExporter commented 9 years ago
Users reported they are happy, I'm closing this one :)

Original comment by ste...@konink.de on 13 May 2010 at 3:50