Commit Graph

2275 Commits

Author SHA1 Message Date
Goswin von Brederlow
1dd5fef20c zmq_curve_keypair(): return result from crypto_box_keypair() to make testcase meaningfull 2017-03-16 14:01:08 +00:00
Luca Boccassi
d7aceef2ed Problem: thread name is redundant
Solution: call it simply "ZMQ background" instead of "ZMQ b/g thread"
2017-03-12 13:11:44 +00:00
Luca Boccassi
092ad50b0c Problem: I can't refactor
Solution: fix ifdef check for pthread_setname
2017-03-12 13:11:11 +00:00
Luca Boccassi
3ab4796c5a Problem: ZMQ background threads are unnamed
Solution: use pthread API to set the name. For now call every thread
"ZMQ b/g thread". Would be nice to number the I/O threads and name
explicitly the reaper thread, but in reality a bit of internal API
churn would be necessary, so perhaps it's not worth it.
This is useful when debugging a process with many threads.
2017-03-12 00:46:15 +00:00
somdoron
f694a2d985 problem: zmq_poll is slow because FD is being created on every call
making the creation of FD only when thread safe sockets are in used
within the zmq_poller which improve the zmq_poll performance.
2017-03-11 11:07:06 +02:00
nexcvon
9624f9ade7 Problem: zmq::signaler_t::send may loop forever
Solution: restore the wsa_assert statement previously removed.
2017-03-06 21:55:30 +08:00
nexcvon
bcf75777c8 Problem: Assertion failed in zmq::signaler_t::send
Solution: Change to the way it does below on non-Windows platforms, retry when send returns -1.
2017-03-03 19:00:58 +08:00
Luca Boccassi
a73d5cd6c6 Problem: router pipe can block forever
Solution: invert check_write and check_hwm calls in router xsend
function so that check_write can mark the pipe as inactive if
necessary.
2017-02-24 23:56:52 +00:00
Luca Boccassi
0f473d14cb Problem: unnecessary change to router_mandatory_hwm test
Solution:

Revert "Problem with ZMQ_ROUTER_MANDATORY option when peer lost"

This partially reverts commit 06740b5d8c.

The change in the mentioned commit was fixed to be backward
compatible so test changes are no longer necessary.
Partially revert the commit, leaving only the bug fix and taking out
the test change and the superfluous change in socket_base.
2017-02-24 17:57:14 +00:00
Reza Ebrahimi
06740b5d8c Problem with ZMQ_ROUTER_MANDATORY option when peer lost
indention

Revert "indention"

This reverts commit a6e7e192ac2d089ac9f7dc0d31d4b1fd10de982e.

indention

indention

Fix Failure in tests

Check both pipe full and pipe close
2017-02-24 20:49:26 +03:30
Luca Boccassi
18cb7caeb2 Problem: v4-in-v6 mapped addresses cause parsing failure
Solution: in the address validator accept an endpoint that starts
with :, eg: ::ffff:192.168.0.1:12345 as it's a valid mapped
address.
2017-02-03 11:19:31 +01:00
Patrick McLean
df7c684dd5 fix divide by zero in zmq::lb_t::sendpipe
This is based on https://github.com/zeromq/zeromq3-x/pull/116/files
2017-01-27 17:08:20 -08:00
Ahmad M. Zawawi
bf6d8a5d17 Fix clock_t crash on iOS 9.3.2 and 9.3.5 (#2325)
* Fix possible clock_t crash on iOS 9.3.2 and 9.3.5 + macOS < 10.12

* No need to read return value
2017-01-26 13:21:41 +00:00
sigiesec
c6c21cf197 Problem: zmq_z85_decode does not validate its input (#2322)
* Problem: zmq_z85_decode does not validate its input
Solution: added checks for invalid characters and overflows

* Added tests, added further check for range overflow, removed (multiple) calls to strlen

* Problem: gcc fails to build
Solution: added missing include directive

* Added VS2015 test_utils_z85 project

* Fixed indentation and copyright notice

* Resolved garbage from merge

* Revert "Added VS2015 test_utils_z85 project"

This reverts commit c58b3c664c.

* Problem: test calls zmq_z85_decode with a NULL dest
Solution: call zmq_z85_decode with a properly sized buffer

* Problem: tests for zmq_z85_* scattered over two files
Solution: merged files

* Removed reference to removed test file from CMakeLists.txt

* Problem: Missing include directive to stdint.h
Solution: Added include directive

* Define __STDC_LIMIT_MACROS before including stdint.h

* Problem: Wrong variable is checked for invalid character marker
Solution: Use correct variable
2017-01-25 14:28:03 +00:00
Asmod4n
4dbd387fa9 Add "draft" capability to zmq_has
As discussed in #2307
2017-01-19 18:44:56 +01:00
laplaceyang
107f2441d5 Problem: Thread-safe solution for modify hwm of pipe
Solution: where change pipe hwm, send a command (new type pipe_hwm) to peer, so peer pipe can modify hwm thread-safely
2017-01-11 10:49:54 +08:00
Luca Boccassi
edc770d680 Problem: HWM always boosted by 1
Solution: initialise *hwmboost to -1 instead of 1, and use it only if
it's >= 0. The socket option code checks anyway that the
user-provided value is >= 0 so there is no risk of clashing. The
documentation also specifies that it has to be >= 0.
2017-01-10 11:40:14 +00:00
Luca Boccassi
9f1ba60f50 Problem: modifying pipe from different thread is not safe
Solution: revert change from #2299 to avoid bugs while we look for an
alternative and thread-safe solution
2017-01-10 11:38:02 +00:00
laplaceyang
5adcb83509 Problem: set hwm after connect lead to infinite hwm 2017-01-09 12:34:40 +08:00
Luca Boccassi
31a3a06828 Problem: peer can close connection before SO_NOSIGPIPE is set
Solution: setsockopt returns EINVAL if the connection was closed by
the peer after the accept returned a valid socket. This is a valid
network error and should not cause an assert.
To handle this we have to extract the setsockopt from the stream
engine, as there's no clean way to return an error from the
constructor. Instead, try to set this option before creating the
engine in the callers, and return immediately as if the accept
had failed to avoid churn. Do the same for the connect calls by
setting the option in open_socket, so that the option for that
case is set even before connecting, so there's no possible race
condition.
Since this has to be done in 4 places (tcp/ipc listener, socks
connecter and open_socket) add an utility function in ip.cpp.
Fixes #1442
2017-01-04 17:34:33 +00:00
Patrik Wenger
1b3df75b87 fix typos 2017-01-03 12:45:33 +01:00
Vincent Tellier
7e36db07b1 Handshake events null pointer fix
The mechanism is instanciated during the handshake itself, when and
error happen before this, the error method shall work anyway.
An error handling with a NULL mechanism means the handshake fail, so the
handshake failure event is also raised in this case.
2017-01-01 19:08:28 +01:00
Vincent Tellier
ffb31dcadd Fixed issue #2227 second part
- removed the previously added encryption_error, less changes less bug
 - handshake fail is now signaled when an error happen while the
   mechanism is still hanshaking
2017-01-01 19:08:28 +01:00
Luca Boccassi
efc0e94291 Problem: build fails on GNU/Hurd as it does not support IPV6_TCLASS
Solution: check if IPV6_TCLASS is defined so that when Hurd adds
support it will just work. Also it will avoid tripping over this on
other similar legacy systems.
2017-01-01 16:23:27 +01:00
Luca Boccassi
c0e2bc4ef9 Problem: new DRAFT monitor events returned even without --enable-draft
Solution: wrap the event triggering in the DRAFT ifdef as well as the
defines. This ensures that the event are returned only if the
library was built with DRAFTs enabled.

Also update the test case to expect the new events since it uses
the catch-all mask. Although the sequence of event is different and
this might be considered as an API breakage, using the catch-all
ZMQ_EVENT_ALL mask implies that, well, all events are monitored so
it's normal that new ones will be added.
Users that don't want this kind of behaviour to change can simply
monitor only the event that they care about.
2016-12-30 23:21:14 +01:00
Vincent Tellier
48bc75e8a1 Code formatting + reverted hard error handshake fail
- Moved new events in draft section + added to zmq_draft.h
 - Removed the remainning tabs
 - Reverted the hard error (back to soft error) in curve_server.cpp

=> The feature doesn't works anymore
2016-12-30 18:34:33 +01:00
Vincent Tellier
b6e9e0c2d3 Fixed issue #2227
Added two new monitoring events:
 - ZMQ_EVENT_HANDSHAKE_SUCCEED is raised once the encryption handshake succeed
 - ZMQ_EVENT_HANDSHAKE_FAILED is raised when it failed
Both events are raised on server and client side.
2016-12-30 16:26:42 +01:00
Luca Boccassi
113feb60a2 Problem: ZMQ_MSG_T_SIZE draft but not in DRAFT section
Solution: move it there, add it to src/zmq_draft.h and clarify in the
documentation and in the NEWS file that this option is not yet stable
2016-12-29 21:07:39 +01:00
Luca Boccassi
6e708ce144 Problem: socketpair leaks file on fork+exec
Solution: if available, call socketpair with SOCK_CLOEXEC flag to
make the process close the socket on fork+exec
2016-12-26 19:13:02 +01:00
Luca Boccassi
f287c7a2aa Problem: eventfd leaks socket on fork+exec
Solution: if available, use eventfd with EFD_CLOEXEC flag to make
the process close the socket on fork+exec
2016-12-26 19:08:27 +01:00
Luca Boccassi
211898d243 Problem: epoll leaks socket on fork+exec
Solution: if available, use epoll_create1 with EPOLL_CLOEXEC flag to
make the process close the socket on fork+exec
2016-12-26 19:08:27 +01:00
Luca Boccassi
a06f97d73a Problem: fix for read-after-free not documented
Solution: add a comment as it's easy to miss and very tempting to
"optimize"
2016-12-25 18:01:55 +01:00
Wojciech Kula
ee72493e14 Problem: Duplicated code
Solution: set_curve_key method in options_t struct with little
improvement in switch-case block
2016-12-19 12:13:14 +01:00
Luca Boccassi
48e9e24726 Problem: #2262 broke curve
Solution: Revert "Problem: Duplicated code"

This reverts commit 022eeaf33d.
2016-12-16 16:50:17 +00:00
Wojciech Kula
022eeaf33d Problem: Duplicated code
Solution: set_curve_key method in options_t struct with little
improvement in switch-case block
2016-12-16 17:09:53 +01:00
Cziken
d514bb598a Fixed handling of WSAEWOULDBLOCK to be generic (#2260)
* Fixed handling of WSAEWOULDBLOCK to be generic

I don't know what was the intention of this early if statement but
now this is properly evaluated in wsa_error_no function if this is
performance issue I suggest moving evaluating this error code to the
beginning of wsa_error_no.

* Fixed handling of WSAEWOULDBLOCK to be generic

Introduced default pointer to const char * and overrides this as NULL
if function is called by zmq::wsa_error()

* Fixed handling of WSAEWOULDBLOCK to be generic

Introduced default pointer to const char * and overrides this as NULL
if function is called by zmq::wsa_error()
2016-12-16 15:51:00 +01:00
Luca Boccassi
2b565088d0 Merge pull request #2257 from minrk/check-event
zmq_poll: only compare FD when neither item is a zmq socket
2016-12-15 14:20:46 +01:00
Min RK
0abdc28c84 only compare FD when neither item is a zmq socket 2016-12-15 14:05:40 +01:00
laplaceyang
8e8fdcc9ed fix bug zmq4.x PUB msg to ZMTP1.0 SUB server 2016-12-15 20:29:58 +08:00
Laughing
a4e448d586 misuse of 'close'
use 'pollset_destroy' instead of 'close' to release pollset_fd
2016-12-13 11:09:01 +08:00
Luca Boccassi
72176d5fbe Problem: check for item.fd causes zloop_poller regression
Solution: fix the check for the socket.
This regression happens when using zloop with zmq_pollitem_it with
only file descriptors registerted through zloop_poller.
2016-12-10 23:49:18 +00:00
pavel.pimenov
4d6fbe17e0 "%" -> '%' 2016-12-10 17:27:42 +03:00
pavel.pimenov
eff42fa321 Add #include "precompiled.hpp" 2016-12-10 16:44:51 +03:00
Andreas Rottmann
365ca8595d Fix #include case for <mstcpip.h>
On native Windows, the file system is case-insensitive, so this this
doesn't matter there.

However, when compiling on a case-sensitive filesystem, such as when
cross-compiling from a Unixoid using mingw, we have to use the case
the file is supplied with, which is all lowercase.
2016-12-08 16:35:44 +01:00
Luca Boccassi
57db5f2a5c Problem: 4.2.0 won't compile on AIX 7.1
Solution: restore inclusion of poll.h if using poll before zmq.h as
it was originally, as AIX redefines the POSIX structures and provides
compatibility macros.
Also add alternative aliases for 32 bit AIX's pollitem struct:
  events -> reqevents
  revents -> rtnevents
2016-12-05 22:50:10 +00:00
Justin.Hung
52ebffd715 avoid crashing in the multi-thread operation for std::vector
1. stl container is not thread safety
2. rm_fd() and loop() end to clear the retired event source will in multi-thread operation
3. may be crashed in reaper thread to delete the items in the std::vector as the source is nullptr
2016-12-05 09:28:05 +08:00
Luca Boccassi
e46d91d41f Problem: PR #2236 breaks the build
Solution: Revert "avoid crashing in the multi-thread operation for std::vector"

This reverts commit e1368bdac8.
2016-12-03 22:10:19 +00:00
Justin.Hung
e1368bdac8 avoid crashing in the multi-thread operation for std::vector
1. stl container is not thread safety
2. rm_fd() and loop() end to clear the retired event source will in multi-thread operation
3. may be crashed in reaper thread to delete the items in the std::vector as the source is nullptr
2016-12-02 17:33:13 +08:00
Laughing
febf801584 bug fix: AIX pollset error (#2233)
* bug fix: AIX pollset error

buf fix:  AIX only, pollset 'rm_fd' set fd_table to null first then set pe->fd to retired_fd

* remove extra spaces

remove extra spaces
2016-12-01 11:59:23 +01:00
Luca Boccassi
33fcd2d6ca Problem: Windows does not support IPV6_TCLASS
Solution: don't use it on Windows.
There is a Windows-specific API for ToS, even IPv4 does not work and
it's just a silent no-op on that platform.
2016-11-30 11:09:12 +00:00