FAQ
Hi,

On recent bleadperls, a call to socket() will leak a file descriptor if
the filehandle has already been opened. For example, the following script
causes the process to die with the message "Too many open files".

while (1) {
socket S, 1, 2, 0 or die $!;
}

The patch below fixes the leak. Not sure if it's the right fix or not,
but all tests still pass. If it is the right fix, then someone should
look at pp_sockpair() too, because at first glance it looks like it might
have the same problem.

Patch is against perl@9359.

Cheers,
-Ben

--
signer: can't create ~/.sig: Broken pipe

--- pp_sys.c.orig Mon Mar 26 13:13:06 2001
+++ pp_sys.c Mon Mar 26 14:20:13 2001
@@ -2205,6 +2205,9 @@
RETPUSHUNDEF;
}

+ if (IoIFP(io))
+ do_close(gv, FALSE);
+
TAINT_PROPER("socket");
fd = PerlSock_socket(domain, type, protocol);
if (fd < 0)

Search Discussions

  • Nick at Mar 26, 2001 at 6:33 pm

    Benjamin Sugars writes:
    Hi,

    On recent bleadperls, a call to socket() will leak a file descriptor if
    the filehandle has already been opened. For example, the following script
    causes the process to die with the message "Too many open files".

    while (1) {
    socket S, 1, 2, 0 or die $!;
    }

    The patch below fixes the leak. Not sure if it's the right fix or not,
    but all tests still pass. If it is the right fix, then someone should
    look at pp_sockpair() too, because at first glance it looks like it might
    have the same problem.

    Patch is against perl@9359.
    Patch looks good.

    should socket() become
    open($fg,"+<",":socket:Unix:Datagram", $addr);
    though ;-)

    (Yes I am getting fixated - I must calm down...)

    Cheers,
    -Ben

    --
    signer: can't create ~/.sig: Broken pipe

    --- pp_sys.c.orig Mon Mar 26 13:13:06 2001
    +++ pp_sys.c Mon Mar 26 14:20:13 2001
    @@ -2205,6 +2205,9 @@
    RETPUSHUNDEF;
    }

    + if (IoIFP(io))
    + do_close(gv, FALSE);
    +
    TAINT_PROPER("socket");
    fd = PerlSock_socket(domain, type, protocol);
    if (fd < 0)
    --
    Nick Ing-Simmons
  • Jarkko Hietaniemi at Mar 26, 2001 at 6:45 pm

    On Mon, Mar 26, 2001 at 06:29:07PM +0000, nick@ing-simmons.net wrote:
    Benjamin Sugars <bsugars@canoe.ca> writes:
    Hi,

    On recent bleadperls, a call to socket() will leak a file descriptor if
    the filehandle has already been opened. For example, the following script
    causes the process to die with the message "Too many open files".

    while (1) {
    socket S, 1, 2, 0 or die $!;
    }

    The patch below fixes the leak. Not sure if it's the right fix or not,
    but all tests still pass. If it is the right fix, then someone should
    look at pp_sockpair() too, because at first glance it looks like it might
    have the same problem.

    Patch is against perl@9359.
    Patch looks good.
    Patch applied, also to pp_sockpair().
    should socket() become
    open($fg,"+<",":socket:Unix:Datagram", $addr);
    though ;-)

    (Yes I am getting fixated - I must calm down...)
    :-)

    --
    $jhi++; # http://www.iki.fi/jhi/
    # There is this special biologist word we use for 'stable'.
    # It is 'dead'. -- Jack Cohen

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl5-porters @
categoriesperl
postedMar 26, '01 at 6:26p
activeMar 26, '01 at 6:45p
posts3
users3
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase