This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] aio_write


On Fri, Jun 14, 2002 at 10:18:16AM -0500, Amos Waterland wrote:
> > > 4) If on completion of the __aio_enqueue_request errno==EINTR set
> > > errno to 0 as this is in fact not an error and a residual of the
> > > fact that the TEMP_FAILURE_RETRY macro does not reset errno when
> > > pwrite is interrupted.  (Can this macro be changed? Should it?)
> > 
> > This looks broken.  errno is only defiend when the function fails and
> > since it does not fail in this case why are you changing it?
> 
> Andreas:
> 
> Hi, I just wanted to jump in and explain what Tom meant.  Here is a
> small test case that shows the behavior of concern for the pread(2)
> case (see below for code listing for test0025.c):
> 
>     % ./test0025
>     ./test0025: did not fail (ret: 0), but errno: 4
>     n a m e s e r v

    errno = 0;
    if ((r = aio_read( &cb )))
        error( 1, errno, "reading from file" );

    if (r == 0 && errno != 0)
        error( 0, 0, "did not fail (ret: %i), but errno: %i", r, errno );

errno is undefined in this case, it can be as well 25431 or any other value.
Only a few functions are guaranteed not to change errno if no error occured
(e.g. strtol family and a few others - for them errno = 0; strtol (); test errno
is allowed). For the majority of functions the standards specify
in which case they set errno (most often when functions return -1)
and in the rest of cases errno is undefined.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]