Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
15846f2f
Commit
15846f2f
authored
Feb 08, 2016
by
Constantin Rack
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1784 from bluca/rename_pre_allocated_fd
Problem: ZMQ_PRE_ALLOCATED_FD is too long
parents
66d9a5f5
c1581787
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
35 additions
and
35 deletions
+35
-35
.gitignore
.gitignore
+2
-2
Makefile.am
Makefile.am
+8
-8
zmq_getsockopt.txt
doc/zmq_getsockopt.txt
+2
-2
zmq_setsockopt.txt
doc/zmq_setsockopt.txt
+1
-1
zmq.h
include/zmq.h
+1
-1
ipc_listener.cpp
src/ipc_listener.cpp
+4
-4
options.cpp
src/options.cpp
+5
-5
options.hpp
src/options.hpp
+1
-1
tcp_listener.cpp
src/tcp_listener.cpp
+2
-2
CMakeLists.txt
tests/CMakeLists.txt
+2
-2
test_setsockopt.cpp
tests/test_setsockopt.cpp
+5
-5
test_usefd_ipc.cpp
tests/test_usefd_ipc.cpp
+1
-1
test_usefd_tcp.cpp
tests/test_usefd_tcp.cpp
+1
-1
No files found.
.gitignore
View file @
15846f2f
...
...
@@ -125,8 +125,8 @@ test_timers
test_radio_dish
test_udp
test_large_msg
test_
pre_allocated_
fd_ipc
test_
pre_allocated_
fd_tcp
test_
use
fd_ipc
test_
use
fd_tcp
tests/test*.log
tests/test*.trs
src/platform.hpp*
...
...
Makefile.am
View file @
15846f2f
...
...
@@ -626,8 +626,8 @@ test_apps += \
tests/test_shutdown_stress
\
tests/test_pair_ipc
\
tests/test_reqrep_ipc
\
tests/test_
pre_allocated_
fd_ipc
\
tests/test_
pre_allocated_
fd_tcp
\
tests/test_
use
fd_ipc
\
tests/test_
use
fd_tcp
\
tests/test_timeo
\
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_LDADD
=
src/libzmq.la
tests_test_
pre_allocated_
fd_ipc_SOURCES
=
\
tests/test_
pre_allocated_
fd_ipc.cpp
\
tests_test_
use
fd_ipc_SOURCES
=
\
tests/test_
use
fd_ipc.cpp
\
tests/testutil.hpp
tests_test_
pre_allocated_
fd_ipc_LDADD
=
src/libzmq.la
tests_test_
use
fd_ipc_LDADD
=
src/libzmq.la
tests_test_
pre_allocated_
fd_tcp_SOURCES
=
\
tests/test_
pre_allocated_
fd_tcp.cpp
\
tests_test_
use
fd_tcp_SOURCES
=
\
tests/test_
use
fd_tcp.cpp
\
tests/testutil.hpp
tests_test_
pre_allocated_
fd_tcp_LDADD
=
src/libzmq.la
tests_test_
use
fd_tcp_LDADD
=
src/libzmq.la
if
HAVE_FORK
test_apps
+=
tests/test_fork
...
...
doc/zmq_getsockopt.txt
View file @
15846f2f
...
...
@@ -464,9 +464,9 @@ Default value:: null string
Applicable socket types:: all, when using TCP or IPC transports
ZMQ_
PRE_ALLOCATED_
FD: Retrieve the pre-allocated socket file descriptor
ZMQ_
USE
FD: Retrieve the pre-allocated socket file descriptor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_
PRE_ALLOCATED_
FD' 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
returned if a pre-allocated file descriptor was not set for the socket.
...
...
doc/zmq_setsockopt.txt
View file @
15846f2f
...
...
@@ -492,7 +492,7 @@ Default value:: not set
Applicable socket types:: all, when using TCP transport
ZMQ_
PRE_ALLOCATED_
FD: 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,
the socket shall use the corresponding file descriptor for connections over
...
...
include/zmq.h
View file @
15846f2f
...
...
@@ -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_MAX_SIZE 87
#define ZMQ_VMCI_CONNECT_TIMEOUT 88
#define ZMQ_
PRE_ALLOCATED_
FD 89
#define ZMQ_
USE
FD 89
/* Message options */
#define ZMQ_MORE 1
...
...
src/ipc_listener.cpp
View file @
15846f2f
...
...
@@ -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
// working after the first client connects. The user will take care of
// cleaning up the file after the service is stopped.
if
(
options
.
pre_allocated_
fd
==
-
1
)
{
if
(
options
.
use
fd
==
-
1
)
{
::
unlink
(
addr
.
c_str
());
}
filename
.
clear
();
...
...
@@ -171,8 +171,8 @@ int zmq::ipc_listener_t::set_address (const char *addr_)
address
.
to_string
(
endpoint
);
if
(
options
.
pre_allocated_
fd
!=
-
1
)
{
s
=
options
.
pre_allocated_
fd
;
if
(
options
.
use
fd
!=
-
1
)
{
s
=
options
.
use
fd
;
}
else
{
// Create a listening socket.
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
// working after the first client connects. The user will take care of
// cleaning up the file after the service is stopped.
if
(
has_file
&&
!
filename
.
empty
()
&&
options
.
pre_allocated_
fd
==
-
1
)
{
if
(
has_file
&&
!
filename
.
empty
()
&&
options
.
use
fd
==
-
1
)
{
rc
=
::
unlink
(
filename
.
c_str
());
if
(
rc
!=
0
)
{
socket
->
event_close_failed
(
endpoint
,
zmq_errno
());
...
...
src/options.cpp
View file @
15846f2f
...
...
@@ -78,7 +78,7 @@ zmq::options_t::options_t () :
heartbeat_ttl
(
0
),
heartbeat_interval
(
0
),
heartbeat_timeout
(
-
1
),
pre_allocated_
fd
(
-
1
)
use
fd
(
-
1
)
{
#if defined ZMQ_HAVE_VMCI
vmci_buffer_size
=
0
;
...
...
@@ -623,9 +623,9 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
break
;
# endif
case
ZMQ_
PRE_ALLOCATED_
FD
:
case
ZMQ_
USE
FD
:
if
(
is_int
&&
value
>=
-
1
)
{
pre_allocated_
fd
=
value
;
use
fd
=
value
;
return
0
;
}
break
;
...
...
@@ -1040,9 +1040,9 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
}
break
;
case
ZMQ_
PRE_ALLOCATED_
FD
:
case
ZMQ_
USE
FD
:
if
(
is_int
)
{
*
value
=
pre_allocated_
fd
;
*
value
=
use
fd
;
return
0
;
}
break
;
...
...
src/options.hpp
View file @
15846f2f
...
...
@@ -235,7 +235,7 @@ namespace zmq
// 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
// one via the socket () system call.
int
pre_allocated_
fd
;
int
use
fd
;
};
}
...
...
src/tcp_listener.cpp
View file @
15846f2f
...
...
@@ -168,8 +168,8 @@ int zmq::tcp_listener_t::set_address (const char *addr_)
address
.
to_string
(
endpoint
);
if
(
options
.
pre_allocated_
fd
!=
-
1
)
{
s
=
options
.
pre_allocated_
fd
;
if
(
options
.
use
fd
!=
-
1
)
{
s
=
options
.
use
fd
;
socket
->
event_listening
(
endpoint
,
(
int
)
s
);
return
0
;
}
...
...
tests/CMakeLists.txt
View file @
15846f2f
...
...
@@ -90,8 +90,8 @@ if(NOT WIN32)
test_stream_exceeds_buffer
test_router_mandatory_hwm
test_term_endpoint_tipc
test_
pre_allocated_
fd_ipc
test_
pre_allocated_
fd_tcp
test_
use
fd_ipc
test_
use
fd_tcp
)
if
(
HAVE_FORK
)
list
(
APPEND tests test_fork
)
...
...
tests/test_setsockopt.cpp
View file @
15846f2f
...
...
@@ -70,7 +70,7 @@ void test_setsockopt_tcp_send_buffer()
zmq_ctx_term
(
ctx
);
}
void
test_setsockopt_
pre_allocated_
fd
()
void
test_setsockopt_
use
fd
()
{
int
rc
;
void
*
ctx
=
zmq_ctx_new
();
...
...
@@ -79,17 +79,17 @@ void test_setsockopt_pre_allocated_fd()
int
val
=
0
;
size_t
placeholder
=
sizeof
(
val
);
rc
=
zmq_getsockopt
(
socket
,
ZMQ_
PRE_ALLOCATED_
FD
,
&
val
,
&
placeholder
);
rc
=
zmq_getsockopt
(
socket
,
ZMQ_
USE
FD
,
&
val
,
&
placeholder
);
assert
(
rc
==
0
);
assert
(
val
==
-
1
);
val
=
3
;
rc
=
zmq_setsockopt
(
socket
,
ZMQ_
PRE_ALLOCATED_
FD
,
&
val
,
sizeof
(
val
));
rc
=
zmq_setsockopt
(
socket
,
ZMQ_
USE
FD
,
&
val
,
sizeof
(
val
));
assert
(
rc
==
0
);
assert
(
val
==
3
);
rc
=
zmq_getsockopt
(
socket
,
ZMQ_
PRE_ALLOCATED_
FD
,
&
val
,
&
placeholder
);
rc
=
zmq_getsockopt
(
socket
,
ZMQ_
USE
FD
,
&
val
,
&
placeholder
);
assert
(
rc
==
0
);
assert
(
val
==
3
);
...
...
@@ -102,5 +102,5 @@ int main()
{
test_setsockopt_tcp_recv_buffer
();
test_setsockopt_tcp_send_buffer
();
test_setsockopt_
pre_allocated_
fd
();
test_setsockopt_
use
fd
();
}
tests/test_
pre_allocated_
fd_ipc.cpp
→
tests/test_
use
fd_ipc.cpp
View file @
15846f2f
...
...
@@ -50,7 +50,7 @@ void pre_allocate_sock (void *zmq_socket, const char *path)
rc
=
listen
(
s_pre
,
SOMAXCONN
);
assert
(
rc
==
0
);
rc
=
zmq_setsockopt
(
zmq_socket
,
ZMQ_
PRE_ALLOCATED_
FD
,
&
s_pre
,
rc
=
zmq_setsockopt
(
zmq_socket
,
ZMQ_
USE
FD
,
&
s_pre
,
sizeof
(
s_pre
));
assert
(
rc
==
0
);
}
...
...
tests/test_
pre_allocated_
fd_tcp.cpp
→
tests/test_
use
fd_tcp.cpp
View file @
15846f2f
...
...
@@ -52,7 +52,7 @@ void pre_allocate_sock (void *zmq_socket, const char *address,
rc
=
listen
(
s_pre
,
SOMAXCONN
);
assert
(
rc
==
0
);
rc
=
zmq_setsockopt
(
zmq_socket
,
ZMQ_
PRE_ALLOCATED_
FD
,
&
s_pre
,
rc
=
zmq_setsockopt
(
zmq_socket
,
ZMQ_
USE
FD
,
&
s_pre
,
sizeof
(
s_pre
));
assert
(
rc
==
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment