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

556 Commits

Author SHA1 Message Date
Chia-liang Kao
a2500ae348 Fix a bug that zmq_poll's select backend spins when timeout=-1, due to
ptimeout not properly recalculated after first pass.

Signed-off-by: Chia-liang Kao <clkao@clkao.org>
2010-11-12 19:16:00 +01:00
Martin Sustrik
8abe67357a Merge branch 'maint'
* maint:
  Fix socket_t::recv() hang scenario where initial call to process_commands() eats signal

Conflicts:
	src/socket_base.cpp
2010-11-12 14:47:26 +01:00
Marc Rossi
f7123de943 Fix socket_t::recv() hang scenario where initial call to process_commands() eats signal
Added block boolean var to second process_commands() invocation for blocking sockets
instead of always using true.  This prevents the process_commands() call from hanging
when a message is received with an empty queue after the call to xrecv() but
prior to the initial call to process_commands() invoked when ++ticks == inbound_poll_rate.

Signed-off-by: Marc Rossi <mrossi19@gmail.com>
2010-11-12 14:38:25 +01:00
Martin Sustrik
c0217027cc Coding style cleanup in mailbox.cpp
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-11-06 08:02:14 +01:00
Martin Sustrik
9da84a5239 signaler renamed to mailbox
For historical reasons queue to transfer commands between
threads was called 'signaler'. Given that it was used to
pass commands rather than signals it was renamed to 'mailbox',
see Erlang mailboxes.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-11-05 17:39:51 +01:00
Martin Sustrik
9cfdb441f4 slots renamed to tids
Threads were so far identified by integers called 'slots'.
This patch renames them to more comprehensible 'tid's (thread IDs).

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-11-05 16:38:52 +01:00
Martin Lucina
1b39bcd883 Automatically resize signalling socket buffer if full
If the socketpair used by signaler_t fills up, this can lead to deadlock.
This patch provides partial resolution by attempting to resize SO_SNDBUF on
the writer side, and if that fails we shall at least assert rather than
hang.

I've also refactored the signaler_t code to make the platform-dependent
parts clearer and have tested both the MSG_DONTWAIT and standard POSIX path
in recv.

The Win32 implementation currently does not implement resizing as I'm not
convinced that it's safe, but it will also assert like other platforms if
signaler_t::send() cannot succeed.

The OpenVMS implementation has been carried forward but is untested.

Signed-off-by: Martin Lucina <mato@kotelna.sk>
2010-11-04 17:54:47 +01:00
Martin Sustrik
756f7df8c8 Previous FD_STSIZE patch reverted.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-11-04 16:11:04 +01:00
Martin Sustrik
2246689c8f FD_SETSIZE for internal polling defaults to 1024
If, when compiling 0MQ you don't set FD_SETSIZE,
it defaults to 1024 rather than to 64.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-11-04 13:12:40 +01:00
Martin Sustrik
b90e621329 minor typo fixed
Devpoll polling mechanism used ZMQ_HAVE_SOLRIS instead of
ZMQ_HAVE_SOLARIS in one case. Fixed.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-11-04 10:01:58 +01:00
Martin Sustrik
d4a41067d3 HP-UX has no OPEN_MAX defined
devpoll_t used this constant to determine how many events to
retrieve from the poller in one go. The implementation was
changed not to depend on this constant.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-11-02 14:27:24 +01:00
Mikael Helbo Kjaer
0ad71f88fe select now uses Erase-Remove idiom for retired fds
Signed-off-by: Mikael Helbo Kjaer <mhk@designtech.dk>
2010-11-01 12:54:58 +01:00
Martin Sustrik
3d8eb071a2 Coding style fixed for pgm_socket
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-30 16:17:08 +02:00
Martin Sustrik
b358df9fff Name of "GNU Lesser Public License" corrected.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-30 15:08:28 +02:00
Dhammika Pathirana
9a1d4df0fd fix typo, destroy new engine
Signed-off-by: Dhammika Pathirana <dhammika@gmail.com>
2010-10-27 09:37:32 +02:00
Dhammika Pathirana
465da7b17e drop connection requests with duplicate peer identity
Signed-off-by: Dhammika Pathirana <dhammika@gmail.com>
2010-10-26 16:02:47 +02:00
Martin Sustrik
401986e6bb Build with MSVC2005 fixed
To use __rdtsc() function MSVC2005 requires including intrin.h

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-26 15:35:56 +02:00
Dhammika Pathirana
71bef330fc handle decoding malformed messages
Signed-off-by: Dhammika Pathirana <dhammika@gmail.com>
2010-10-23 20:59:54 +02:00
Steven McCoy
8d6979922e Changes for MSVC OpenPGM build.
Signed-off-by: Steven McCoy <steven.mccoy@miru.hk>
2010-10-23 14:35:02 +02:00
Martin Sustrik
da59f8dd7a Merge branch 'maint'
* maint:
  SunStudio fixed.
2010-10-23 13:51:12 +02:00
Martin Sustrik
21b0c0b4f7 SunStudio fixed.
With SunStudio's implementation of STL basic_string constructor
doesn't accept NULL as a parameter even though size of string
is set to zero. Fixed.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-23 13:49:13 +02:00
Martin Sustrik
e73c96ba30 Minor comment improvement.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-18 09:11:36 +02:00
Martin Sustrik
a780833683 ZMQ_BACKLOG socket option added.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-17 10:23:58 +02:00
Martin Sustrik
e8e2944f45 ZMQ_RECONNECT_IVL socket options added.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-17 09:54:12 +02:00
Martin Sustrik
8b8837688a Couple of bugs in zmq_poll fixed.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-16 17:56:25 +02:00
Martin Sustrik
72b15a6dae Implementation of zmq_strerror moved from zmq.cpp to err.cpp
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-16 16:05:34 +02:00
Martin Sustrik
61d38fbeed Bug in low precision clock fixed.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-16 14:48:06 +02:00
Martin Sustrik
0a03e86e95 ZMQ_LINGER socket option added.
1. ZMQ_LINGER option can be set/get
    2. options are part of own_t base class rather than being declared
       separately by individual objects
    3. Linger option is propagated with "term" command so that the
       newest value of it is used rather than the stored old one.
    4. Session sets the linger timer if needed and terminates
       as soon as it expires.
    5. Corresponding documentation updated.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-16 10:53:29 +02:00
Toralf Wittner
a1474e3057 Cancel tx_timer_id in pgm_sender_t::out_event().
Signed-off-by: Toralf Wittner <toralf.wittner@gmail.com>
2010-10-16 08:27:57 +02:00
Martin Sustrik
733c6780c5 Minor code clean-up to keep clang compiler happy.
"warning: extra ';' inside a struct or union [-pedantic]"

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-16 01:22:18 +02:00
Martin Sustrik
48b0a901b8 Obsolete compile-time option removed.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-16 00:53:50 +02:00
Martin Sustrik
027eed41b8 Merge branch 'maint'
* maint:
  Fix memory leak under Windows
2010-10-15 17:46:21 +02:00
Taras Shpot
6e95205333 Fix memory leak under Windows
The comment about memory ownership in uuid_t::to_string
was misleading as on most platforms the buffer is a field
of the object;
The string allocated in UuidToString() wasn't properly freed
with RpcStringFree()

Signed-off-by: Taras Shpot <taras.shpot@eleks.com>
2010-10-15 17:45:02 +02:00
Martin Sustrik
7b9e39724e Minor fix in devpoll.hpp
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-15 11:31:20 +02:00
Martin Sustrik
17b0785744 Destructor of poller_base_t made virtual.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-15 11:29:20 +02:00
Mikko Koppanen
3e74a439c4 Cast execute_timers() result to int
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-10-15 11:21:56 +02:00
Martin Sustrik
b64b50ae21 Timers correctly canceled by PGM engines on shutdown.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-15 10:58:19 +02:00
Mikko Koppanen
e33e4d7650 ICC related qualifier fix
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-10-15 10:38:09 +02:00
Martin Pales
03a18c27ac zmq::clock_t : return correct value in rdtsc() on solaris
Function clock_t::rdtsc() now returns correct value when compiled
with sunstudio 12 compiler.

Signed-off-by: Martin Pales <m.pales@gmail.com>
2010-10-14 16:31:58 +02:00
Martin Sustrik
b7386f5b50 To insert to associateive STL containers value_type used instead of make_pair
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-14 12:13:52 +02:00
Martin Pales
f9e6d94be5 zmq::poller_base_t : workaround for sunstudio compiler in add_timer()
A minor workaround to resolve compilation error with sunstudio compiler,
which does not yet support member templates for std::multimap.

Signed-off-by: Martin Pales <m.pales@gmail.com>
2010-10-14 12:02:05 +02:00
Martin Sustrik
cafcdbbe2b Safety measure in zmq_msg_close implemented
zmq_msg_close now empties the message on zmq_msg_close, thus not
leaving random data in the structure, that may be mistaken for
a valid message.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-14 09:34:09 +02:00
Martin Pales
da73b7c6f6 zmq::devpoll_t : correct a typo in loop()
A minor typo correction to resolve compilation error on Solaris.

Signed-off-by: Martin Pales <m.pales@gmail.com>
2010-10-14 08:38:11 +02:00
Martin Sustrik
e2167cecae Precise timouts in zmq_poll implemented
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-13 21:39:20 +02:00
Martin Sustrik
9d96e0037a Clean-up of the code related to attaching/detaching engines to sessions.
Session base class now handles the engine events exclusively. It notifies
derived session types using dedicated "attached" and "detached" events.

Couple of bugs was fixed along the way.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-13 10:09:46 +02:00
Martin Sustrik
954d7f743d Avoid duplicate creation of pipes for a single session
When a session is being closed down its inbound and outbound
pipe pointers are set to null. If (re) connection happens at
that time, session may try to reinistantiate the pipes which
is wrong. This patch allows session to attach pipes only once
in its lifetime.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-12 17:55:09 +02:00
Steven McCoy
c6d74e0a03 Drop PGM parameters to 100mb friendly range.
Signed-off-by: Steven McCoy <steven.mccoy@miru.hk>
2010-10-12 12:26:21 +02:00
Steven McCoy
5b8af52efc Fix assertion in PGM transports on cancel_timer
Signed-off-by: Steven McCoy <steven.mccoy@miru.hk>
2010-10-11 17:59:58 +02:00
Martin Sustrik
f22e85f19f Reverting commit 1d431190f50c86f62460
The patch was supposed to check that pipe writer sends messages
in atomic fashion. However, it prevented the user to read
half of a message and close the socket.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-11 12:23:18 +02:00
Martin Sustrik
73e7ef37c2 When XREP silently drops message, it does not empty it -- fixed
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-10 09:23:37 +02:00
Christian Gudrian
f5030a93a5 Execute the timers before pollset initialisation.
Since executing the timers might modify the source pollsets we have
to defer the initialisation until after the timers have executed.

Signed-off-by: Christian Gudrian <christian.gudrian@fluidon.com>
2010-10-09 19:19:50 +02:00
Martin Sustrik
318cdd1f24 Merge branch 'maint'
* maint:
  Version macros added

Conflicts:
	builds/msvc/platform.hpp

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-09 08:03:58 +02:00
Martin Sustrik
ef8db789a1 Version macros added
Macro ZMQ_VERSION represents the current version of 0MQ
Macro ZMQ_MAKE_VERSION(major,minor,patch) allows to create
a representation of the specified version.
The versions can be compared using simple <, >, ==, etc.
operators.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-09 07:53:24 +02:00
Martin Lucina
214b56077a Fix missing platform.hpp in zmq_connecter.cpp
Missed testing on Win32

