On Monday, September 19, 2011 10:29:24 AM Frank Meier wrote: > hi > > > Well, that would seem to solve the problem, but would introduce a > > race. With 'close', another thread might open a file or socket and > > MHD's might then select/poll/accept on that unrelated socket. > > I'm not sure if I understand the race problem correctly. is it if we > call close on listening socket, and a thread is entering accept() on > this socket the descriptor is invalid and accept would return EBADF?
EBADF would be returned, except if another thread creates a fresh listen socket between the 'close' and the 'accept' (which may happen to get the same number as the socket that was just closed). Hence it is a race (with MHD, we should not make assumptions about what the rest of the program might be doing...). Happy hacking, Christian