mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 19:52:00 +01:00
Problem: cannot use pre-allocated FDs. Fixes #777
Solution: add new [set|get]sockopt ZMQ_PRE_ALLOCATED_FD to allow users to let ZMQ use a pre-allocated file descriptor instead of allocating a new one. Update [set|get]sockopt documentation and test accordingly. The main use case for this feature is a socket-activated systemd service. For more information about this feature see: http://0pointer.de/blog/projects/socket-activation.html
This commit is contained in:
@@ -77,7 +77,8 @@ zmq::options_t::options_t () :
|
||||
connected (false),
|
||||
heartbeat_ttl (0),
|
||||
heartbeat_interval (0),
|
||||
heartbeat_timeout (-1)
|
||||
heartbeat_timeout (-1),
|
||||
pre_allocated_fd (-1)
|
||||
{
|
||||
#if defined ZMQ_HAVE_VMCI
|
||||
vmci_buffer_size = 0;
|
||||
@@ -621,6 +622,13 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
||||
break;
|
||||
# endif
|
||||
|
||||
case ZMQ_PRE_ALLOCATED_FD:
|
||||
if (is_int && value >= -1) {
|
||||
pre_allocated_fd = value;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
#if defined (ZMQ_ACT_MILITANT)
|
||||
// There are valid scenarios for probing with unknown socket option
|
||||
@@ -1031,6 +1039,13 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
}
|
||||
break;
|
||||
|
||||
case ZMQ_PRE_ALLOCATED_FD:
|
||||
if (is_int) {
|
||||
*value = pre_allocated_fd;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
#if defined (ZMQ_ACT_MILITANT)
|
||||
malformed = false;
|
||||
|
||||
Reference in New Issue
Block a user