Mail Archives: cygwin/2011/08/04/02:01:03
X-Recipient: | archive-cygwin AT delorie DOT com
|
X-SWARE-Spam-Status: | No, hits=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_FD,T_TO_NO_BRKTS_FREEMAIL
|
X-Spam-Check-By: | sourceware.org
|
Message-ID: | <4E3A3582.5020904@gmail.com>
|
Date: | Thu, 04 Aug 2011 08:00:34 +0200
|
From: | Marco atzeri <marco DOT atzeri AT gmail DOT com>
|
User-Agent: | Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0
|
MIME-Version: | 1.0
|
To: | cygwin AT cygwin DOT com
|
Subject: | Re: odd socketpair() failure
|
References: | <4E39D525 DOT 5070804 AT redhat DOT com>
|
In-Reply-To: | <4E39D525.5070804@redhat.com>
|
X-IsSubscribed: | yes
|
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm
|
List-Id: | <cygwin.cygwin.com>
|
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com>
|
List-Archive: | <http://sourceware.org/ml/cygwin/>
|
List-Post: | <mailto:cygwin AT cygwin DOT com>
|
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
|
Sender: | cygwin-owner AT cygwin DOT com
|
Mail-Followup-To: | cygwin AT cygwin DOT com
|
Delivered-To: | mailing list cygwin AT cygwin DOT com
|
On 8/4/2011 1:09 AM, Eric Blake wrote:
> A while ago, I tested pipe() for EMFILE failures [1]. Well, I repeated
> those tests for socketpair() [2], and cygwin is once again the odd man out.
>
> [1] http://cygwin.com/ml/cygwin/2011-06/msg00328.html
> [2] http://austingroupbugs.net/view.php?id=483
>
> $ cat foo.c
> #define _POSIX_C_SOURCE 200811L
> #define __EXTENSIONS__ 1
> #include <sys/types.h>
> #include <sys/time.h>
> #include <unistd.h>
> #include <string.h>
> #include <stdio.h>
> #include <errno.h>
> #include <fcntl.h>
> #include <sys/socket.h>
> int
> main (int argc, char **argv)
> {
> int last;
> int fd[2] = {-2,-3};
> int err;
> /* Get to an EMFILE condition. */
> while (1) {
> int fd = open("/dev/null", O_RDONLY);
> if (fd < 0) {
> printf ("after fd %d, open failed with errno %d %s\n",
> last, errno, strerror(errno));
> break;
> }
> last = fd;
> }
> /* Probe behavior */
> err = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
> if (err)
> printf ("try 1, socketpair returned %d errno %d %s, fds %d %d\n",
> err, errno, strerror(errno), fd[0], fd[1]);
> else
> printf ("try 1, socketpair succeeded, fds %d %d\n", fd[0], fd[1]);
> if (close(last))
> return 1;
> err = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
> if (err)
> printf ("try 2, socketpair returned %d errno %d %s, fds %d %d\n",
> err, errno, strerror(errno), fd[0], fd[1]);
> else
> printf ("try 2, socketpair succeeded, fds %d %d\n", fd[0], fd[1]);
> if (close(0))
> return 1;
> err = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
> if (err)
> printf ("try 3, socketpair returned %d errno %d %s, fds %d %d\n",
> err, errno, strerror(errno), fd[0], fd[1]);
> else
> printf ("try 3, socketpair succeeded, fds %d %d\n", fd[0], fd[1]);
> return 0;
> }
> $ ./foo
> after fd 3199, open failed with errno 24 Too many open files
> try 1, socketpair returned -1 errno 24 Too many open files, fds -2 -3
> try 2, socketpair returned -1 errno 24 Too many open files, fds -2 -3
> try 3, socketpair returned -1 errno 24 Too many open files, fds -2 -3
>
> But on Linux, try 3 succeeds. Something in cygwin is not quite right on
> try 3 - the program explicitly freed two fd slots (0 and 3199), so it
> should have plenty of room to create the socketpair without hitting EMFILE.
>
> Disclaimer: I tested on 1.7.9 rather than the latest snapshot; maybe the
> pipe() fix in the meantime also fixed socketpair()?
>
same result on latest CVS
Marco
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -