2004-10-21 00:46:46

by Andrea Arcangeli

[permalink] [raw]
Subject: accept should return ENFILE if it runs out of inodes

EMFILE is only for the per-process fds limit, all other cases where
sock_alloc fails already returns -ENFILE too, must have been a typo.

patch for 2.4:

--- 2.4.23aa3/net/socket.c.~1~ 2004-07-04 02:09:33.000000000 +0200
+++ 2.4.23aa3/net/socket.c 2004-10-21 02:36:45.704715960 +0200
@@ -1068,7 +1068,7 @@ asmlinkage long sys_accept(int fd, struc
if (!sock)
goto out;

- err = -EMFILE;
+ err = -ENFILE;
if (!(newsock = sock_alloc()))
goto out_put;


patch for 2.6:

Index: linux-2.5/net/socket.c
===================================================================
RCS file: /home/andrea/crypto/cvs/linux-2.5/net/socket.c,v
retrieving revision 1.90
diff -u -p -r1.90 socket.c
--- linux-2.5/net/socket.c 8 Aug 2004 02:05:19 -0000 1.90
+++ linux-2.5/net/socket.c 21 Oct 2004 00:37:12 -0000
@@ -1354,7 +1354,7 @@ asmlinkage long sys_accept(int fd, struc
if (!sock)
goto out;

- err = -EMFILE;
+ err = -ENFILE;
if (!(newsock = sock_alloc()))
goto out_put;


2004-10-26 01:25:47

by David Miller

[permalink] [raw]
Subject: Re: accept should return ENFILE if it runs out of inodes

On Thu, 21 Oct 2004 02:41:27 +0200
Andrea Arcangeli <[email protected]> wrote:

> EMFILE is only for the per-process fds limit, all other cases where
> sock_alloc fails already returns -ENFILE too, must have been a typo.

Fix applied to both 2.4.x and 2.6.x, thanks Andrea.