Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jan 2006 12:36:02 +0300
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        arch@FreeBSD.org
Cc:        alfred@FreeBSD.org
Subject:   fix return code for pipe(2) syscall
Message-ID:  <20060127093602.GO83922@cell.sick.ru>
Resent-Message-ID: <20060127125124.GT83922@FreeBSD.org>

next in thread | raw e-mail | index | archive | help

--O8/n5iBOhiUtMkxf
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline

  Colleagues,

  sometimes pipe(2) can return ENFILE, which has nothing to do
with number of open files. It happens when we run out of kva.

However, pipe(2) can also return correct ENFILE, when falloc()
fails.

  The only way to distinguish between latter error and the
former one is looking into the 'dmesg' output, right after
failure. If your dmesg is later overwritten with some other
logging, then you will loose this information, and you won't
be able to tell why pipe(2) syscall yesterday returned ENFILE -
did it hit descriptor limit or kva?

Recently I've got some communication with people, who have
problems with mpd port. They have experienced ENFILE from
pipe(2). They have spent some time tuning descriptor limits
and I spent some time trying to help them, until we looked
into dmesg, and then into source, to discover alternative
meaning of ENFILES.

Any objection for the attached change? It should make return
ENOMEM in case of kva outage?

Yes, according to SUSv3 the only errors from pipe(2) are ENFILE
and EMFILE. I think that blindly following standard in this
case will lead to confusion (see above). And we already return
EFAULT from pipe(2), which is not described in standard.

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE

--O8/n5iBOhiUtMkxf
Content-Type: text/plain; charset=koi8-r
Content-Disposition: attachment; filename="sys_pipe.c.diff"

Index: sys_pipe.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/sys_pipe.c,v
retrieving revision 1.185
diff -u -r1.185 sys_pipe.c
--- sys_pipe.c	16 Dec 2005 18:32:39 -0000	1.185
+++ sys_pipe.c	27 Jan 2006 09:15:56 -0000
@@ -357,10 +357,11 @@
 	    NULL);
 
 	/* Only the forward direction pipe is backed by default */
-	if (pipe_create(rpipe, 1) || pipe_create(wpipe, 0)) {
+	if ((error = pipe_create(rpipe, 1)) != 0 ||
+	    (error = pipe_create(wpipe, 0)) != 0) {
 		pipeclose(rpipe);
 		pipeclose(wpipe);
-		return (ENFILE);
+		return (error);
 	}
 
 	rpipe->pipe_state |= PIPE_DIRECTOK;

--O8/n5iBOhiUtMkxf
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
--O8/n5iBOhiUtMkxf--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060127093602.GO83922>