0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-21 15:12:03 +08:00

2059 Commits

Author SHA1 Message Date
somdoron
34968771ca add an option to check if the socket is thread safe 2015-08-16 11:50:50 +03:00
reza.ebrahimi
8e6ef4616e changing some camelCase variable names to snake_case in previous commit 2015-08-14 16:56:07 +04:30
reza.ebrahimi
d7b74d1f57 remove unnecessary multiple WSAGetLastError() calls 2015-08-14 16:29:18 +04:30
reza.ebrahimi
bff2284a50 place a ZMQ_UNUSED macro and replace all unused variables with ZMQ_UNUSED macro 2015-08-14 15:40:39 +04:30
Rik van der Heijden
c68e9a39bf Merge fix for zeromq/zeromq4-1#52, getsockopt ZMQ_RCVMORE now resets all bits 2015-08-11 21:37:50 +02:00
KIU Shueng Chuan
e129640471 fix: ZMQ_TCP_RETRANSMIT_TIMEOUT not applied to bind socket 2015-08-07 06:43:31 +08:00
Constantin Rack
84a93d4251 Merge pull request #1511 from sorenh/linger_fix
Avoid terminating connections prematurely
2015-08-06 20:45:45 +02:00
Soren Hansen
abc845d1af Avoid terminating connections prematurely
While sending very large messages (far beyond what fits in a the tcp
buffer, so it takes multiple sendto system calls for it to finish),
zmq_close will close the connection regardless of ZMQ_LINGER.

In case no engine is attached, a pipe->check_read() is needed to look
for the delimiter in the pipe and ultimately trigger the pipe
termination.

However, if there *is* an engine attached, the check_read() looks ahead
and finds the delimiter and terminates the connection even though the
engine might actually still be in the middle of sending a message.

This happens because while the io_thread is still busy sending the data,
the pipe can get terminated and the io thread ends up being terminated.
2015-08-06 20:09:37 +02:00
KIU Shueng Chuan
c7f2cdd699 fix: Windows setsockopt needs char* cast 2015-08-07 00:05:13 +08:00
KIU Shueng Chuan
ca9215de1e add ZMQ_TCP_RETRANSMIT_TIMEOUT socket option 2015-08-06 23:36:27 +08:00
KIU Shueng Chuan
eeb697b5ac add connect timeout logic 2015-08-04 22:17:02 +08:00
KIU Shueng Chuan
c0ca2be642 add ZMQ_CONNECT_TIMEOUT socket option 2015-08-04 22:17:02 +08:00
KIU Shueng Chuan
4a0bde8130 rename timer_started to reconnect_timer_started 2015-08-04 22:17:02 +08:00
Joe Eli McIlvain
438b5207f6 Remove type-pun in zmq.cpp to resolve issue #1500. 2015-08-02 08:27:07 -07:00
Pieter Hintjens
6dfe8f20e2 Merge pull request #1492 from brian-peloton/fix-memory-leak
Fix a documented memory leak.
2015-07-28 22:57:11 +02:00
Brian Silverman
62a0e45089 Fix eventfd read handling under heavy load.
I had the assertion below fail occasionally when running the libzmq
tests under heavy CPU load on linux 3.16.0-4-amd64.
2015-07-28 13:48:36 -07:00
Brian Silverman
97969808f6 Fix a documented memory leak.
Despite the old comments, re-initing the msg_t leaks a refcount to
metadata in some situations.

v1_decoder looks like it isn't tested any more, but it seems like a good
idea to fix it because it has the exact same piece of buggy code
v2_decoder does.
2015-07-28 13:48:13 -07:00
evoskuil
81aa6f45a4 Style and explicitness. 2015-07-26 17:37:38 -07:00
evoskuil
6f0efc092c Make lossy cast explicit. 2015-07-26 17:37:28 -07:00
KIU Shueng Chuan
2182bc963d check for potential unsigned integer wraparound before adding 2015-07-25 17:46:46 +08:00
KIU Shueng Chuan
3e7d737360 change ZMQ_STREAM_NOTIFY to default to 1 2015-07-24 05:21:53 +08:00
KIU Shueng Chuan
518b939f31 make ZMQ_STREAM_NOTIFY also control disconnect notificatons 2015-07-24 05:21:53 +08:00
Ricardo Catalinas Jiménez
ec5592db1f Fix 1478: receive unsubscriptions in XPUB when verbose
Fixes not receiving unsubscription messages in XPUB socket with
ZMQ_XPUB_VERBOSE and using a XSUB-XPUB proxy in front.

