NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/45441: aio_write and aio_read connected to one pipe don't make progress



The following reply was made to PR kern/45441; it has been noted by GNATS.

From: Alexander Nasonov <alnsn%yandex.ru@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
        netbsd-bugs%netbsd.org@localhost
Subject: Re: kern/45441: aio_write and aio_read connected to one pipe don't
 make progress
Date: Wed, 12 Oct 2011 21:26:40 +0100

 alnsn%NetBSD.org@localhost wrote:
 > If you initialize two aiocb structs to connect to one pipe and call aio_read 
 > before aio_write, then aio_error() calls will always be returning 
 > EINPROGRESS.
 ...
 >Fix:
 > not known
 
 The best fix, I think, is return ESPIPE for non-seekable fildes rather
 than silently ignoring aio_offset. This would indirectly solve the issue
 described in this PR.
 
 Any objections if I commit the patch below? (I'll document ESPIPE as well)
 Alex
 
 
 Index: sys/kern/sys_aio.c
 ===================================================================
 RCS file: /cvsroot/src/sys/kern/sys_aio.c,v
 retrieving revision 1.37
 diff -p -u -u -r1.37 sys_aio.c
 --- sys/kern/sys_aio.c 17 Feb 2011 19:02:50 -0000      1.37
 +++ sys/kern/sys_aio.c 12 Oct 2011 20:15:34 -0000
 @@ -360,6 +360,7 @@ aio_process(struct aio_job *a_job)
        struct proc *p = curlwp->l_proc;
        struct aiocb *aiocbp = &a_job->aiocbp;
        struct file *fp;
 +      struct vnode *vp;
        int fd = aiocbp->aio_fildes;
        int error = 0;
  
 @@ -380,6 +381,13 @@ aio_process(struct aio_job *a_job)
                        goto done;
                }
  
 +              vp = (struct vnode *)fp->f_data;
 +              if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
 +                      fd_putfile(fd);
 +                      error = ESPIPE;
 +                      goto done;
 +              }
 +
                aiov.iov_base = (void *)(uintptr_t)aiocbp->aio_buf;
                aiov.iov_len = aiocbp->aio_nbytes;
                auio.uio_iov = &aiov;
 @@ -427,7 +435,6 @@ aio_process(struct aio_job *a_job)
                /*
                 * Perform a file Sync operation
                 */
 -              struct vnode *vp;
  
                if ((error = fd_getvnode(fd, &fp)) != 0)
                        goto done; 
 


Home | Main Index | Thread Index | Old Index