zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (ZOOKEEPER-2338) c bindings should create socket's with SOCK_CLOEXEC to avoid fd leaks on fork/exec
Date Thu, 16 Nov 2017 01:21:00 GMT

    [ https://issues.apache.org/jira/browse/ZOOKEEPER-2338?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16254592#comment-16254592

ASF GitHub Bot commented on ZOOKEEPER-2338:

Github user fr0stbyte commented on the issue:

    @phunt I'd have no problem making in backward compatible, but I am not sure how. Can you
offer some guidance here ?
    @anmolnar In the description of MESOS-4065 you can see 2 processes that share the same
open file descriptor. In Linux ( Unix in general ) upon forking, the child inherits all the
open files of the parent, unless the O_CLOEXEC option has been set on the file descriptor.
My change uses the SOCK_CLOEXEC which is an atomic set of that flag. The alternative is to
open it and then use `fcntl` to set the flag, but that leaves space for a race as a process
could fork before.
    Since the child process does not need / makes use of the open file descriptor it is proper
to close it before exec'ing. I wouldn't say it's a functional bug, but rather good housekeeping
( afaict ).
    @afine I think in order to reproduce it, you need a process that uses the C client, then
that forks and execs something else. To verify, look at the open file descriptors for the
2 processes and verify that the open socket to zookeeper is not available in the child.

> c bindings should create socket's with SOCK_CLOEXEC to avoid fd leaks on fork/exec
> ----------------------------------------------------------------------------------
>                 Key: ZOOKEEPER-2338
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2338
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: c client
>            Reporter: James DeFelice
> I've observed socket FD leaks in Apache Mesos when using ZK to coordinate master leadership:

This message was sent by Atlassian JIRA

View raw message