On Sun, Nov 04, 2007 at 09:47:59PM -0800, Christopher Layne <[EMAIL PROTECTED]> 
> > What is my program supposed to do? It can't distinguish them, and the
> > correct behavior in each of these conditions is totally different. Also,
> > in the program I'm thinking of, "libev chose to kill this file
> > descriptor" probably means a network link just went down. Ergh.
> Great point. It should back away and leave things alone - notifying
> to the caller (or whoever else is listening) "this is not acceptable to
> me - I suggest you fix it - because I won't" (aka unix way).

The "caller" in this case is the callback, however, because its the
continuation of whatever code requested to watch e.g. a bad fd in the first

Also, there is no way around an error status for the callback, one simply
*must* provide a sensible status to the callback when something goes
wrong, because that might be a long time after the watcher was added.

So instead of notifying both the caller of the start funktion and the
callback later, I don't see why notifying the callback in all cases would be
worse, in fact, it lets you have errors easier.

And yes, if you don't check for errors in your callback you are doomed.
Returning errors to the caller of the event only requires additional checking
code, and I have yet to see any code that actively checks for problems while
calling event_once or event_add.

But most callbacks do the sensible thing when called with EV_ERROR even when
they don't care, because in the case of I/O errors they will try to read or
write and see it doesn't work.

> > No, on error your library may have muddied the water already by screwing
> > with the file descriptors. libevent also makes errors clearer by simply
> > returning error from the failed function (I'm thinking of event_once()
> > vs ev_once() here.)

Yes, closing is not a good idea, reporting an error and removing the event
form the fd set is enough.

However, I still maintain concentrating error handlign in the one place
where its likely to be present already as opposed to reporting errors to
places where nobody cares (show me the code that catches errors after
making event_(once|del|add) calls) is the right thing to do.

Wether one reports more detailed errors is then another question. And
might be solved as easily as giving errno a defined value to use.

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

Reply via email to