eio.c bug - use of errno without testing result

Marc Lehmann schmorp at schmorp.de
Fri Oct 29 16:05:56 CEST 2010


On Sat, Oct 30, 2010 at 12:48:34AM +1100, Micheil Smith <micheil at brandedcode.com> wrote:
> Actually, I read the wrong documentation. So, in node, we currently have a pretty 
> much global After callback, which does:
> 
> 	static int After(eio_req *req) {
> 	  // ...
> 	  ev_unref(EV_DEFAULT_UC);
> 	  // ...
> 	  if (req->errorno != 0) {
> 	     // throw error
> 	  } else {
> 	     // call JS function as callback.
> 	  }
> 	  // ...
> 	}

Yes, this is broken, errno values are no indicator for success or failure.
libeio calls work just like any other syscall (or actually like the
respective underlying syscall, usually forced into a more portable form).

> Are you suggesting we should actually be doing something like:
> 
> 	  if (req->result != EXPECTED_RESULT) {
> 
> Where EXPECTED_RESULT is the result int that we would expect given req->type?

That wouldn't work, most syscalls return -1 on errno, and a LOT of
expected results (think of read(2)), others have other conventions, some
never set errno etc.

You would have to consult the documentation of the call to decide what
constitues success or failure.

> On 30/10/2010, at 12:40 AM, Micheil Smith wrote:

And please learn to write proper e-mails - quoting a whole e-mail thread
needlessly wastes everybody's time scanning through it. You should make it
easy for your readers, not needlessly hard.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list