[
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:
https://github.com/apache/zookeeper/pull/410
@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: https://issues.apache.org/jira/browse/MESOS-4065
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)