You are right - switching to non-blocking fixes this problem. Thanks for
your help. It worked with 0.9.48 - but had some flaws (now I know why).
Please close this issue - this was my fault.
Ah, the cause is that you create the listen socket (which is OK), but
you don't set it to be non-blocking. The result looks like this:
pid 5676] <... epoll_wait resumed> {{EPOLLIN, {u32=39549584,
u64=39549584}}}, 128, -1) = 1
[pid 5676] accept4(4, {sa_family=AF_INET, sin_port=htons(35076),
sin_addr=inet_addr("127.0.0.1")}, [16], SOCK_CLOEXEC|SOCK_NONBLOCK) = 8
[pid 5676] mmap(NULL, 134217728, PROT_NONE,
MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f74bc1ab000
[pid 5676] munmap(0x7f74bc1ab000, 65359872) = 0
[pid 5676] munmap(0x7f74c4000000, 1748992) = 0
[pid 5676] mprotect(0x7f74c0000000, 135168, PROT_READ|PROT_WRITE) = 0
[pid 5676] fcntl(8, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
[pid 5676] epoll_ctl(7, EPOLL_CTL_ADD, 8, {EPOLLIN|EPOLLOUT|EPOLLET,
{u32=3221227712, u64=140139414161600}}) = 0
[pid 5676] accept4(4, <= hangs here!
I'm not sure if we used to make the listen socket non-blocking
explicitly before, but _removing_ calls to make stuff non-blocking was
part of Evgeny's "optimization" work. Maybe he went a bit overboard, I
certainly agree that _if_ there was a change like that it probably was
unintentional and should have been avoided.
Evgeny: could you check, and re-add the logic to make the listen socket
explicitly non-blocking also IF it was passed in from the outside to
MHD, and then make a fast bugfix release? Thanks!
On 04/12/2016 04:10 PM, Markus Doppelbauer wrote:
Hello,
Thanks a lot.
For me, 0.9.49 does not work - it never enters the
"AccessHandlerCallback()" handler. I have attached
a small testcase.
Steps to reproduce:
g++ -o testmhd test.cpp -I/tmp/libmicrohttpd-0.9.49/src/include/
-L/tmp/libmicrohttpd-0.9.49/src/microhttpd/.libs/ -lmicrohttpd
LD_LIBRARY_PATH=/tmp/libmicrohttpd-0.9.49/src/microhttpd/.libs/
./testmhd
wget -O /dev/null 127.0.0.1:8080
Best wishes,
Markus
Am Samstag, den 09.04.2016, 16:39 +0200 schrieb Christian Grothoff:
Dear all,
I'm happy to announce the release of libmicrohttpd 0.9.49.
GNU libmicrohttpd is a small C library that is supposed to make it
easy
to run an HTTP server as part of another application. GNU
libmicrohttpd
is fully HTTP 1.1 compliant and supports IPv6. Finally, GNU
libmicrohttpd is fast, portable and has a simple API and (without TLS
support and other optional features) a small binary size (~32k).
Major changes include:
* use US-ASCII only (instead of user locale settings) when performing
caseless string comparison.
* Send response properly if sendfile() failed with EINVAL
* do not crash if pthread_create() fails
* various minor bugfixes (see ChangeLog)
* use non-blocking sockets on all platforms
* various improvements to the documentation
* reducing number of system calls
You can download GNU libmicrohttpd from
* ftp://ftp.gnu.org/gnu/libmicrohttpd/ and all GNU FTP mirrors.
* Our Subversion repository at https://gnunet.org/svn/libmicrohttpd/
Please report bugs to our bugtracker at https://gnunet.org/bugs/.
The documentation (including a reference manual and tutorial) can be
found at http://www.gnu.org/software/libmicrohttpd/.
Happy hacking!
Christian & Evgeny