Problem: ZMQ_USEFD does not follow conventions

Solution: rename socket option (and variables and files) from usefd
to use_fd.
This commit is contained in:
Luca Boccassi 2016-02-09 09:36:14 +00:00
parent 15846f2fe4
commit edc4ee03e8
13 changed files with 35 additions and 35 deletions

4
.gitignore vendored
View File

@ -125,8 +125,8 @@ test_timers
test_radio_dish test_radio_dish
test_udp test_udp
test_large_msg test_large_msg
test_usefd_ipc test_use_fd_ipc
test_usefd_tcp test_use_fd_tcp
tests/test*.log tests/test*.log
tests/test*.trs tests/test*.trs
src/platform.hpp* src/platform.hpp*

View File

@ -626,8 +626,8 @@ test_apps += \
tests/test_shutdown_stress \ tests/test_shutdown_stress \
tests/test_pair_ipc \ tests/test_pair_ipc \
tests/test_reqrep_ipc \ tests/test_reqrep_ipc \
tests/test_usefd_ipc \ tests/test_use_fd_ipc \
tests/test_usefd_tcp \ tests/test_use_fd_tcp \
tests/test_timeo \ tests/test_timeo \
tests/test_filter_ipc tests/test_filter_ipc
@ -650,15 +650,15 @@ tests_test_timeo_LDADD = src/libzmq.la
tests_test_filter_ipc_SOURCES = tests/test_filter_ipc.cpp tests_test_filter_ipc_SOURCES = tests/test_filter_ipc.cpp
tests_test_filter_ipc_LDADD = src/libzmq.la tests_test_filter_ipc_LDADD = src/libzmq.la
tests_test_usefd_ipc_SOURCES = \ tests_test_use_fd_ipc_SOURCES = \
tests/test_usefd_ipc.cpp \ tests/test_use_fd_ipc.cpp \
tests/testutil.hpp tests/testutil.hpp
tests_test_usefd_ipc_LDADD = src/libzmq.la tests_test_use_fd_ipc_LDADD = src/libzmq.la
tests_test_usefd_tcp_SOURCES = \ tests_test_use_fd_tcp_SOURCES = \
tests/test_usefd_tcp.cpp \ tests/test_use_fd_tcp.cpp \
tests/testutil.hpp tests/testutil.hpp
tests_test_usefd_tcp_LDADD = src/libzmq.la tests_test_use_fd_tcp_LDADD = src/libzmq.la
if HAVE_FORK if HAVE_FORK
test_apps += tests/test_fork test_apps += tests/test_fork

View File

@ -464,9 +464,9 @@ Default value:: null string
Applicable socket types:: all, when using TCP or IPC transports Applicable socket types:: all, when using TCP or IPC transports
ZMQ_USEFD: Retrieve the pre-allocated socket file descriptor ZMQ_USE_FD: Retrieve the pre-allocated socket file descriptor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_USEFD' option shall retrieve the pre-allocated file The 'ZMQ_USE_FD' option shall retrieve the pre-allocated file
descriptor that has been assigned to a ZMQ socket, if any. -1 shall be descriptor that has been assigned to a ZMQ socket, if any. -1 shall be
returned if a pre-allocated file descriptor was not set for the socket. returned if a pre-allocated file descriptor was not set for the socket.

View File

@ -492,7 +492,7 @@ Default value:: not set
Applicable socket types:: all, when using TCP transport Applicable socket types:: all, when using TCP transport
ZMQ_USEFD: Set the pre-allocated socket file descriptor ZMQ_USE_FD: Set the pre-allocated socket file descriptor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When set to a positive integer value before zmq_bind is called on the socket, When set to a positive integer value before zmq_bind is called on the socket,
the socket shall use the corresponding file descriptor for connections over the socket shall use the corresponding file descriptor for connections over

View File

@ -344,7 +344,7 @@ ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg);
#define ZMQ_VMCI_BUFFER_MIN_SIZE 86 #define ZMQ_VMCI_BUFFER_MIN_SIZE 86
#define ZMQ_VMCI_BUFFER_MAX_SIZE 87 #define ZMQ_VMCI_BUFFER_MAX_SIZE 87
#define ZMQ_VMCI_CONNECT_TIMEOUT 88 #define ZMQ_VMCI_CONNECT_TIMEOUT 88
#define ZMQ_USEFD 89 #define ZMQ_USE_FD 89
/* Message options */ /* Message options */
#define ZMQ_MORE 1 #define ZMQ_MORE 1

View File