This adds two modifications:

- It adds a new flag, ZMQ_XPUB_VERBOSE_UNSUBSCRIBE, to enable verbose
  unsubscription messages, necessary when using a XSUB/XPUB proxy.

- It adds a boolean switch to zmq::mtrie_t::rm () to control if the
  callback is invoked every time or only in the last removal. Necessary
  when a pipe is terminated and the verbose mode for unsubscriptions is
  enabled.
2015-07-23 12:02:34 +01:00
Richard Newton
91877a22d7 Fix windows build 2015-07-23 08:49:03 +01:00
Richard Newton
a4509d8f88 Merge pull request #1484 from pijyoi/fixsmash
fix #1447 Segfault or Abort after PR #1441
2015-07-23 08:26:15 +01:00
Giulio Eulisse
e2be0d25bd Fix compilation on mac. 2015-07-22 21:31:48 +02:00
Brian Silverman
773a06fc23 Fix memory leak when creating a socket fails.
Previously, AddressSanitizer flagged leaks when running
tests/test_many_sockets.cpp.
2015-07-22 11:18:48 -07:00
KIU Shueng Chuan
708353a1b9 advance refcnt only if it was used 2015-07-22 21:19:22 +08:00
Brian Silverman
18791f2bfb Fix several missing msg_t::close calls.
I traced memory leaks found using AddressSanitizer down to these.
2015-07-21 19:42:20 -07:00
Jens Auer
23797120ff Fixed #1477 corruption in "zero-copy" raw_decoder for payloads larger than 8192 bytes #1477
Fixed wrong message::init arguments.
2015-07-20 22:22:13 +02:00
Constantin Rack
311f4d00e4 Merge pull request #1472 from reunanen/allow-explicitly-setting-buf-sizes-to-0
Allow explicitly setting buf sizes to 0
2015-07-08 11:20:45 +02:00
Juha Reunanen
f7b933f570 LIBZMQ-195 allow explicitly setting sndbuf and rcvbuf to 0 (see https://support.microsoft.com/en-us/kb/201213) 2015-07-08 11:31:34 +03:00
Pieter Hintjens
72a94881de Merge pull request #1471 from reunanen/retry-on-WSAENOBUFS
on Windows, handle WSAENOBUFS like WSAEWOULDBLOCK
2015-07-07 21:51:36 +02:00
Pieter Hintjens
adafdb8f4f Merge pull request #1470 from reunanen/check-msg-type-in-rm_refs
add message type sanity check in msg_t::rm_refs
2015-07-07 21:50:35 +02:00
Juha Reunanen
ccb13e1732 add sanity check in msg_t::rm_refs in order to avoid invalid memory access with u.zclmsg.refcnt 2015-07-07 19:31:46 +03:00
Juha Reunanen
8339271a3e LIBZMQ-195 on Windows, handle WSAENOBUFS like WSAEWOULDBLOCK 2015-07-07 13:38:10 +03:00
Thomas Köppe
29b45489fa [decoder.hpp] Fix misspelled inclusion 2015-07-06 00:20:59 +01:00
Thomas Köppe
5b4b8a063b [decoder*] Style fixes for consistency 2015-07-06 00:01:52 +01:00
Jens Auer
ef365151ca - Replaced C-style casts with C++-casts
- Replaced stdlib.h with cstdlib
- Made single-argument constructors explicit
2015-07-05 23:19:41 +02:00
Jens Auer
3679793601 "zero-copy" raw_decoder
A memcpy is eliminated when receiving data on a ZMQ_STREAM socket. Instead
of receiving into a static buffer and then copying the data into the
buffer malloced in msg_t::init_size, the raw_decoder allocates the memory
for together with the reference-counter and creates a msg_t object
on top of that memory. This saves the memcpy operation.

For small messages, data is still copied and the receive buffer is reused.
2015-07-05 16:05:46 +02:00
Thomas Köppe
14d69a312d Clean-up: Rename internal macros consistently. 2015-07-02 17:41:09 +01:00
Thomas Köppe
ddb82a546b atomic_counter.hpp: clean up the clean-up 2015-07-01 09:55:43 +01:00
Thomas Köppe
26e3873f70 Add C++11 support to atomic_counter_t. 2015-07-01 09:55:25 +01:00
Thomas Köppe
73e6a3808f atomic_ptr.h: clean up the clean-up 2015-06-30 22:57:13 +01:00
Thomas Köppe
08f9bf589e Add missing relaxed memory ordering. 2015-06-30 22:26:35 +01:00
Thomas Köppe
68f5926ec6 Add support for <atomic> in C++11 2015-06-30 20:57:38 +01:00
Jonathan Reams
e9a5bc8d1e Fix units and default values for heartbeats options
Set the ZMQ_HEARTBEAT_TIMEOUT to default to the value of
ZMQ_HEARTBEAT_IVL if it's not explicitly set.
Change the units of ZMQ_HEARTBEAT_TTL to milliseconds in the API
and round down to the nearest decisecond so that all the options
are using the same units.
Make the maximum heartbeat TTL match the spec (6553 seconds)
2015-06-26 14:25:58 -04:00
Jonathan Reams
cbb3b176a6 Add ZMTP heartbeats
This commit adds ZMTP connection heartbeats described in
http://rfc.zeromq.org/spec:37/ZMTP.
2015-06-24 13:24:53 -04:00
Marin Atanasov Nikolov
fa3b5d8b03 Typo fix 2015-06-23 14:45:51 +03:00
Constantin Rack
15f9ee19cb Solution: allow brackets in tcp ipv6 address 2015-06-23 08:54:49 +02:00
Jens Auer
e70b5efa0b Reuse buffer when no messages depend on it. 2015-06-14 14:01:04 +02:00
Jens Auer
51cb57e2c9 Fixed wrong handling of shared messages
The shared reference count was not shared but copied. msg_t cannot
store the refcnt itsef but has to store a pointer to an externally
allocated (shared) refcnter. The changes to lmsg are reverted to
use content_t again. Howver, this introduces an allocation in v2_decoder
when creating the message which can be avoided. When allocating the reception
buffer, space is allocated for the maximum number of reference counts
(8192 / max_vsm_size = 8192/64 = 128 zmq:atomic_counter objects). This
increases the buffer by 128*sizeof(atomic_counter) = 128*4 = 512 bytes only.
When creating a message, the refcnt member is set to the address of one of the
pre-allocated atomic_counter_t objects. To do so, a new msg_t type zcmsg
is introduced because msg::copy must discriminate between the message types
when releasing memory.
2015-06-14 13:35:33 +02:00
Jens Auer
dfe1908008 Fixed wrong buffer end detection in v2_decoder.
zero-copy msg_t::init cannot be used when the message exceeds either
the buffer end or the last received byte. To detect this, the buffer
is now resized to the numnber of received bytes.
2015-06-14 13:35:23 +02:00
Kapp Arnaud
8ffd723271 Probably fix build issue on Solaris.
See #1220 recent comments. This change is untested yet seems
safe.
2015-06-13 22:08:14 +02:00
Min RK
158d77d63e don't check POLLOUT for single-socket proxies 2015-06-06 21:05:32 -07:00
Kapp Arnaud
c35971a603 Fix initialization order.
Fixes #1431.
2015-06-07 02:21:32 +02:00
Richard Newton
dc949624e1 Handle infinite hwms properly 2015-06-05 19:06:36 +01:00
Richard Newton
15eecf4cf4 Update high water marking to allow changing high water mark after connection established. 2015-06-05 17:14:55 +01:00
Richard Newton
9f8b8af926 Fail ZMQ_SNDHWM and ZMQ_RCVHWM setsockopt if already connected. 2015-06-05 10:43:40 +01:00
Jens Auer
e9b403a7b1 zero-copy message receive
Construct messages from a reference-counted buffer allocated once
per receive instead of copying the data.
2015-06-03 23:03:14 +02:00
Jens Auer
611e96c701 Allocation-free msg::init_data
With a msg_t size of 64 bytes, it becomes possible to embedd the content_t's members
struct for large messages directly in the msg_t. This saves the dynamic allocation
of content_t obejcts when using msg_t::init_data.

content_t contains a zmq::atomic_counter_t object which is not a POD in C++98
and thus it cannot be used as a member of the union u. To bypass this, C++11
is used which has relaxed rules for POD and atomic_counter is a C++11-POD. An
alternative would have been to make atomic_counter a classical POD by removing
constructors and all private member functions, i.e. have a struct and free functions
to manipulate it.

A new msg_t::init function is added which decides to either to copy the data for size<64 bytes
or use msg_t::init_data to do zero-copy initialization.
2015-06-03 22:44:33 +02:00
Pieter Hintjens
a07244cda2 Merge pull request #1414 from hintjens/master
Problem: source file headers are somewhat confusing about LGPLv3
2015-06-02 23:40:52 +02:00
Pieter Hintjens
8620c3e032 Problem: source file headers are somewhat confusing about LGPLv3
Of course people still "can" distributed the sources under the
LGPLv3. However we provide COPYING.LESSER with additional grants.

Solution: specify these grants in the header of each source file.
2015-06-02 22:33:55 +02:00
ALEKSANDR MELNIKOV
1eb8e2a69f HPUX build and gmake check issues solution (#1412) 2015-06-02 20:17:15 +06:00
Rik van der Heijden
aa2e74c2a2 Fix another degradation, CPU maxes out when POLLOUT is set because poll exits on POLLOUT and doesn't wait for POLLIN. 2015-05-27 14:27:53 +02:00
Rik van der Heijden
ae630cf3eb Fix degradation from #1382, POLLOUT was tested but not requested 2015-05-24 22:39:36 +02:00
Constantin Rack
8a3296c1aa Solution: add missing brackets 2015-05-23 23:18:10 +02:00
Brian Knox
537626258f remove temp printf from stream_engine 2015-05-19 09:38:53 -04:00
Peter Korsgaard
e89577d30c libzmq: Fix pkg-config files for static linking
Libzmq uses C++ standard library features, so users of it should link
against that as well when statically linking.

Add it to Libs.private so users using pkg-config automatically gets the
correct linker flags.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2015-05-13 08:01:34 +02:00
Pieter Hintjens
eead3bc661 Merge pull request #1388 from rikvdh/issue-1382
Fix for issue #1382
2015-05-01 11:18:56 +02:00
Rik van der Heijden
7b9e9b838d Issue #1382: Do not send data to backend when there are no listeners (+ tests) 2015-05-01 10:39:29 +02:00
Martin Hurton
2e06737bf4 pub: Don't delay pipe termination 2015-04-28 07:48:54 +02:00
Martin Hurton
09a65c5598 push: Don't delay pipe termination 2015-04-28 07:48:04 +02:00
somdoron
c2dcc80602 change minimum version to windows vista and implement dummy condition variable for lower versions 2015-04-26 09:16:01 +03:00
evoskuil
30bd7c481e Fix integer narrowing issues. 2015-04-21 22:26:32 -07:00
Pieter Hintjens
594e3dcceb Problem: shutdown asserts if WSASTARUP wasn't done previously
This is a silly assertion that causes problems if libzmq.dll is
called in some esoteric ways.

Solution: if the shutdown code detects WSANOTINITIALISED, then
exit silently.

Fixes #1377
Fixes #1144
2015-04-20 12:53:37 +02:00
Pieter Hintjens
f053854e51 Merge pull request #1360 from hurtonm/master
Adjust number of sent messages on hiccups
2015-02-19 22:09:58 +01:00
Martin Hurton
5ed6ac60e2 Adjust number of sent messages on hiccups
Not adjusting the sent message count may lead to situation when SUB
socket does not forward its subscriptions.
2015-02-19 21:47:26 +01:00
Thomas Rodgers
700f7bfede resolve #1347 addresses issue of no metadata on identity frame 2015-02-19 13:22:32 -06:00
Thomas Rodgers
4b948b1f3b Code cleanup 2015-02-18 21:24:57 -06:00
Thomas Rodgers
cf0804bb7c Remove unused include 2015-02-18 21:10:50 -06:00
Thomas Rodgers
638ddeb404 resolve #1347 Support limited metadata for STREAM sockets 2015-02-18 12:28:58 -06:00
evoskuil
bc53d710ff Fix error return for clock_gettime. 2015-02-13 23:10:39 -08:00
evoskuil
a8f11b3c3d Add clock_gettime implementation for OSX. 2015-02-13 22:50:28 -08:00
somdoron
deaa89656f thread safety bug - lock when sending 2015-02-13 09:30:29 +02:00
somdoron
5a897f7509 allocate reaper_signal only when needed 2015-02-12 20:42:31 +02:00
somdoron
6749c9b3eb thread safety 2015-02-12 18:54:22 +02:00
evoskuil
2fd2fca531 Make implicit cast explicit. 2015-02-11 13:10:55 -08:00
evoskuil
6724f41427 Fix forcing to bool. 2015-02-11 13:09:25 -08:00
evoskuil
1a0d134666 Add missing EOL at EOF. 2015-02-04 16:27:57 -08:00
somdoron
862cd41c65 implement client socket type and drop messages when more flag is set on client and server 2015-02-02 11:59:13 +02:00
somdoron
5632b57b4a adds server socket type and routing id to msg 2015-02-02 01:17:37 +02:00
Thomas Rodgers
937d485e74 Add cast to make Clang happy 2015-01-28 16:38:14 -06:00
Thomas Rodgers
e6c45f5376 Support using compielr intrinsics for atomic operations
Works with GCC and most likely clang
2015-01-28 10:27:15 -06:00
Thomas Rodgers
d8c15cf43b Code cleanup - removing unused local 2015-01-27 12:40:35 -06:00
Thomas Rodgers
1c72bf4e55 Clean up of metadata_t
* There is no clear reason why the map should hold const std::strings
* This class is never derived, there doesn't seem to be a compelling
  reason to ever do so, so no need to make virtual members
* In general const member data is an anti-pattern, the *only* reason
  is to prevent assignability, and the accepted idiom for that is to
  to declare the assigment operator private. This change does so, and
  also prevents copy construction.
2015-01-27 09:33:47 -06:00
Julien Ruffin
cf2238f80e Added socket option ZMQ_INVERT_MATCHING.
ZMQ_INVERT_MATCHING reverses the PUB/SUB prefix matching. The subscription
list becomes a rejection list. The PUB socket sends messages to all
connected (X)SUB sockets that do not have any matching subscription.

Whenever the option is used on a PUB/XPUB socket, any connecting SUB
sockets must also set it or they will reject everything the publisher
sends them. XSUB sockets are unaffected because they do not filter out
incoming messages.
2015-01-26 17:59:43 +01:00
Constantin Rack
4ad2edff38 Merge pull request #1322 from hintjens/master
Problem: commit afb24b53 broke ZMQ_STREAM contract
2015-01-23 18:03:10 +01:00
Pieter Hintjens
6ced7027a0 Problem: commit afb24b53 broke ZMQ_STREAM contract
Symptom is that ZMQ_STREAM sockets in 4.1.0 and 4.1.1 generate zero
sized messages on each new connection, unlike 4.0.x which did not do
this.

Person who made this commit also changed test cases so that contract
breakage did not show. Same person was later banned for persistently
poor form in CZMQ contributions.

Solution: enable connect notifications on ZMQ_STREAM sockets using a
new ZMQ_STREAM_NOTIFY setting. By default, socket does not deliver
notifications, and behaves as in 4.0.x.

Fixes #1316
2015-01-23 15:25:40 +01:00
Constantin Rack
0d9852a2a5 Merge pull request #1321 from hintjens/master
Problem: copyright statements are out of date
2015-01-22 10:49:56 +01:00