patch-2.3.18 linux/fs/pipe.c

Next file: linux/fs/proc/root.c
Previous file: linux/fs/binfmt_misc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.17/linux/fs/pipe.c linux/fs/pipe.c
@@ -59,37 +59,32 @@
 	if (count == 0)
 		goto out_nolock;
 
-	/* Grab, or try to grab, the pipe's semaphore with data present.  */
-	if (filp->f_flags & O_NONBLOCK) {
+	/* Get the pipe semaphore */
+	ret = -ERESTARTSYS;
+	if (down_interruptible(PIPE_SEM(*inode)))
+		goto out_nolock;
+
+	if (PIPE_EMPTY(*inode)) {
+		ret = 0;
+		if (!PIPE_WRITERS(*inode))
+			goto out;
+
 		ret = -EAGAIN;
-		if (down_trylock(PIPE_SEM(*inode)))
-			goto out_nolock;
-		ret = PIPE_WRITERS(*inode) ? -EAGAIN : 0;
-		if (PIPE_EMPTY(*inode))
+		if (filp->f_flags & O_NONBLOCK)
 			goto out;
-	} else {
-		ret = -ERESTARTSYS;
-		if (down_interruptible(PIPE_SEM(*inode)))
-			goto out_nolock;
 
-		if (PIPE_EMPTY(*inode)) {
+		for (;;) {
+			pipe_wait(inode);
+			ret = -ERESTARTSYS;
+			if (signal_pending(current))
+				goto out_nolock;
+			if (down_interruptible(PIPE_SEM(*inode)))
+				goto out_nolock;
 			ret = 0;
+			if (!PIPE_EMPTY(*inode))
+				break;
 			if (!PIPE_WRITERS(*inode))
 				goto out;
-
-			for (;;) {
-				pipe_wait(inode);
-				ret = -ERESTARTSYS;
-				if (signal_pending(current))
-					goto out_nolock;
-				if (down_interruptible(PIPE_SEM(*inode)))
-					goto out_nolock;
-				ret = 0;
-				if (!PIPE_EMPTY(*inode))
-					break;
-				if (!PIPE_WRITERS(*inode))
-					goto out;
-			}
 		}
 	}
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)