@ -158,7 +158,7 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
// MUST NOT unlink if the FD is managed by the user, or it will stop // MUST NOT unlink if the FD is managed by the user, or it will stop
// working after the first client connects. The user will take care of // working after the first client connects. The user will take care of
// cleaning up the file after the service is stopped. // cleaning up the file after the service is stopped.
if (options.usefd == -1) { if (options.use_fd == -1) {
::unlink (addr.c_str()); ::unlink (addr.c_str());
} }
filename.clear (); filename.clear ();
@ -171,8 +171,8 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
address.to_string (endpoint); address.to_string (endpoint);
if (options.usefd != -1) { if (options.use_fd != -1) {
s = options.usefd; s = options.use_fd;
} else { } else {
// Create a listening socket. // Create a listening socket.
s = open_socket (AF_UNIX, SOCK_STREAM, 0); s = open_socket (AF_UNIX, SOCK_STREAM, 0);
@ -216,7 +216,7 @@ int zmq::ipc_listener_t::close ()
// MUST NOT unlink if the FD is managed by the user, or it will stop // MUST NOT unlink if the FD is managed by the user, or it will stop
// working after the first client connects. The user will take care of // working after the first client connects. The user will take care of
// cleaning up the file after the service is stopped. // cleaning up the file after the service is stopped.
if (has_file && !filename.empty () && options.usefd == -1) { if (has_file && !filename.empty () && options.use_fd == -1) {
rc = ::unlink(filename.c_str ()); rc = ::unlink(filename.c_str ());
if (rc != 0) { if (rc != 0) {
socket->event_close_failed (endpoint, zmq_errno()); socket->event_close_failed (endpoint, zmq_errno());

View File

@ -78,7 +78,7 @@ zmq::options_t::options_t () :
heartbeat_ttl (0), heartbeat_ttl (0),
heartbeat_interval (0), heartbeat_interval (0),
heartbeat_timeout (-1), heartbeat_timeout (-1),
usefd (-1) use_fd (-1)
{ {
#if defined ZMQ_HAVE_VMCI #if defined ZMQ_HAVE_VMCI
vmci_buffer_size = 0; vmci_buffer_size = 0;
@ -623,9 +623,9 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break; break;
# endif # endif
case ZMQ_USEFD: case ZMQ_USE_FD:
if (is_int && value >= -1) { if (is_int && value >= -1) {
usefd = value; use_fd = value;
return 0; return 0;
} }
break; break;
@ -1040,9 +1040,9 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
} }
break; break;
case ZMQ_USEFD: case ZMQ_USE_FD:
if (is_int) { if (is_int) {
*value = usefd; *value = use_fd;
return 0; return 0;
} }
break; break;

View File

@ -235,7 +235,7 @@ namespace zmq
// When creating a new ZMQ socket, if this option is set the value // When creating a new ZMQ socket, if this option is set the value
// will be used as the File Descriptor instead of allocating a new // will be used as the File Descriptor instead of allocating a new
// one via the socket () system call. // one via the socket () system call.
int usefd; int use_fd;
}; };
} }

View File

@ -168,8 +168,8 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
address.to_string (endpoint); address.to_string (endpoint);
if (options.usefd != -1) { if (options.use_fd != -1) {
s = options.usefd; s = options.use_fd;
socket->event_listening (endpoint, (int) s); socket->event_listening (endpoint, (int) s);
return 0; return 0;
} }

View File

@ -90,8 +90,8 @@ if(NOT WIN32)
test_stream_exceeds_buffer test_stream_exceeds_buffer
test_router_mandatory_hwm test_router_mandatory_hwm
test_term_endpoint_tipc test_term_endpoint_tipc
test_usefd_ipc test_use_fd_ipc
test_usefd_tcp test_use_fd_tcp
) )
if(HAVE_FORK) if(HAVE_FORK)
list(APPEND tests test_fork) list(APPEND tests test_fork)

View File

@ -70,7 +70,7 @@ void test_setsockopt_tcp_send_buffer()
zmq_ctx_term(ctx); zmq_ctx_term(ctx);
} }
void test_setsockopt_usefd() void test_setsockopt_use_fd()
{ {
int rc; int rc;
void *ctx = zmq_ctx_new(); void *ctx = zmq_ctx_new();
@ -79,17 +79,17 @@ void test_setsockopt_usefd()
int val = 0; int val = 0;
size_t placeholder = sizeof(val); size_t placeholder = sizeof(val);
rc = zmq_getsockopt(socket, ZMQ_USEFD, &val, &placeholder); rc = zmq_getsockopt(socket, ZMQ_USE_FD, &val, &placeholder);
assert(rc == 0); assert(rc == 0);
assert(val == -1); assert(val == -1);
val = 3; val = 3;
rc = zmq_setsockopt(socket, ZMQ_USEFD, &val, sizeof(val)); rc = zmq_setsockopt(socket, ZMQ_USE_FD, &val, sizeof(val));
assert(rc == 0); assert(rc == 0);
assert(val == 3); assert(val == 3);
rc = zmq_getsockopt(socket, ZMQ_USEFD, &val, &placeholder); rc = zmq_getsockopt(socket, ZMQ_USE_FD, &val, &placeholder);
assert(rc == 0); assert(rc == 0);
assert(val == 3); assert(val == 3);
@ -102,5 +102,5 @@ int main()
{ {
test_setsockopt_tcp_recv_buffer(); test_setsockopt_tcp_recv_buffer();
test_setsockopt_tcp_send_buffer(); test_setsockopt_tcp_send_buffer();
test_setsockopt_usefd(); test_setsockopt_use_fd();
} }

View File

@ -50,7 +50,7 @@ void pre_allocate_sock (void *zmq_socket, const char *path)
rc = listen (s_pre, SOMAXCONN); rc = listen (s_pre, SOMAXCONN);
assert (rc == 0); assert (rc == 0);
rc = zmq_setsockopt (zmq_socket, ZMQ_USEFD, &s_pre, rc = zmq_setsockopt (zmq_socket, ZMQ_USE_FD, &s_pre,
sizeof (s_pre)); sizeof (s_pre));
assert(rc == 0); assert(rc == 0);
} }

View File

@ -52,7 +52,7 @@ void pre_allocate_sock (void *zmq_socket, const char *address,
rc = listen (s_pre, SOMAXCONN); rc = listen (s_pre, SOMAXCONN);
assert (rc == 0); assert (rc == 0);
rc = zmq_setsockopt (zmq_socket, ZMQ_USEFD, &s_pre, rc = zmq_setsockopt (zmq_socket, ZMQ_USE_FD, &s_pre,
sizeof (s_pre)); sizeof (s_pre));
assert(rc == 0); assert(rc == 0);
} }