Discussion:
[zeromq-dev] setting the CLOEXEC flag for eventfd and epoll instances?
zmqdev
2016-12-02 13:19:43 UTC
Permalink
while investigating a problem involving fork() and zeromq, I found some
file descriptor leaks.


1. The function

zmq::epoll_t::epoll_t (const zmq::ctx_t &ctx_)

in src/epoll.cpp creates an epoll instance with

epoll_fd = epoll_create(1);

SUGGESTION: replace with

epoll_fd = epoll_create1(EPOLL_CLOEXEC);


2. The function

zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)

in src/signaler.cpp creates an eventfd object with

#if defined ZMQ_HAVE_EVENTFD
fd_t fd = eventfd (0, 0);

SUGGESTION: replace with

#if defined ZMQ_HAVE_EVENTFD
fd_t fd = eventfd (0, EFD_CLOEXEC);
Luca Boccassi
2016-12-02 14:00:12 UTC
Permalink
Makes sense, we already set the CLOEXEC flag in the sockets.

Given it's causing you issues, would you be able to test it and send a
PR to fix it? Thanks!
Post by zmqdev
while investigating a problem involving fork() and zeromq, I found some
file descriptor leaks.
1. The function
zmq::epoll_t::epoll_t (const zmq::ctx_t &ctx_)
in src/epoll.cpp creates an epoll instance with
epoll_fd = epoll_create(1);
SUGGESTION: replace with
epoll_fd = epoll_create1(EPOLL_CLOEXEC);
2. The function
zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
in src/signaler.cpp creates an eventfd object with
#if defined ZMQ_HAVE_EVENTFD
fd_t fd = eventfd (0, 0);
SUGGESTION: replace with
#if defined ZMQ_HAVE_EVENTFD
fd_t fd = eventfd (0, EFD_CLOEXEC);
_______________________________________________
zeromq-dev mailing list
http://lists.zeromq.org/mailman/listinfo/zeromq-dev
zmqdev
2016-12-02 14:06:15 UTC
Permalink
Post by Luca Boccassi
Makes sense, we already set the CLOEXEC flag in the sockets.
Given it's causing you issues, would you be able to test it and send a
PR to fix it? Thanks!
it's going to take a few days until I get to it.

Loading...