0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-31 01:43:02 +08:00

2729 Commits

Author SHA1 Message Date
korbes
63e1e745f8 Fixed compilation with ZMQ_ATOMIC_PTR_MUTEX 2018-05-14 22:08:15 -03:00
Luca Boccassi
d81a041f18
Merge pull request #3103 from sigiesec/win-warnings-as-errors
Warnings in Windows builds
2018-05-14 22:53:04 +01:00
Simon Giesecke
d437d668c0 Problem: MSVC warnings in connection with poll
Solution: handle types properly
2018-05-14 22:25:21 +02:00
Simon Giesecke
c589f2b603 Problem: C4800 warning in socket_base.cpp
Solution: make proper boolean expression
2018-05-14 19:18:37 +02:00
Simon Giesecke
c52871f82c Problem: C4627 warning in proxy.cpp and signaler.cpp
Solution: move conditional include directive to precompiled.hpp
2018-05-14 18:07:13 +02:00
Simon Giesecke
a8095a1046 Problem: C4800 warning in ip_resolver.cpp
Solution: fix type specification
2018-05-14 18:07:13 +02:00
Simon Giesecke
95c770a275 Problem: C4099 warning in udp_engine.cpp
Solution: fix type specification
2018-05-14 17:17:11 +02:00
Simon Giesecke
bf6bde3ae3 Problem: unnecessary ifdefs regarding handling of int vs. SOCKET at various places
Solution: use a typedef instead
2018-05-14 14:58:36 +02:00
Simon Giesecke
e8877f78a9 Problem: zmq_poller_[add/modify] accept invalid events arguments silently
Solution: check and return an error on invalid arguments. Fixes #3088
2018-05-14 14:58:36 +02:00
Simon Giesecke
6b9b369469 Problem: zmq_poller_* argument check code is cloned
Solution: extract common code into functions
2018-05-14 14:34:46 +02:00
Simon Giesecke
213254cca5 Problem: inconsistent behaviour of zmq_poller_new in case of memory exhaustion
Solution: return NULL and set errno to ENOMEM
2018-05-14 11:29:24 +02:00
Simon Giesecke
00d25b7873 Problem: inconsistent behaviour of zmq_poller_add and zmq_poller_add_fd in case of memory exhaustion
Solution: always return -1 with errno == ENOMEM
2018-05-14 11:29:24 +02:00
Luca Boccassi
b331caad06 Problem: ZMTP 3.1 PING Context not implemented
Solution: if a PING message contains a context, echo it back in the
PONG message. In order to do so, create the PONG message when PING
is received and store it in the engine.
After the PING the engine goes straight to encoding and sending, so
there can always be at most one pending PING.
Add tests for various contexts.
2018-05-14 10:14:13 +02:00
Luca Boccassi
5482b1ca45 Problem: heartbeat command parsing does not check command name size
Solution: treat the first byte of the command body as the size of the
command name, rather than as an id, to comply with ZMTP 3.1.
This was not an actual problem at runtime since both heartbeat
commands have a size of 4, which was treated like an id.
But once SUBSCRIBE/UNSUBSCRIBE get implemented it needs to be checked.
2018-05-14 09:15:39 +02:00
Luca Boccassi
09f700f72e Problem: uninitialised class variable warning
Solution: initialise it
2018-05-13 18:24:50 +01:00
Luca Boccassi
7ba074fa28 Problem: Sun Studio build errors
Solution: add compiler flags to support extensions like anonymous
structs in unions, fix casting of const, and check for suncc rather
than solaris
2018-05-13 18:24:50 +01:00
Lionel Flandrin
a833ace204 Problem: no way to specify source interface for UDP multicast sender sockets
Solution: if a binding interface is provided in the sender URL we pass
it to IP[V6]_MULTICAST_IF setsockopt
2018-05-13 18:32:12 +02:00
Luca Boccassi
b78cfb2395 Problem: mismatching declarations and definitions break Solaris Studio build
Solution: add missing const qualifier to internal functions
2018-05-13 13:17:20 +01:00
Luca Boccassi
8b82ed50a2 Problem: Solaris Studio does not convert from char * to string
Solution: do it explicitly to fix build on Solaris 10/11 with the Sun
compiler
2018-05-13 13:16:37 +01:00
Simon Giesecke
3d9c119543 Problem: compilation broken on Solaris
Solution: remove constness on pair arguments. Fixes #3090
2018-05-13 13:15:32 +01:00
Simon Giesecke
d6433b5c24 Problem: warnings in MSVC builds around size_t/int
Solution: use proper types
2018-05-13 11:11:19 +02:00
Lionel Flandrin
99412c810d Problem: ZMQ doesn't expose the MULTICAST_LOOP socket option
Solution: add a new ZMQ_MULTICAST_LOOP option for UDP sockets.
2018-05-10 19:24:46 +02:00
Lionel Flandrin
b0df4be51c Problem: UDP engine does not support IPv6
Solution: Add IPv6 support
2018-05-09 12:06:23 +02:00
Lionel Flandrin
746d4a0f5e Problem: UDP transport doesn't let the user specify the local bind address
for multicast

Solution: augment the UDP URL syntax to accept an interface specifier with a
syntax similar to the PGM urls.

Fixes #2212
2018-05-04 14:36:18 +02:00
Lionel Flandrin
524affc4c3 Problem: UDP address parser uses ad hoc code to detect multicast address
Solution: factor the code into ip_resolver, add IPv6 support and unit tests.
2018-05-04 10:44:01 +02:00
Lionel Flandrin
2dc8579412 Problem: the UDP address code uses an ad hoc custom parser
Solution: replace it with the ip_resolver code shared with the TCP
address code

It simplifies the UDP parsing code and makes it behave more like the
TCP counterpart, in particular it's not possible to connect to hosts
by name and bind by NIC names.

It also adds support for "*" port resolving to 0 (useful to let the OS
allocate the port number).
2018-05-03 14:22:48 +02:00
Lionel Flandrin
406c348771 Problem: ip_resolver allows wildcard ports for non-bindable sockets
Solution: return an error in this situation but still allow using an explicit
"0" if somebody really wants to connect to port 0.

