Re: Hang in fd_ebadf function

2008-05-30 Thread Marc-André Cournoyer

Perfect, it works now w/ checking the EV_ERROR bit, thx Marc!

On 29-May-08, at 12:09 AM, Marc Lehmann wrote:

On Wed, May 28, 2008 at 01:41:58PM -0400, Marc-André Cournoyer <[EMAIL PROTECTED] 
> wrote:

I'm playing w/ libev to make (yet another) Ruby web server and I got
some random issues. Sometimes the server hangs and when I attach to
the process w/ gdb to get the backtrace here's what I get:


fd_ebadf is called when you give libev an invalid file descriptor -  
this
is likely an applciation bug (fd_ebadf is very slow, but select and  
poll

do not report *which* file descriptor is wrong, so libev has to check
every single one).

you likely see it repeatedly because you ignore the EV_ERROR bit in  
your
watcher and just add the file descriptor again (ignoring that bit is  
fine

if your code is perfect :).

Both of these are application bugs - you have to make sure that the  
file
descriptors you give to libev are valid, open, poll'able file  
descriptors,

and you should check for EV_ERROR conditions and not start the watcher
again.

--
   The choice of a   Deliantra, the free code 
+content MORPG

 -==- _GNU_  http://www.deliantra.net
 ==-- _   generation
 ---==---(_)__  __   __  Marc Lehmann
 --==---/ / _ \/ // /\ \/ /  [EMAIL PROTECTED]
 -=/_/_//_/\_,_/ /_/\_\



___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev


Re: Hang in fd_ebadf function

2008-05-30 Thread Marc Lehmann
On Fri, May 30, 2008 at 10:12:45AM -0400, Marc-André Cournoyer <[EMAIL 
PROTECTED]> wrote:
> Perfect, it works now w/ checking the EV_ERROR bit, thx Marc!

No, it doesn't - if you get EV_ERROR for this case then your code is buggy
- you *must not* have active watchers with illegal file descriptors.

The fact that libev tries to work around your bug doesn't mean it works
(in fact, you are relying on luck because this bug isn't 100% detectable
in libev).

-- 
The choice of a   Deliantra, the free code+content MORPG
  -==- _GNU_  http://www.deliantra.net
  ==-- _   generation
  ---==---(_)__  __   __  Marc Lehmann
  --==---/ / _ \/ // /\ \/ /  [EMAIL PROTECTED]
  -=/_/_//_/\_,_/ /_/\_\

___
libev mailing list
libev@lists.schmorp.de
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev