]> Zhao Yanbai Git Server - minix.git/commitdiff
. minor fix in select() logic on pipes
authorBen Gras <ben@minix3.org>
Fri, 24 Mar 2006 20:53:10 +0000 (20:53 +0000)
committerBen Gras <ben@minix3.org>
Fri, 24 Mar 2006 20:53:10 +0000 (20:53 +0000)
. fix in pipe_check when 'notouch' is on - we touched something!

servers/fs/pipe.c

index 98d5eb2e760a97b2cbb5f86a7fe06faf849431fa..8adaa607c3447911d8ff1c12ac0de1b0889be05d 100644 (file)
@@ -158,7 +158,8 @@ int notouch;                        /* check only */
                                /* Do a partial write. Need to wakeup reader
                                 * since we'll suspend ourself in read_write()
                                 */
-                               release(rip, READ, susp_count);
+                               if (!notouch)
+                                       release(rip, READ, susp_count);
                                return(1);
                        }
                }
@@ -386,24 +387,26 @@ PUBLIC int select_request_pipe(struct filp *f, int *ops, int block)
 {
        int orig_ops, r = 0, err, canwrite;
        orig_ops = *ops;
-       if ((*ops & SEL_RD)) {
+       if ((*ops & (SEL_RD|SEL_ERR))) {
                if ((err = pipe_check(f->filp_ino, READING, 0,
-                       1, f->filp_pos, &canwrite, 1)) != SUSPEND)
+                       1, f->filp_pos, &canwrite, 1)) != SUSPEND && err > 0)
                        r |= SEL_RD;
-               if (err < 0 && err != SUSPEND && (*ops & SEL_ERR))
+               if (err < 0 && err != SUSPEND)
                        r |= SEL_ERR;
        }
-       if ((*ops & SEL_WR)) {
+       if ((*ops & (SEL_WR|SEL_ERR))) {
                if ((err = pipe_check(f->filp_ino, WRITING, 0,
-                       1, f->filp_pos, &canwrite, 1)) != SUSPEND)
+                       1, f->filp_pos, &canwrite, 1)) != SUSPEND &&
+                       err > 0 && canwrite > 0)
                        r |= SEL_WR;
-               if (err < 0 && err != SUSPEND && (*ops & SEL_ERR))
+               if (err < 0 && err != SUSPEND)
                        r |= SEL_ERR;
        }
 
-       *ops = r;
+       /* Some options we collected might not be requested. */
+       *ops = r & orig_ops;
 
-       if (!r && block) {
+       if (!*ops && block) {
                f->filp_pipe_select_ops |= orig_ops;
        }