This shouldn't break any existing code because a "*" port was already rejected
in an early test in the TCP path in zmq::socket_base_t::connect.
2018-05-03 13:19:22 +02:00
Lionel Flandrin
4cd2c2ebf8 Problem: address parsing code is tied to the TCP code
Solution: Factor the code into a different file with a well defined API and add
unit tests.
2018-05-02 18:06:01 +02:00
Luca Boccassi
cae6434345 Problem: HEARTBEAT command breaks REQ connection
Solution: ignore command messages in the REQ session to avoid
disrupting the state machine.
Commands are handled by the engine before handing off to the session.
2018-04-28 15:25:24 +01:00
Maks Naumov
989dfc7801
Fix fd_t variable casting on Windows platform
event_accepted() already accepts fd_t type and there is no reason to cast it to int type
Moreover, on Windows x64 this leads to truncation memsize -> int
2018-04-19 12:38:06 +03:00
asafkahlon
8e8009ec5d Implement the wsa_error_no function with switch-case (#3044)
* Implement the wsa_error_no function with switch-case

Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
2018-04-13 15:16:54 +01:00
Marc Sune
c7d602a29b Problem: C++ style comments in header file breaks pedantic build
Solution: change missing comments in header file
Fixes: #3036 and adds on top of '15905c5'
2018-04-03 22:58:36 +02:00
Luca Boccassi
15905c5561 Problem: C++ style comments in C file breaks pedantic build
Solution: change comments
Fixes: #3036
2018-04-02 21:52:01 +01:00
Simon Giesecke
87fbb5c447 Problem: socket poller shutdown asserts when context is terminating
Solution: do not call getsockopt to query thread-safety of a socket
2018-03-28 11:23:08 +02:00
Luca Boccassi
6f26a33359 Problem: 4.2.5 is out, we need to restore API changes and 4.3.x
Solution: revert the revert!

Revert "Problem: regression in 4.2.3 went unnoticed, want to release 4.2.5"

This reverts commit 5f17e26fa4c60c3de0282d1b6ad1e8b7037ed57a.
2018-03-23 19:31:42 +00:00
Luca Boccassi
5f17e26fa4 Problem: regression in 4.2.3 went unnoticed, want to release 4.2.5
Solution: revert DRAFT -> STABLE API transition so that we can do a
bugfix-only 4.2.5 release.
Will be re-reverted once tagged.

Revert "Problem: ZMQ_BINDTODEVICE has met STABLE conditions"

This reverts commit 3cb79f5042cf32cdb7b1b58d4acf17eba85ec9f7.

Revert "Problem: ZMQ_MSG_GSSAPI_* have met STABLE conditions"

This reverts commit 374da4207b8034b0fcd67a2cc2165d50e09b9387.

Revert "Problem: ZMQ_MSG_T_SIZE has met STABLE conditions"

This reverts commit 6411c4a247c08ead50919d16b30eb030eaf44a7e.

Revert "Problem: docs say STABLE API still in DRAFT"

This reverts commit 9f2f30b7ffa09acc51d3b87251a47e83b435d5d4.
2018-03-23 11:22:10 +00:00
Luca Boccassi
1c5a63e939 Problem: backward incompatible change to NULL with ZAP
Solution: like for other mechanism, do not enforce strict ZAP protocol
adherence unless the specific socket option is enabled with NULL auth.

Add test to exercise this functionality, and fix ZAP test to set the
socket option when it uses NULL auth.

See: https://github.com/zeromq/pyzmq/pull/1152
2018-03-22 19:27:23 +00:00
Luca Boccassi
3cb79f5042 Problem: ZMQ_BINDTODEVICE has met STABLE conditions
Solution: move them from DRAFT to STABLE since it's been in a public
release, committed for 6+ months and has not changed.
2018-03-21 16:45:41 +00:00
Luca Boccassi
374da4207b Problem: ZMQ_MSG_GSSAPI_* have met STABLE conditions
Solution: move them from DRAFT to STABLE since it's been in a public
release, committed for 6+ months and has not changed.
2018-03-21 16:45:41 +00:00
Luca Boccassi
6411c4a247 Problem: ZMQ_MSG_T_SIZE has met STABLE conditions
Solution: move it from DRAFT to STABLE since it's been in a public
release, committed for 6+ months and has not changed.
Given a new STABLE symbol has been added, bump minor version number.
2018-03-21 16:45:41 +00:00
Pontus Sköldström
6a5af3dae6 Removed unnecessary errno_assert 2018-03-20 14:35:24 +01:00
Pontus Sköldström
65a9670065 Problem: ZMQ_DISH over UDP triggers errno_assert() after hitting watermark 2018-03-19 17:46:48 +01:00
Luca Boccassi
8f5fc705e4 Problem: global random init/deinit breaks existing applications
Solution: restrict it only to the original issue #2632, Tweetnacl on
*NIX when using /dev/urandom, ie: without the new Linux getrandom()
syscall.

Existing applications might use atexit to register cleanup functions
(like CZMQ does), and the current change as-is imposes an ordering
that did not exist before - the context MUST be created BEFORE
registering the cleanup with atexit. This is a backward incompatible
change that is reported to cause aborts in some applications.

Although libsodium's documentation says that its initialisation APIs
is not thread-safe, nobody has ever reported an issue with it, so
avoiding the global init/deinit in the libsodium case is the less
risky option we have.

Tweetnacl users on Windows and on Linux with getrandom (glibc 2.25 and
Linux kernel 3.17) are not affected by the original issue.

Fixes #2991
2018-03-19 15:47:07 +00:00
Pontus Sköldström
dd5eec35be Support application metadata through ZMQ_METADATA
Lets the application set per-connection metadata.
Metadata is specified as "X-key:value" and set using zmq_setsockopt, eg:
zmq_setsockopt (s, ZMQ_METADATA, "X-key:value", 11);

The peer can then obtain the metadata from a received message:
char *data = zmq_msg_gets(msg, "X-key");
2018-03-14 12:56:15 +01:00
Sergey Kachanovskiy
9c748f1bf1 Partial fix for issue 2963, removed invalid casts from fd_t to int (#2984)
* Fixes issue 2963, ref stream_engine.cpp:981

* Fixes issue 2963, ref socks_connecter.cpp:158

* Fixes issue 2963, ref tcp_listener.cpp:144

* Fixes issue 2963, ref tcp_connecter.cpp:423

* Fixes issue 2963, ref socks_connecter.cpp:436

* Fixes issue 2963, ref tcp_listener.cpp:179

* Fixes issue 2963, ref tcp_listener.cpp:268

* Fixes issue 2963, ref tcp_connecter.cpp:160
2018-03-12 11:55:58 +01:00
Luca Boccassi
8d544ef1c4 Problem: formatting issues in the CI
Solution: commit clang-format-diff
2018-03-10 12:44:27 +00:00
Luca Boccassi
fef99d6c50 Problem: tweetnacl is external code and clang-format parses it
Solution: add pragma to make clang-format ignore the external code
2018-03-10 12:43:34 +00:00
Manuel Segura
4726f7262d Pull request to merge porting to WindRiver VxWorks 6.x (#2966)
* Problem: Still need to port over more files to VxWorks 6.x

Solution: Port more files to VxWorks 6.x

* Problem: Need to port over remaining files to VxWorks 6.x. Also remove POSIX thread dependency for VxWorks (because of priority inversion problem in POSIX mutexes with VxWorks 6.x processes)

Solution: Port over remaining files to VxWorks 6.x. Also removed POSIX thread dependency for VxWorks

* Problem: Needed to modify TCP, UDP, TIPC classes with #ifdefs to be compatible with VxWorks 6.x.

Solution:  Modify TCP, UDP, TIPC classes with #ifdefs to be compatible with VxWorks 6.x
2018-03-10 11:03:02 +00:00
Kachanovskiy
90342e0d29 Fixed issue #2979 2018-03-09 22:24:23 +01:00
Pontus.Skoeldstroem
7abb8388d6 Problem: Tests for different TIPC address types missing (#2956)
* Tests for different TIPC address types and code cleanup

* Adds tests for binding/connecting with different TIPC address types
  using Unity
* Adds error checking for address type misuse
2018-03-07 17:31:26 +00:00
Simon Giesecke
cef9cfa091
Revert "Problem: mis-detection of threadsafe_static_init causes test failures" 2018-03-07 15:03:07 +01:00
Luca Boccassi
9bd2d3f937 Problem: mis-detection of threadsafe_static_init causes test failures
Solution: do not rely __cplusplus >= 201103L to detect whether the
compiler supports thread safe static initialisation, but check only
the proper feature preprocessor macro.
GCC introduced it in version 8, and Clang in version 6.
2018-03-06 23:11:03 +00:00
Luca Boccassi
e0b1992dd7 Problem: build broken with gcc-4.7
Solution: initialise variable in options.cpp to dummy value to fix
compiler complaint:

 src/options.cpp: In function
  'int zmq::do_setsockopt_int_as_bool_strict(const void*, size_t, bool*)':
 src/options.cpp:121:5: error: 'value' may be used uninitialized in
  this function [-Werror=maybe-uninitialized]
 src/options.cpp: In function
  'int zmq::do_setsockopt_int_as_bool_relaxed(const void*, size_t, bool*)':
 src/options.cpp:135:31: error: 'value' may be used uninitialized in
  this function [-Werror=maybe-uninitialized]
2018-03-06 20:29:47 +00:00
Luca Boccassi
ec58ba04f3
Merge pull request #2972 from sigiesec/reduce-sockopt-code-duplication
Problem: code duplication in getsockopt/setsockopt
2018-03-06 20:08:46 +00:00
Simon Giesecke
6f967c3a13 Problem: code duplication in getsockopt/setsockopt
Solution: extracted common code into do_getsockopt/do_setsockopt functions
2018-03-06 16:41:30 +01:00
Luca Boccassi
10d2b2885e
Merge pull request #2971 from ZMQers/fix-static-init
Problem: static initialization order fiasco
2018-03-06 09:18:52 +00:00
Luca Boccassi
541ca30d8e Problem: make clang-format still shows error in the CI
Solution: run make clang-format-diff and commit the changes.
2018-03-05 22:41:11 +00:00
Luca Boccassi
4ea1e78d9d
Merge pull request #2969 from skaes/master
Problem: enormous memory increase due to zero copy decoding
2018-03-05 17:40:33 +00:00
Stefan Kaes
fcbd2a5710 Problem: enormous memory increase due to zero copy decoding
The zero copy decoding strategy implemented for 4.2.0 can lead to a large
increase of main memory usage in some cases (I have seen one program go up to
40G from 10G after upgrading from 4.1.4). This commit adds a new option to
contexts, called ZMQ_ZERO_COPY_RECV, which allows one to switch to the old
decoding strategy.
2018-03-05 18:13:28 +01:00
Ryan Hileman
3658b2b580 Problem: pthread condvar timeouts are broken (#2967)
* fix pthread condvar timeouts

This fixes a race condition / hang for threadsafe sockets.
Context: https://github.com/zeromq/czmq/issues/1873#issuecomment-370279244
2018-03-05 16:36:10 +00:00
Simon Giesecke
8cdfc8b9dd Problem: static initialization order fiasco
Solution: use local statics when available in a thread-safe implementation
2018-03-05 16:30:57 +01:00
Simon Giesecke
9cd01bb54f Problem: inconsistent return values from mtrie_t::rm
Solution: Return an enum from rm instead of a bool, and adapt existing uses
2018-03-02 13:42:50 +01:00
Simon Giesecke
36cdcc6c1a Problem: docs of mtrie referring to subscriptions and pipes
Solution: generalized terms to entries/values
2018-03-02 13:42:47 +01:00
Simon Giesecke
5d5def40b5 Problem: casts required due to void* arguments in a C++ class
Solution: introduce a type template argument
2018-03-02 13:42:42 +01:00
Simon Giesecke
5fb0e97ab7 Problem: semantic issues
Solution: added some TODO comments, improved existing documentation
2018-03-02 13:42:31 +01:00
Simon Giesecke
a9712c0bf2 Problem: no unittests for mtrie
Solution: made mtrie generic (to remove complex dependency on pipe_t),
and added some unit tests
2018-03-02 13:32:51 +01:00
Simon Giesecke
9fc3692e3f Problem: read-only arguments of mtrie are not declared as const
Solution: add const, introduce typedef
2018-03-02 13:32:50 +01:00
Romain Geissler
1e03f7b2d4 Fix gcc 8 build warning/error with -O3. 2018-02-27 10:12:22 +01:00
Pontus Sköldström
78aa9b1983 Support addressing TIPC Port Identity
ZeroMQ currently supports location independent addressing using TIPC
Port Names with tipc://{type,instance}. This commits adds support for
connecting and binding using TIPC Port Identity addresses. To connect
using Port Identities the expected format is tipc://<Z.C.N:Ref>, e.g.
"tipc://<1.2.3:123123>". To bind using TIPC Port Identities the expected
format is "tipc://<*>".
2018-02-19 17:34:40 +01:00
Kachanovskiy
e10464e45e Fix for build break when SIO_LOOPBACK_FAST_PATH is not defined (i.e. in VS2010) 2018-02-13 23:04:08 +01:00
Simon Giesecke
94743fd21f Problem: wrong formatting in several files
Solution: apply clang-format
2018-02-13 18:40:43 +01:00
Simon Giesecke
90c6d993be Problem: kqueue_t fails unittest_poller
Solution: fix shutdown of kqueue_t
2018-02-13 18:38:30 +01:00
Simon Giesecke
3b90ad8c63 Problem: support of std::atomic is incomplete in VS <2015
Solution: use std::atomic only from VS 2015
2018-02-13 18:38:29 +01:00
Simon Giesecke
96131b5b4e Problem: no documentation of the poller concept
Solution: added documentation
2018-02-13 18:38:25 +01:00
Simon Giesecke
a8e9032dc5 Problem: unreachable code in io_thread_t::process_stop
Solution: replaced by assertion
2018-02-13 18:38:24 +01:00
Simon Giesecke
a5738529e8 Problem: wsa_assert does not include error code
Solution: extend output of wsa_assert
2018-02-13 18:38:22 +01:00
Simon Giesecke
e8e24030ea Problem: network initialization and shutdown functions not available for
reuse

Solution: extract into functions defined in ip.hpp

Problem: signaler_t::make_fdpair not reusable

Solution: move make_fdpair to ip.hpp

Problem: epoll worker with no fds cannot be stopped

Solution: use interruptible epoll_pwait call

Problem: insufficient unit tests for poller

Solution: add test cases
2018-02-13 18:38:17 +01:00
Simon Giesecke
c62574ffca Problem: segfault in select_t::trigger_events
Solution: fixed access to stale vector
2018-02-12 14:42:46 +01:00
Simon Giesecke
11a5388637 Problem: data race w.r.t. select_t::stopping
Solution: change termination condition of select_t
2018-02-12 14:42:33 +01:00
Simon Giesecke
e650240580 Problem: data race w.r.t. poll_t::stopping
Solution: remove stopping, stop on thread-safe conditions; add
additional checks for correct thread-safe usage
2018-02-12 14:41:53 +01:00
Simon Giesecke
08201bc1b9 Problem: select blocks forever under Unix
Solution: fixed call of select, and initialization of poll_t members
2018-02-12 14:39:02 +01:00
Luca Boccassi
a30133d8f5
Merge pull request #2935 from ZMQers/unity-base
Problem: no test framework, no unit tests
2018-02-12 11:01:08 +00:00
Luca Boccassi
d0e01b4bb2 Problem: regression with "select" on *nix (#2940)
* Problem: build failure with select as polling mechanism

Solution: cast mailbox_handle argument to (poller_t::handle_t) like in
the reaper thread class.

* Problem: build failure due to INT_MAX use without include

Solution: include limits and climits in src/select.cpp where INT_MAX is
used

* Problem: build failure due to unused variable in select.cpp

Solution: move the declaration of int rc inside the ifdef block where
it is actually used

* Problem: reference to wrong variable in select.cpp breaks build

Solution: fix it

* Problem: family_entry_t constructor has no body, build fails on *nix

Solution: add empty inline function in the struct

* Problem: no test coverage for poll and select

Solution: add Travis jobs for them on Linux

* Problem: Travis jobs cannot run in container infra

Solution: set sudo: false as it is not required anymore
2018-02-12 03:01:03 -05:00
Simon Giesecke
7ea924c763 Problem: segfault on thread_t::stop if thread was never started
Solution: add started flag
2018-02-11 17:25:36 +00:00
Simon Giesecke
f87d3ab294 Problem: pollers unnecessarily depend on whole ctx_t, but actually use only start_thread method
Solution: extract thread_ctx_t from ctx_t
2018-02-11 17:25:36 +00:00
Simon Giesecke
5873894c83 Problem: wrong assertion macro used on Windows
Solution: use wsa_assert instead of errno_assert
2018-02-11 13:52:41 +01:00
Simon Giesecke
2f27bcd74b Problem: assertion failure in poll_t::poll if timer_event retired a
pollset entry

Solution: clean up retired entries before poll
2018-02-11 13:49:26 +01:00
Simon Giesecke
a2af3d18cc Problem: unittest_poller fails for poll_t
Solution: fixed behaviour in corner cases
2018-02-11 13:49:25 +01:00
Luca Boccassi
c33cb38af2
Merge pull request #2928 from eponsko/master
Add support for ZMQ_XPUB_NODROP on ZMQ_RADIO sockets
2018-02-09 17:15:47 +00:00
Pontus Sköldström
a57f7e3824 Add support for ZMQ_XPUB_NODROP on ZMQ_RADIO sockets
Solves issue #2927
2018-02-09 16:20:50 +01:00
Simon Giesecke
a5e763039d Problem: use of TCP loopback fastpath not available for user sockets
Solution: add socket option
2018-02-09 14:22:42 +01:00
sigiesec
490d76da2f Problem: SIO_LOOPBACK_FAST_PATH not activated for signaler socket pair
Solution: activate SIO_LOOPBACK_FAST_PATH if available

See #2899
2018-02-09 13:50:40 +01:00
sigiesec
88d8c768d1 Problem: test_timers frequently fails on travis-ci
Solution: relaxed test assertions, based on the actual time passed,
instead of assuming that this equals to the time slept
2018-02-09 09:55:40 +01:00
Simon Giesecke
3baefc66ea Problem: incomplete assertions around modifications of fd_entries vs.
load

Solution: add assertions, partially in debug build only, improved naming
2018-02-09 09:53:02 +01:00
Simon Giesecke
a1d55d0506 Problem: race conditions for options.linger (#2910)
* Problem: race conditions for options.linger

Solution: make options.linger atomic
2018-02-08 22:10:45 +00:00
Simon Giesecke
de0c669323 Problem: std::atomic not used on Visual C++ although it is available (#2930)
* Problem: std::atomic not used on Visual C++ although it is available

Solution: change conditional compilation to recognize _MSC_VER
2018-02-08 22:01:02 +00:00
Luca Boccassi
cdfc6bb8b3
Merge pull request #2924 from sigiesec/tcp-cleanup
Problem: duplicated code, redundant member handle_valid, asymmetry between tcp_connecter and tcp_listener
2018-02-08 21:57:46 +00:00
Luca Boccassi
9fbd125b41
Merge pull request #2917 from ZMQers/thread-safe-simplification
Problem: code duplication and unnecessary nesting around ZMQ_THREAD_SAFE querying
2018-02-08 21:57:06 +00:00
sigiesec
147fe9ed77 Problem: code duplication and unnecessary nesting around ZMQ_THREAD_SAFE
querying

Solution: remove code duplication and rearrange conditions
2018-02-08 22:54:30 +01:00
Luca Boccassi
cb9ccfa154
Merge pull request #2921 from sigiesec/mechanism-cleanup
Problem: code style issues in mechanism_t and socket_base_t
2018-02-08 21:53:14 +00:00
Luca Boccassi
2e849a4d60
Merge pull request #2913 from ZMQers/add-const
Problem: several fields are non-const without need
2018-02-08 21:47:21 +00:00
Simon Giesecke
2c2ea82789 Problem: duplicated code, redundant member handle_valid, asymmetry between
tcp_connecter and tcp_listener

Solution: remove duplication and redundant member, align handling of
handle in tcp_connecter and tcp_listener
2018-02-08 22:20:01 +01:00
sigiesec
06d805ff82 Problem: unnecessary complex operations in socket_base_t::term_endpoint
Solution: use simpler operations, construct std::string only once
2018-02-08 22:19:54 +01:00
sigiesec
9a6993adce Problem: several code style issues in mechanism_t: code and data duplication,
unnecessary construction of temporary std::string

Solution: removed duplication, removed construction of std::string
2018-02-08 22:19:54 +01:00
sigiesec
368eff9ecb Problem: several fields are non-const without need
Solution: add const where easily possible
2018-02-08 22:17:03 +01:00
sigiesec
5b510656d0 Problem: unreachable code around socket_base_t::add/remove_signaler
Solution: replaced by assertion
2018-02-08 22:16:30 +01:00
sigiesec
41f459e1dc Problem: formatting inconsistent
Solution: applied clang-format
2018-02-02 15:47:43 +01:00
Pontus Sköldström
542fe67f25 Problem: ZMQ_DISH triggers assert when hitting the watermark(?)
Solves issue #2907 by checking whether the msg already has a group
2018-02-02 14:01:45 +01:00
sigiesec
206c832167 Problem: in case of exhausted resources on creation of a context, assertions are triggered
Solution: signal error to caller, and apply appropriate cleanup
2018-01-31 20:53:06 +01:00
Simon Giesecke
7488be61c2 Problem: add_fd might be called with fd_ == retired_fd
Solution: add assertion
2018-01-25 16:03:43 +01:00
Bill Torpey
ec05166545 prevent duplicate connections from PUB sockets also (see https://github.com/zeromq/libzmq/issues/788) 2017-12-29 14:36:59 -05:00
evoskuil
9622984241 Problem: vc++ 11.0 (vs 2012) compile fails on move semantics. 2017-12-14 14:58:02 -08:00
evoskuil
8d78e08f71 Problem: fn pointers are not bool (vc++ warning C4550). 2017-12-14 12:47:38 -08:00
Jasper Lievisse Adriaanse
22b57f6f28 Problem: Build is broken on OpenBSD
Solution: re-instate block for OpenBSD erroneously removed in 9622a830
2017-12-14 09:47:49 +01:00
Luca Boccassi
ac552ba448 Problem: accept4 not available on all platforms
Solution: check for availability in CMake and autoconf before using it
2017-11-18 11:33:53 +00:00
ccpaging
e8ad51e62f Clean code for Visual Studio 2008 compiler 2017-11-16 14:09:13 +08:00
Rolf Timmermans
c8592dfbc3 Problem: REQ socket with ZMQ_REQ_RELAXED does not report ZMQ_POLLOUT when queried for events after first message.
Solution: Check for strictness before returning false if no reply has been received.
2017-11-08 09:55:14 +01:00
Anton Bärwald
630f6d6ae7 Problem: On OSX usleep() changes the errno value
Solution: Update errno value after calling usleep()
2017-11-02 16:01:11 +01:00
sigiesec
f9d7eea6f9 Problem: code duplication
Solution: unified Windows & non-Windows code further
2017-10-26 11:05:39 +02:00
sigiesec
e7817ad38d Problem: code duplication
Solution: reduced code duplication by introducing local variables and
new function trigger_events
2017-10-26 10:47:05 +02:00
sigiesec
37914d1be2 Problem: get_fd_family call is expensive and called frequently for the
same fds

Solution: cache results of get_fd_family
2017-10-26 09:46:11 +02:00
sigiesec
cd32603c0e Problem: wsa_events are initialized/destroyed within every loop
iteration even if not used

Solution: Move wsa_events closer to usage
2017-10-25 18:30:03 +02:00
f18m
2aa0e6fd4d Change ZMQ_THREAD_AFFINITY to ZMQ_THREAD_AFFINITY_CPU_ADD/ZMQ_THREAD_AFFINITY_CPU_REMOVE. Avoid prefix thread names when no prefix was set. 2017-10-25 09:55:47 +02:00
Yann Diorcet
81327af557 Partial Windows XP support 2017-10-24 13:12:34 +02:00
Simon Giesecke
7ec58b279a Problem: one missed optimization opportunity for blob_t map lookup
Solution: create referencing blob_t
2017-10-23 11:12:15 +02:00
Simon Giesecke
a4aceb272b Problem: use of std::map::insert is inefficient
Solution: use std::map::emplace instead, where available
2017-10-22 17:15:00 +02:00
Simon Giesecke
0897b3e07b Problem: excessive memory allocations around blob_t (#2796)
* Problem: excessive memory allocations around blob_t

Solution: redefine blob_t as a custom type, and use reference/move
semantics where possible
2017-10-21 12:19:51 +01:00
sigiesec
cfb2129557 Problem: comment before sndtimeo/rcvtimeo does not specify dimension
Solution: add "milliseconds"
2017-10-18 15:04:54 +02:00
f18m
f25cd6e7be Background thread names (#2784)
* Add ZMQ_THREAD_NAME_PREFIX ctx option
2017-10-17 12:06:50 +01:00
f18m
bfbb4ff2e9 Background threads enhancements (#2778)
* Background thread scheduling 

- add ZMQ_THREAD_AFFINITY ctx option; set all thread scheduling options
from the context of the secondary thread instead of using the main
process thread context!
- change ZMQ_THREAD_PRIORITY to support setting NICE of the background
thread when using SCHED_OTHER
2017-10-16 12:29:03 +01:00
Luca Boccassi
b6aee51691 Problem: strict ZAP protocol adherence is backward incompatible
Solution: add ZMQ_ZAP_ENFORCE_DOMAIN to hide backward incompatible
change and make it disabled by default.
In a future release that breaks API compatibility we can then switch
the default to enabled in order to achieve full RFC compatibility.

Fixes #2762
2017-10-09 17:48:33 +01:00
Luca Boccassi
50bddbaac9 Problem: dead code in options.hpp
Solution: remove unused zap_ipc_creds boolean variable
2017-10-09 13:52:56 +01:00
Luca Boccassi
e3ee55b191 Problem: missing indentation for UDP branch
Solution: fix it
2017-10-09 13:52:56 +01:00
Luca Boccassi
c8f3f8a5da Problem: ambiguos bitwise ANDs in if statements
Solution: wrap bitwise ANDs in brackets as the static analyzer suggests
2017-10-09 13:52:56 +01:00
Luca Boccassi
7ad06f1449 Problem: IPC event_closed logs -1 as the FD
Solution: take a copy of the file descriptor before setting it to
retired_fd.
2017-10-06 09:53:59 +01:00
Luca Boccassi
9be8cebd21 Merge pull request #2765 from GreatFruitOmsk/issue-2764
Problem: Race condition in IPC sockets
2017-10-06 09:25:33 +01:00
Ilya Kulakov
656cdb959a Problem: Race condition in IPC sockets
Solution: Don't unlink file on close

File may not belong to the socket at that point.
2017-10-05 14:57:10 -07:00
Christopher Hall
997825bdf1 add __FreeBSD__ to ifdefs
On FreeBSD the sysmbol __FreeBSD_kernel__ is only defines if a
specific param.h file is included, unlike Debian/kFreeBSD where this
symbol is always defined.  So also compile the FreeBSD specific code
if __FreeBSD__ is defined for FreeBSD 11 & 12 compatibility.

Signed-off-by: Christopher Hall <hsw@ms2.hinet.net>
2017-10-03 15:30:42 +08:00
Luca Boccassi
44f96a3652 Merge pull request #2745 from sigiesec/rename-identity
Problem: term "identity" is confusing
2017-09-20 10:08:45 +02:00
sigiesec
2c8a7223b8 Problem: remaining use of "identity"
Solution: replaced by "routing id"
2017-09-19 17:55:00 +02:00
sigiesec
7e3f4b1d32 Problem: ZMTP protocol broken w.r.t. Identity property
Solution: differentiate propertly between ZMTP property names and ZeroMQ API property names
2017-09-19 17:55:00 +02:00
sigiesec
a5e3a65ae2 Problem: inconsistency between zmq.h and zmq_draft.h
Solution: fix zmq_draft.h
2017-09-19 17:55:00 +02:00
sigiesec
4b821d8f84 Problem: remaining uses of "identity"
Solution: replaced by "routing id"
2017-09-19 17:54:59 +02:00
sigiesec
fab57634b4 Problem: Message metadata properties still refer to "identity"
Solution: Renamed, but support querying the property by its old name
2017-09-19 17:53:53 +02:00
sigiesec
27c7e52a5a Problem: Usage of "rid" in server_t
Solution: Replaced by "routing_id"
2017-09-19 17:53:53 +02:00
sigiesec
41bae55af7 Problem: inconsistent naming related to routing ids
Solution: renamed routing_id fields in pipe_t, renamed ZMQ_CONNECT_RID to ZMQ_CONNECT_ROUTING_ID
2017-09-19 17:53:53 +02:00
sigiesec
9e7507b38b Problem: term "identity" is confusing
Solution: replace by "routing id"
2017-09-19 17:53:44 +02:00
Luca Boccassi
edb4ca1023 Problem: zmq_connect fails after disconnect due to RECONNECT_IVL == -1
Solution: when a connection breaks and ZMQ_RECONNECT_IVL is set to -1,
which means a reconnection will not be attempted, send a message from
the I/O thread to the application thread to make the socket call
term_endpoint, which is the equivalent of manually calling
zmq_disconnect.
This way subsequent zmq_connect call to the same endpoint will attempt
again to do a connection.
Otherwise, for some socket types like SUBs, those new connects will
fail as the endpoint is recorded, despite the connection having been
permanently closed.

Add test cases to exercise this corner case with TCP and IPC.
2017-09-19 14:05:43 +01:00
sigiesec
e546f9296e Problem: duplicated code & inconsistent behaviour between
mechanisms

Solution: uniformly require a ZAP domain to be set to activate ZAP
handling, clarify comment on Stonehouse pattern
2017-09-18 17:01:38 +02:00
sigiesec
a5f94cb610 Problem: tests without ZAP handler are failing
Solution: emit events as expected by tests, and refuse connections when
ZAP is required but no handler started

Addresses #2711 partially
2017-09-18 12:58:09 +02:00
Luca Boccassi
5de2a82be8 Merge pull request #2744 from msune/refactor_poller_wait
Problem: duplicated socket_poller::wait() code
2017-09-13 00:48:26 +02:00
Marc Sune
5b92989540 Problem: duplicated socket_poller::wait() code
zmq::socket_poller_t::wait() had an important set of common lines
between POLL and SELECT variant.

Solution: refactor zmq::socket_poller_t::wait() and add the
following methods:

zmq::socket_poller_t::zero_trail_events()
zmq::socket_poller_t::check_events()
zmq::socket_poller_t::adjust_timeout()

Signed-off-by: Marc Sune <mardevel@gmail.com>
2017-09-12 21:47:57 +02:00
Doron Somech
af03241dcb Revert "Problem: term "identity" is confusing" 2017-09-07 15:47:43 +03:00
sigiesec
deae59dca9 Problem: Message metadata properties still refer to "identity"
Solution: Renamed, but support querying the property by its old name
2017-09-07 10:33:25 +02:00
sigiesec
ae2ea1a655 Problem: Usage of "rid" in server_t
Solution: Replaced by "routing_id"
2017-09-07 10:33:25 +02:00
sigiesec
e00131dd43 Problem: inconsistent naming related to routing ids
Solution: renamed routing_id fields in pipe_t, renamed ZMQ_CONNECT_RID to ZMQ_CONNECT_ROUTING_ID
2017-09-07 10:33:13 +02:00
sigiesec
1daf83079a Problem: term "identity" is confusing
Solution: replace by "routing id"
2017-09-06 17:45:56 +02:00
Luca Boccassi
4fac78ec31 Problem: proxy stat 5th multipart message treated as 1st
Solution: fix it
2017-09-06 08:27:29 +01:00
Luca Boccassi
d7da31ed25 Problem: typo in comment in proxy.cpp
Solution: fix it
2017-09-06 08:27:17 +01:00
Luca Boccassi
b8695a47b5 Problem: proxy_steerable STATISTICS returns conflated buffers
Solution: split each stat into its own frame, to make it simpler and
easier to use it, especially from high level bindings
2017-09-06 01:28:28 +01:00
Luca Boccassi
78c4d33600 Problem: new STATISTICS proxy_steerable not behind DRAFT
Solution: ifdef it until it's declared stable
2017-09-05 17:37:52 +01:00
f18m
4be9513443 Add "STATISTICS" command to zmq_proxy_steerable() (#2737)
* Issue #2736: Add STATISTICS command to zmq_proxy_steerable()
2017-09-05 17:05:04 +01:00
Luca Boccassi
f4b32aa792 Merge pull request #2734 from pavel-pimenov/fix-v1001
Variable is assigned but is not used until the end of the function
2017-09-04 15:25:43 +01:00
pavel.pimenov
0e8bf3520c V728 An excessive check 'options.mechanism == 0' can be simplified.
The '||' operator is surrounded by opposite expressions. session_base.cpp 377
2017-09-04 15:25:31 +03:00
pavel.pimenov
51ac7d28c5 V1001 The 'ptr' variable is assigned but is not used until the end of the function. 2017-09-04 15:15:35 +03:00
Luca Boccassi
8feed48bb9 Problem: switch statements without breaks
Solution: add /* FALLTHROUGH */ comments so that nagging compilers
don't nag
2017-09-01 20:01:15 +01:00
Luca Boccassi
31089326fb Problem: unused variables warnings in get_peer_state
Solution: wrap arguments with LIBZMQ_UNUSED
2017-09-01 19:57:00 +01:00
Luca Boccassi
31e3977ab9 Merge pull request #2731 from sigiesec/fix-issue-2723
Problem: assertion in src\select.cpp:111 on Windows or hang on zmq_ctx_destroy
2017-09-01 19:51:39 +01:00
sigiesec
79e28af4ce Problem: new function zmq_socket_get_peer_state not in zmq_draft.h
Solution: added function to zmq_draft.h
2017-09-01 17:15:23 +02:00
sigiesec
48a1e637b6 Problem: zmq_socket_get_peer_state is not implemented
Solution: add initial implementation
2017-09-01 16:28:58 +02:00
sigiesec
f4d139bd16 Problem: duplicated code in socket-related functions
Solution: extract as_socket_base_t function
2017-09-01 16:28:58 +02:00
sigiesec
efa86fe629 Problem: no test case using the proposed zmq_socket_get_peer_state function
Solution: added test case (with dummy implementation of zmq_socket_get_peer_state)
2017-09-01 16:28:58 +02:00
sigiesec
23e018f37a Problem: termination is requested from a session's owner when already in
pending termination while processing an error

Solution: terminate pipe instead

Fixes #2723
2017-09-01 11:55:31 +02:00
sigiesec
eb8105cde1 Problem: assertion failure in select.cpp:111 under Windows
Solution: handle case when get_fd_family fails
2017-09-01 11:55:31 +02:00
bjovke
91e0d689bb Problem: Inconsistent size_t/int usage. Solution: types corrected. 2017-08-28 15:03:46 +02:00
Jim Klimov
40a3b0746f Problem: cosmetic setThreadName() can be fatal
Solution: do not assert() the values returned; if we failed to set the thread name - we just have harder debugging, not flawed production conditions.
Closes github issue #2679

Signed-off-by: Jim Klimov <EvgenyKlimov@eaton.com>
2017-08-25 15:30:03 +02:00
sigiesec
6147e45a07 Problem: missing tests for zmq_timers_* corner cases, missing handling of such corner cases, code duplication, missing assertions in test code
Solution: add tests, add checks to timers_t, add match_by_id functor, add assertions
2017-08-23 09:41:34 +02:00
sigiesec
f685a3ffd2 Solution: unreachable code paths in socket_poller_t
Problem: replaced by assertions resp. removed
2017-08-22 21:23:09 +02:00
sigiesec
a71f7b0405 Problem: zmq_poller_* uses ETIMEDOUT (instead of the usual EAGAIN) to indicate timeouts
Solution: replace ETIMEDOUT within socket_poller_t and all client code by EAGAIN

Fixes #2713
2017-08-22 20:00:29 +02:00
sigiesec
6a3c053a3e Problem: EFAULT is returned for bad file descriptors passed to zmq_poller_*_fd
Solution: Return EBADF instead
2017-08-22 19:43:56 +02:00
sigiesec
74303b08e6 Problem: calling zmq_poller_wait* with NULL events causes an assertion, as opposed to other NULL arguments, which return an error
Solution: return EFAULT when such an operation is attempted
2017-08-22 19:43:56 +02:00
sigiesec
c1a4cfdd9f Problem: waiting on an empty poller with infinite timeout waits forever
Solution: return EFAULT when such an operation is attempted
2017-08-22 19:43:56 +02:00
sigiesec
2e4fc4faf0 Problem: zmq_poller_*_fd functions do not check for invalid fd
Solution: add checks, added test cases
2017-08-22 19:28:07 +02:00
sigiesec
c3c2515542 Problem: code duplication within zmq::select_t::rm_fd
Solution: extract find_fd_entry_by_handle from rm_fd
2017-08-21 14:36:50 +02:00
sigiesec
bd0675b93f Problem: no tests for client-side events for successful handshake and authentication failure in handshake
Solution: added tests for CURVE, add emitting of client-side event in curve_client_t; add ZAP code 300/500 tests for all mechanisms; suppress sending an error message for ZAP code 300
2017-08-20 22:45:14 +02:00
Luca Boccassi
f6ce019fff Problem: incompatible parameter passed to send_zap_request
Solution: cast from void* to uint8_t* to match new definition
2017-08-19 17:40:15 +01:00
Luca Boccassi
7c85bf2f88 Problem: uninitialised variables in gssapi_server constructor
Solution: initialise session and peer_address
2017-08-19 17:40:15 +01:00
Luca Boccassi
2ba0149ee4 Problem: gssapi_mechanism_base_t initialisation misses one param
Solution: pass the session as well as the options
2017-08-19 17:40:15 +01:00
Luca Boccassi
83c9c0b55f Problem: gssapi_client does not have a peer_address param
Solution: remove it from the gssapi_mechanism_base initialiser
2017-08-19 17:40:15 +01:00
Luca Boccassi
24b2f61b1b Problem: gssapi_server out of date with zap_client
Solution: remove local unused zap_client variable
2017-08-19 17:40:15 +01:00
Luca Boccassi
c8097af884 Problem: DRAFT GSSAPI socket options in wrong section cause duplication
Solution: move them together with the other DRAFT socket options, and
change value of DRAFT ZMQ_BINDTODEVICE from 90 to 92 to avoid clash
2017-08-19 17:40:15 +01:00
Luca Boccassi
6f49e40e36 Problem: gssapi_mechanism_base does not include mechanism_base
Solution: include mechanism_base.hpp instead of mechanism.hpp
2017-08-19 17:40:15 +01:00
Luca Boccassi
e2ffa2a77b Problem: produce_ready in gssapi_mechanism_base not deduped
Solution: call make_command_with_basic_properties
2017-08-19 17:40:15 +01:00
Luca Boccassi
90b6c102bb Problem: various unused variables warnings
Solution: use LIBZMQ_UNUSED where necessary
2017-08-19 12:18:51 +01:00
Luca Boccassi
7be3efc936 Problem: TODO in gssapi mechanism
Solution: remove it.
Looking at the code:

https://github.com/krb5/krb5/blob/master/src/lib/gssapi/mechglue/g_unseal.c#L55

gss_unwrap as the very first thing checks that plaintext is not a
null pointer, which in our case it's true given it's on the stack,
and then initialises its members to 0 length and null ptr.

https://github.com/krb5/krb5/blob/master/src/lib/gssapi/mechglue/g_rel_buffer.c#L36

So it should be safe to release it in all cases, and the release API
seems to check again if it's not a null pointer and then if the
members are 0 length and null pointer it's a no-op.
2017-08-18 15:58:35 +01:00
Luca Boccassi
77444e206c Problem: free on stack variable in GSSAPI mechanism
Solution: free wrapper.value instead of wrapper.
2017-08-18 15:57:51 +01:00
sigiesec
898691e2eb Problem: gssapi_mechanism_base_t aborts the application when it receives a message it cannot decode
Solution: emit an ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL event instead of using zmq_assert
2017-08-18 12:29:37 +02:00
sigiesec
301f3c70c2 Problem: code duplication between curve_client_t and curve_server_t decode and encode
Solution: extracted common base class curve_mechanism_base_t
2017-08-18 11:34:22 +02:00
sigiesec
44f6aa3de6 Problem: gssapi_* do not emit ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL events
Solution: emit appropriate events
2017-08-18 10:30:48 +02:00
sigiesec
ca7eee357e Problem: no ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL events emitted in plain_client_t
Solution: emit events at appropriate places
2017-08-18 10:15:44 +02:00