Signed-off-by: Martin Lucina <mato@kotelna.sk>
2010-10-08 22:06:41 +02:00
Martin Sustrik
daf5d3273b More cleanup of session termination process.
Fix in termination of session attached to a REP socket.
Several fixes of session termination in case of disconnection.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-08 21:42:55 +02:00
Martin Lucina
f90c8d957e Scalability improvements for large amounts of connections
Add signaler_sndbuf_size option to config.hpp which allows the user to
increase the size of the send buffer used by the signalling socketpair.

Implement random backoff for reconnection attempts using a primitive
pseudo-random generation to prevent reconnection storms.

Add wait_before_connect option to config.hpp to allow the user to enable
random delay even on initial connect. Default is false for low latency.

Signed-off-by: Martin Lucina <mato@kotelna.sk>
2010-10-08 17:49:40 +02:00
Martin Sustrik
7a685b0f88 Clean-up of session termination process
Specifically, shutdown of child objects is initiated *before* termination
handshake with socket object.

Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2010-10-08 17:23:21 +02:00
Nir Soffer
1d431190f5 make sure that reader does not terminate in the middle of a multipart message 2010-10-02 10:01:18 +02:00
Martin Sustrik
2142b8918a issue 92 -- Assertion failed: inpipe && outpipe (pair.cpp:86) -- fixed 2010-10-01 18:46:32 +02:00
Martin Sustrik
2a85cce189 Merge branch 'master' of github.com:zeromq/zeromq2 2010-10-01 13:37:59 +02:00
Martin Sustrik
0bb76b667b assert when xrep socket gets reconnected in the middle of the shutdown -- fixed 2010-10-01 13:37:46 +02:00
Martin Lucina
8f9080ebb9 zmq_poll(): Fix busy-loop if timeout is zero
Fix a case where zmq_poll() (poll-based version) could go off into a busy-loop
if no revents are returned and the timeout passed in is zero.
2010-09-30 15:30:24 +02:00
Martin Sustrik
ac9b05c36b Merge branch 'maint'
* maint:
  zmq_msg_move called on uninitialised message in xrep_t::xrecv -- fixed
2010-09-30 15:12:06 +02:00
Max Wolf
79aea5ffa6 zmq_msg_move called on uninitialised message in xrep_t::xrecv -- fixed 2010-09-30 15:10:47 +02:00
Martin Sustrik
98fa2fa802 fix in XREP's fair queueing mechanism 2010-09-30 14:03:54 +02:00
Martin Sustrik
7881ba1bcd minor whitespace fix 2010-09-30 11:35:14 +02:00
Steven McCoy
eaa925eca7 FreeBSD doesn't define MSG_ERRQUEUE -- now it's defined in 0MQ 2010-09-30 11:33:35 +02:00
Steven McCoy
d14be62499 more fixes to (e)pgm transport 2010-09-30 09:11:51 +02:00
Steven McCoy
96d85b2098 * Add assertions to check for OpenPGM calls with invalid parameters.
* Assertion to check that pgm_getaddrinfo is actually returning something.
 * Missing pgm_connect call.
 * Typo on TOS causing immediate abort.
 * Placeholder calls for timeouts whilst continuing spin loop functionality.
 * OpenPGM v5 now supports reference counting so remove init checks.
 * Duplicate UDP unicast port setting, requires one unicast and one multicast.
 * Incorrectly set socket rcvbuf size with sndbuf.
 * Replace std::lexicographical_compare of TSI's with long word integer comparisons.
 * pgm_socket_t::receive returns -1 on no data.
2010-09-30 09:11:19 +02:00
Steven McCoy
00cd7d49c7 Upgrade to OpenPGM-5.0.78 2010-09-28 16:35:29 +02:00
Gonzalo Diethelm
87beaaa00d ZMQ_TYPE socket option added 2010-09-28 15:27:45 +02:00
Martin Sustrik
6715f9b185 Merge branch 'maint'
* maint:
  crash when closing an ypipe -- fixed
