zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fr0stbyte <...@git.apache.org>
Subject [GitHub] zookeeper issue #410: [ZOOKEEPER-2338] - set SOCK_CLOEXEC on socket if defin...
Date Thu, 16 Nov 2017 01:20:59 GMT
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.


---

Mime
View raw message