2010-09-28 07:51:59 +02:00
Dhammika Pathirana
c1deb226f4 crash when closing an ypipe -- fixed 2010-09-28 07:46:17 +02:00
Martin Sustrik
f61921d096 REQ socket can die when reply is delivered on wrong unerlying connection -- fixed 2010-09-28 07:39:16 +02:00
Martin Sustrik
16c3884a61 MSVC build fixed 2010-09-27 11:18:21 +02:00
Martin Sustrik
30c1cba4e4 latency optimisation for the case where there are no timers 2010-09-27 09:34:00 +02:00
Martin Sustrik
238640a526 timers properly implemented 2010-09-26 21:42:23 +02:00
Martin Sustrik
8d7bf6684c common base for all pollers created; the only thing it handles at the moment is 'load' 2010-09-26 19:22:33 +02:00
Martin Sustrik
cf815e8c78 new interfaces for timers; the implementation is not changed yet 2010-09-26 18:30:03 +02:00
Martin Sustrik
be79a9fbc2 minor beautifications 2010-09-26 18:01:59 +02:00
Martin Sustrik
5dae27d0ed clock_t class added 2010-09-26 16:55:54 +02:00
Martin Sustrik
7d5061798c Merge branch 'maint'
* maint:
  if TSC jumps backwards (in case of migration to a different CPU core) latency peak may occur -- fixed

Conflicts:
	src/app_thread.cpp
2010-09-26 13:36:05 +02:00
Martin Sustrik
9129b79248 if TSC jumps backwards (in case of migration to a different CPU core) latency peak may occur -- fixed 2010-09-26 13:30:33 +02:00
Martin Sustrik
e478468e52 minor error in comment fixed 2010-09-21 09:10:17 +02:00
Martin Sustrik
9c11886600 The flag in the socket has clear semantics now -- it tracks whether corresponding context was closed, it doesn't track whether zmq_close was called on the socket itself 2010-09-21 09:00:46 +02:00
Martin Sustrik
4d51a52874 zmq_poll (select version) now correctly assumes that ZMQ_FD is edge-trigerred 2010-09-20 17:25:04 +02:00
Martin Lucina
f49b77eedc zmq_poll honours ZMQ_FORCE_POLL and ZMQ_FORCE_SELECT options 2010-09-20 16:55:46 +02:00
Martin Lucina
1abfc92d26 minor problem in zmq_poll (select version) fixed 2010-09-20 16:45:25 +02:00
Martin Sustrik
328c92a0a7 problem with engine being attached to session while it's being terminated fixed 2010-09-20 00:06:05 +02:00
Martin Sustrik
1d2399720b zmq_init_t destroyed zmq_engine_t before plugging it out from the poller first -- fixed 2010-09-19 22:45:48 +02:00
Martin Sustrik
cda3c96a7f minor code reorganisation in ctx_t::terminate 2010-09-19 22:17:37 +02:00
Martin Sustrik
938689a491 synchronisation problem fixed in ctx_t 2010-09-19 21:40:26 +02:00
Martin Sustrik
471013a59f two races fixed in session creation 2010-09-19 20:43:14 +02:00
Martin Sustrik
1f10208ad0 termination of pipe via delimiter message could stuck when no data were read from the pipe (because connection wasn't active) -- fixed 2010-09-19 08:42:19 +02:00
Martin Sustrik
5153b6368b obsolete 'active' flag removed from session_t 2010-09-19 08:39:53 +02:00
Martin Sustrik
4c6d07d366 single term ack counting mechanism for every socket (no separate mechanisms for fq_t and lb_t) 2010-09-18 07:37:36 +02:00
Martin Sustrik
fb6ce536d9 more details on launch_sibling in comments 2010-09-18 06:48:45 +02:00
Martin Sustrik
0c215fada4 potential duplicate termination of pipes removed 2010-09-18 06:42:46 +02:00
Martin Sustrik
c7b9ba3ccd reconnection process fixed when failure occurs during init phase 2010-09-17 12:58:20 +02:00
Martin Sustrik
85aa25e56c bug in REQ+multipart fixed 2010-09-17 12:32:46 +02:00