Commit Graph

295 Commits

Author SHA1 Message Date
Richard Newton
ccf0e61b77 Merge remote-tracking branch 'upstream/master' 2013-09-10 13:30:11 +01:00
Richard Newton
64e1c181f7 Implement non-blocking shutdown command that unblocks other threads waiting on blocking operations. 2013-09-10 13:30:00 +01:00
Martin Hurton
25c89cace1 Merge pull request #649 from hintjens/master
Fixed minor error in NULL mechanism (spec was wrong)
2013-09-09 12:12:36 -07:00
Pieter Hintjens
6725c4644f Added ZMQ_ZAP_DOMAIN socket option
* This is passed to the ZAP handler in the 'domain' field

* If not set, or empty, then NULL security does not call the ZAP handler

* This resolves the phantom ZAP request syndrome seen with sockets where
  security was never intended (e.g. in test cases)

* This means if you install a ZAP handler, it will not get any requests
  for new connections until you take some explicit action, which can be
  setting a username/password for PLAIN, a key for CURVE, or the domain
  for NULL.
2013-09-09 20:40:34 +02:00
Richard Newton
a601b3f6f4 Remove windows debug code. 2013-09-06 10:25:00 +01:00
Richard Newton
7485b09cba Fix tests on windows 2013-09-06 10:08:11 +01:00
Martin Hurton
498dc37988 Merge pull request #645 from hintjens/master
Updated libzmq to match RFCs
2013-09-06 00:54:51 -07:00
Pieter Hintjens
4c75306023 Fixed test_stream case
- was not looping to read all input from peer
- broke on OS/X specifically
2013-09-06 09:22:09 +02:00
Pieter Hintjens
9dd324aab2 z85 encoding buffer overrun 2013-09-05 15:18:42 +02:00
Pieter Hintjens
32fa426e61 Added system check at start of selftests
- tests that system can provide at least 1,000 sockets
- we could expand on this but this covers the main case of OS/X
  having a too-low default limit of 256 handles per process
2013-09-04 19:38:15 +02:00
MinRK
bb348858f1 mark test_linger as expected failure
rather than pretending it passes
2013-09-04 09:40:08 -07:00
Pieter Hintjens
6612280946 Removed temporary patch on tests/Makefile.am 2013-09-04 18:10:47 +02:00
Pieter Hintjens
28b0a5fa27 Updated libzmq to match RFC 23, 24, 25, 26
* Command names changed from null terminated to length-specified
* Command frames use the correct flag (bit 2)
* test_stream acts as test case for command frames
* Some code cleanups
2013-09-04 17:59:45 +02:00
Pieter Hintjens
1844a27c82 Removed test_raw_sock test case (replaced by test_stream) 2013-09-04 15:00:05 +02:00
Pieter Hintjens
fb67e160a1 Fixed ZAP authentication
- if ZAP server returns anything except 200, connection is closed
- all security tests now pass correctly
- test_security_curve now does proper client key authentication using test key
- test_security_plain now does proper password authentication
2013-09-02 18:21:36 +02:00
Pieter Hintjens
fba5612026 Fixed 'make check' failures
- Split off NULL security check from PLAIN
- Cleaned up test_linger code a little
- Got all tests to pass, added TODOs for outstanding issues
- Added ZAP authentication for NULL test case
- NULL mechanism was not passing server identity - fixed
- cleaned up test_security_plain and removed option double-checks (made code ugly)
- lowered timeout on expect_bounce_fail to 150 msec to speed up checks
- removed all sleeps from test_fork and simplified code (it still passes :-)
2013-09-02 17:22:24 +02:00
Pieter Hintjens
01b336f1f1 Whitespace fixes 2013-09-02 15:08:40 +02:00
Pieter Hintjens
c128fac7a7 Merge pull request #639 from minrk/test_linger
add test_linger
2013-09-02 06:06:58 -07:00
Pieter Hintjens
6fa274ebef Merge pull request #640 from mattconnolly/fork
Adding ability for a context to be terminated in a forked child process
2013-09-02 06:06:31 -07:00
Matt Connolly
1771755888 test_fork.cpp: adding missing headers for linux 2013-09-02 07:13:46 +10:00
MinRK
c646ac96c0 cast rc to size_t for comparisons
avoids -Wall failures comparing int to uint
2013-09-01 13:50:18 -07:00
Matt Connolly
a3d9d01af8 test_fork: update test to verify communication between parent and child 2013-09-01 20:42:19 +10:00
Matt Connolly
0478ee04f4 Adding test showing failure to close socket/context in forked child 2013-09-01 20:42:10 +10:00
MinRK
58b370df69 add test_linger
tests that default LINGER (-1) ensures message delivery.

Note: it fails for large messages ( > 1MB, depending on the system).
2013-08-31 18:27:50 -07:00
MinRK
9d94640edc test failed CURVE auth
adds expect_bounce_fail test function

which is like bounce, but fails if messages arrive.
2013-08-30 17:56:59 -07:00
MinRK
0cac56fe52 test PLAIN auth with failed login
This test fails because PLAIN authentication doesn't actually reject connections
2013-08-30 15:28:16 -07:00
Guido Goldstein
93a068a832 Fixed silly port number. 2013-08-29 20:55:23 +02:00
Pieter Hintjens
2e9385ac02 Merge pull request #631 from jrossi/master
Add the Socket Identity info to the ZAP Messages
2013-08-21 01:35:43 -07:00
Ian Barber
d485404aab Merge pull request #626 from dkrikun/master
Add ZMQ_CONFLATE socket option
2013-08-20 14:37:52 -07:00
Jeremy Rossi
19ca8a0fc0 Add the Socket Identity info to the ZAP Messages
This change adds the socket identity infomartion from the socket to the
zap frames.  In doing this the ZAP is able preform different operations
based on different sockets.  This is not compaitable with the current ZAP
RFC, but that can be updated.  As the ZAP rfc is currently draft for I
did not change the version number.

Tests also modified and passing.
2013-08-20 13:48:05 -04:00
danielkr
3f3777d05b Add test for ZMQ_CONFLATE option 2013-08-19 15:34:11 +03:00
Pieter Hintjens
1011e8ad20 Merge pull request #624 from ricnewton/master
Port tests to windows and add to cmake build.
2013-08-18 00:51:39 -07:00
Uli Köhler
10becae7eb Added zmq_send_const test 2013-08-17 20:37:07 +02:00
Richard Newton
a83baa9b0b Fix up threading code from port tests to windows. 2013-08-17 14:23:22 +01:00
Richard Newton
7f74fc7c99 Port tests to windows and add to cmake build. 2013-08-17 13:43:45 +01:00
Christian Kamm
423ca36b17 Rename ZMQ_REQ_SEND_RESETS -> ZMQ_REQ_STRICT.
It defaults to enabled. Switch it off to be able to send a new message
before the previous reply has been received.
2013-08-03 14:35:18 +02:00
Christian Kamm
a0cc87a9d9 Add ZMQ_REQ_SEND_RESETS option.
This allows making a new request on a REQ socket by sending a new
message. Without the option set, calling send() after the first message
is done will continue to return an EFSM error.

It's useful for when a REQ is not getting a response. Previously that
meant creating a new socket or switching to DEALER.
2013-07-28 11:43:38 +02:00
Christian Kamm
b9646f2aac Add ZMQ_REQ_REQUEST_IDS option.
* Documentation:
The default behavior of REQ sockets is to rely on the ordering of messages
to match requests and responses and that is usually sufficient. When this option
is set to 1, the REQ socket will prefix outgoing messages with an extra frame
containing a request id. That means the full message is (request id, 0,
user frames...). The REQ socket will discard all incoming messages that don't
begin with these two frames.

* Behavior change: When a REQ socket gets an invalid reply, it used to
  discard the message and return EAGAIN. REQ sockets still discard
  invalid messages, but keep looking at the next one automatically
  until a good one is found or there are no more messages.
* Add test_req_request_ids.
2013-07-26 21:38:21 +02:00
Martin Hurton
53bc53da04 Update PLAIN mechanism to the latest ZAP revision 2013-07-18 10:59:34 +02:00
Martin Hurton
d65231be1c Update CURVE mechanism to the latest ZAP revision 2013-07-18 10:59:31 +02:00
Pieter Hintjens
d46c2ee2fc Disabled last step in test_spec_req so build can complete 2013-07-14 13:04:31 +02:00
Christian Kamm
7de23c0c8d Fix intermittent failure in test_spec_req.
There still is a problem when a stale peer's message
arrives at the REQ just after a request was sent to that peer.
2013-07-14 11:57:15 +02:00
Pieter Hintjens
bccf3d6126 Merge pull request #613 from ckamm/coding-style-spec-tests
Fix coding style in spec tests.
2013-07-14 02:32:20 -07:00
Christian Kamm
bbc9a61197 Fix coding style in spec tests. 2013-07-14 08:33:33 +02:00
Christian Kamm
c56d797bf9 REQ sockets drop replies from unasked peers.
* Add lb_t::sendpipe() that returns the pipe that was used for sending,
  similar to fq_t::recvpipe().
* Add forwarder functions to dealer_t to access these two.
* Add logic to req_t to ignore replies on pipes that are not the one
  where the request was sent.
* Enable test in test_spec_req.
2013-07-14 07:55:47 +02:00
Pieter Hintjens
9ca6898f24 Got new test cases working with libzmq
* disabled the specific tests that do not work (yet) on libzmq
* cleaned up one source (test_spec_rep.c) but the others need similar work
* added sleep in test_spec_rep to allow connects time to happen; this would
  not be needed if we connected out to the REP peers instead in from them,
  but I didn't want to change the logic of the test code.
2013-07-07 12:49:24 +02:00
Christian Kamm
dfba19c4b6 Make pipeline/reqrep tests try tcp:// endpoints.
The inproc:// endpoints sometimes use different code paths so
testing with regular tcp:// endpoints as well can show different
issues.
2013-07-05 17:58:01 +02:00
Christian Kamm
8fd163cf5c Add tests for PUSH/PULL sockets. 2013-07-05 15:20:42 +02:00
Christian Kamm
798b394087 Add tests for Request-Reply pattern sockets.
* See http://rfc.zeromq.org/spec:28/REQREP
* Not all testable statements are covered.
* At this point, there are several failures:
  - test_spec_req: The REQ socket does not correctly discard messages
    from peers that are not currently being talked to.
  - test_spec_dealer/router: On disconnect, the queues seem to not be
    emptied. The DEALER can still receive a message the disconnected
    peer sent, the ROUTER can still send to the identity of the dis-
    connected peer.
2013-07-02 15:04:31 +02:00
Richard Newton
998610602e Fix tab/space formatting issue 2013-07-01 12:10:57 +01:00
Richard Newton
f6e972d546 Fix montior tests to handle the monitor stopped event correctly 2013-07-01 10:31:57 +00:00
Martin Hurton
783bb890a9 Check socket types during mechanism handshake 2013-07-01 10:12:08 +02:00
Pieter Hintjens
7041770108 Added Z85 support
The use of binary for CURVE keys is painful; you cannot easily copy
these in e.g. email, or use them directly in source code. There are
various encoding possibilities. Base16 and Base64 are not optimal.
Ascii85 is not safe for source (it generates quotes and escapes).

So, I've designed a new Base85 encoding, Z85, which is safe to use
in code and elsewhere, and I've modified libzmq to use this where
it also uses binary keys (in get/setsockopt).

Very simply, if you use a 32-byte value, it's Base256 (binary),
and if you use a 40-byte value, it's Base85 (Z85).

I've put the Z85 codec into z85_codec.hpp, it's not elegant C++
but it is minimal and it works. Feel free to rewrap as a real class
if this annoys you.
2013-06-28 22:10:22 +02:00
Pieter Hintjens
7832addd20 Updated security mechanisms to use variable-length commands
RFC23, RFC24, RFC26 now use variable-length command names that
end in null octet (valid C strings) instead of fixed-length
space padded strings.
2013-06-28 11:42:54 +02:00
Pieter Hintjens
ad77937956 Added ZMQ_STREAM socket type
- designed for TCP clients and servers
- added HTTP client / server example in tests/test_stream.cpp
- same as ZMQ_ROUTER + ZMQ_ROUTER_RAW + ZMQ_ROUTER_MANDATORY
- includes b893ce set ZMQ_IDENTITY on outgoing connect
- deprecates ZMQ_ROUTER_RAW
2013-06-27 20:53:15 +02:00
Ian Barber
211bf2b08e Added security curve test
Test is skipped if no libsodium.
Added warning if libsodium not configured
2013-06-22 16:17:25 +01:00
Pieter Hintjens
fadfcac1de Fixed compile error, needed unistd.h 2013-06-22 13:50:22 +02:00
Pieter Hintjens
675bd4640b Merge pull request #584 from hurtonm/master
Fix test_disconnect_inproc to work on ILP64 systems
2013-06-22 04:18:27 -07:00
Martin Hurton
1b86324396 Fix test_disconnect_inproc to work on ILP64 systems 2013-06-22 13:05:46 +02:00
Ian Barber
f4c51db842 Fix small streamengine issue w/ term and handshake
Also tidy up monitor test a little.
2013-06-22 10:58:16 +01:00
shripchenko
627190c8be another iteration on ZMQ_PROBE_ROUTER
now it properly works for ROUTER
2013-06-10 02:31:00 -07:00
Pieter Hintjens
6ff51ee909 Updated ZAP request for changed protocol draft
- username and password sent as two string frames
- fixed test case to match
2013-06-07 15:50:36 +02:00
Martin Hurton
2928c91a6d Implement ZAP and integrate it with PLAIN mechanism 2013-06-06 13:28:21 +02:00
Pieter Hintjens
a9679da764 Packaging on ZMQ_PROBE_ROUTER
- renamed to ZMQ_PROBE_ROUTER
2013-06-05 15:55:15 +02:00
Pieter Hintjens
2344131db3 Packaging of ZMQ_PROBE
- Cleaned up man page a little
- Wrote test case tests/test_router_probe.cpp
2013-06-05 15:29:40 +02:00
Pieter Hintjens
c7c865da75 Whitespace fixes 2013-05-21 18:52:44 +02:00
Pieter Hintjens
f06abca046 Disable failing test for now 2013-05-17 17:26:54 +01:00
Pieter Hintjens
f909b9c722 plain_mechanism now uses options.as_server
- we need to switch to PLAIN according to options.mechanism
- we need to catch case when both peers are as-server (or neither is)
- and to use username/password from options, for client
2013-05-17 17:21:59 +01:00
Pieter Hintjens
da1e9a178a Cleaned up test pingpong code 2013-05-17 17:20:33 +01:00
Pieter Hintjens
e1f797b048 Added configuration for PLAIN security
* ZMQ_PLAIN_SERVER, ZMQ_PLAIN_USERNAME, ZMQ_PLAIN_PASSWORD options
* Man page changes to zmq_setsockopt and zmq_getsockopt
* Man pages for ZMQ_NULL, ZMQ_PLAIN, and ZMQ_CURVE
* Test program test_security
2013-05-15 17:55:21 +02:00
Martin Hurton
a7032e9ca8 Update test_raw_sock to work with ZMTP/3.0 2013-04-28 14:13:40 +02:00
Pieter Hintjens
cb2ee7a5c2 Fixed up test_iov case 2013-04-27 14:53:14 +02:00
Jon Dyte
56ead84490 Experimental function zmq_recviov doesnt work correctly in a couple of cases
1) VSM - you cannot hand out the 'data' address as it was not allocated on the heap
2) for other messages the 'data' address cannot be handed out either, as it not the address
originally returned by malloc and hence cannot be passed to 'free'.
see msg.cpp
u.lmsg.content = (content_t*) malloc (sizeof (content_t) + size_);
....
u.lmsg.content->data = u.lmsg.content + 1;

So the function is changed to always malloc a data buffer and copy the data into it.
There is a possible optimisation using memmove for the non-VSM case but that is not done yet.
2013-04-25 21:58:26 +01:00
Pieter Hintjens
257debf659 Removed IPC endpoint from test; not portable, and fragile (#80) 2013-03-24 15:12:34 +01:00
Pieter Hintjens
f1738b9b92 More copyright cleanups 2013-03-12 17:04:51 +01:00
Pieter Hintjens
d826c53b9b Bumped ZMTP revision to 2
* Starting draft ZMTP/2.1 protocol (revision 2)
* Basis for adding security to the wire protocol
* Maintains backward compatibility
2013-03-12 15:49:23 +01:00
Pieter Hintjens
785ef41f67 Refactored codecs to match ZMTP version numbers 2013-03-12 15:29:37 +01:00
Guido Goldstein
b0b8ab27c5 Changed message structure for event notifications. 2013-03-08 13:48:18 +01:00
Guido Goldstein
21eeb03b6c Simplified the zmq_event_t structure for easier access and better usability towards language bindings. 2013-03-08 10:34:25 +01:00
Pieter Hintjens
51cfcb117a Some DNSs will resolve ANY domain name so I made more reliable errors. 2013-02-10 08:39:27 +01:00
montoyaedu
1a13554fe0 solved broken tests compilation 2013-02-07 12:27:33 +01:00
Pieter Hintjens
8ab3c4a1bf Fixed issue #500 2013-01-31 21:52:30 +01:00
Pieter Hintjens
963c6a8e2f Lots of cleanups to self-tests
* Removed or truncated sleeps so the tests run faster
* Removed dependencies on zmq_utils
* Rewrote a few tests that were confusing
* Minor code cleanups
2013-01-31 19:46:22 +01:00
Pieter Hintjens
c39cb0bde1 Rewrote completely, was bogusly testing EAGAIN 2013-01-31 16:26:28 +01:00
Pieter Hintjens
3a558fcc4b Rewrote raw test completely 2013-01-31 15:00:17 +01:00
Pieter Hintjens
8c9289342a Fixed use of deprecated zmq_init/term 2013-01-31 09:10:49 +01:00
Pieter Hintjens
5f009e5234 Various cleanups to test programs 2013-01-30 23:53:23 +01:00
MinRK
edd43e1ca4 deprecate zmq_ctx_destroy in favor of zmq_ctx_term
in order to avoid logical collisions with pre-existing notions of context destruction in bindings (czmq, pyzmq).
2013-01-17 15:48:18 -08:00
Adrian Muraru
35f18aef74 Fixed newline in test_disconnect_inproc 2013-01-12 16:21:56 +02:00
Pieter Hintjens
d997d88096 Revert "Old change to move ports off 5555 (was conflicting with other stuff)"
This reverts commit da0efaa817.
2013-01-08 09:18:38 +01:00
Pieter Hintjens
aff1406713 Revert "Test cases were failing on bind"
This reverts commit 8ba097f3da.
2013-01-08 09:18:23 +01:00
Pieter Hintjens
da0efaa817 Old change to move ports off 5555 (was conflicting with other stuff) 2013-01-08 09:09:27 +01:00
Pieter Hintjens
8ba097f3da Test cases were failing on bind 2013-01-08 09:08:01 +01:00
Min(Dongmin Yu)
a0cecc718d returns -1 with EAGAIN when mandatory is set and pipe is full 2012-12-11 19:41:36 +09:00
Min(Dongmin Yu)
9382941adc returns EHOSTUNREACH when a peer is full if ZMQ_ROUTER_MANDATORY is set 2012-12-08 10:20:42 +09:00
KIU Shueng Chuan
6706efba28 fix wrong boolean operator 2012-12-07 17:45:05 +08:00
Stefan Radomski
66c22456b9 Close pipes for inproc sockets on zmq_disconnect
- fixes LIBZMQ-476 and LIBZMQ-475
2012-12-04 15:14:21 +01:00
Ian Barber
75161b5c62 Serialise test_connect_delay
Simplify the test connect delay test script, removing the threads and
moving to a serialised version. AFAICS this should provide the same
test, but without the race conditions that happened with the previous
test.
2012-11-30 23:07:12 +00:00
Christopher Dolan
6559da3033 Use memset/memmove rather than bzero/bcopy 2012-11-13 19:33:18 +00:00
Martin Hurton
aec47b3642 Extend ZMQ_ROUTER_RAW test
Add test when the zeromq socket connects to a TCP socket.
The test now fails due to bug in the zeromq library.
2012-11-08 19:05:27 +01:00
Pieter Hintjens
777c38ae32 Renamed raw option to ZMQ_ROUTER_RAW 2012-11-06 13:18:58 +01:00
Martin Hurton
9d8eb1f9b9 Style fixes 2012-10-30 12:18:30 +01:00
Martin Hurton
d16e0a5342 Resolve LIBZMQ-458
Ref: https://zeromq.jira.com/browse/LIBZMQ-458
2012-10-30 11:03:43 +01:00
Hardeep
83387b4073 Added support for non-zmq tcp client connections to router socket.
- Created a new option ZMQ_ROUTER_RAW_SOCK
    - Added new raw_encoder and raw_decoder to receive and send messages in raw form to remote client
    - Added test case file tests/test_raw_sock.cpp

    o To create a raw router sock set the ZMQ_ROUTER_RAW_SOCK option
    o ZMQ_MSGMORE flag is ignored for non-id messages
    o To terminate a remote connection send id message followed by zero length data message
2012-10-29 00:03:36 -07:00
Martin Hurton
ef794925b4 Resolve LIBZMQ-452
Ref: https://zeromq.jira.com/browse/LIBZMQ-452
2012-10-25 09:13:48 +02:00
Pieter Hintjens
983ee761b1 Renamed ZMQ_ROUTER_BEHAVIOR to ZMQ_ROUTER_MANDATORY for clarity 2012-10-08 16:36:35 +09:00
Lourens Naudé
8a57e4a5d7 Merge branch 'master' into fix-monitor 2012-09-21 12:55:01 +01:00
Lourens Naudé
759d453368 Significantly reworked the monitoring infrastructure with a more granular per socket API and to play well with monitoring endpoints in application threads 2012-09-21 12:53:31 +01:00
Joshua Gao
67d88bcb41 Add pthread.h include to test_connect_delay.cpp
This test case uses pthreads, but doesn't include the header.
2012-09-18 13:46:48 -07:00
Arthur O'Dwyer
cf20932df0 Add "#undef NDEBUG" to all tests.
This change makes sure that even if the tests are built in a
"release" configuration (with optimizations and NDEBUG turned on),
the assertions won't get compiled out of the tests themselves.

The C standard guarantees that the most recent inclusion of
<assert.h> is the one that counts, so it's important that the
"#undef NDEBUG/#include <assert.h>" come as the last thing in
the block of header files.

"testutil.hpp" includes <assert.h>, so I've left <assert.h> out
of any test that #includes "testutil.hpp", just for the sake of
brevity.
2012-09-06 10:03:12 -07:00
Ian Barber
d7331b7b1f Fixing PGM issues
Hopefully fixed LIBZMQ-427 - there was a slight typo in the init_address
refactor. The encoder refactoring had also broken pgm_sender and
receiver, but just required updating to use the new functions.
2012-09-04 23:24:48 +01:00
Arthur O'Dwyer
08f6a9e7e8 Remove unused argc/argv parameters in tests. 2012-08-27 16:10:47 -07:00
Arthur O'Dwyer
c29aef4dd8 Verify the value of the "void *s" passed to the monitor function.
This formerly unused parameter actually represents the socket
on which the event was received. As such, we should check that
its value makes sense: it must be either "rep" or "req", and in
the case of some kinds of events, it must be specifically one
or the other.

After this change, "s" is no longer unused.
2012-08-27 16:06:51 -07:00
Arthur O'Dwyer
f718d2bead Fix a bug reported on the mailing list.
Both memcmp and strcmp return zero on equal, nonzero on nonequal;
so all of these tests were backwards.

The original committer fixed the failure by comparing 22 bytes instead
of the correct 21, so that the assertions would trigger only if the
22nd byte happened to match exactly --- which was rare.

The correct fix is to compare the right number of bytes with the
right sense.  (I think all of the ".addr" fields are null-terminated,
in which case it's more appropriate to use strcmp throughout.)
2012-08-23 12:56:00 -07:00
Lourens Naudé
9dc248f6ab Fix invalid address metadata for ZMQ_EVENT_DISCONNECTED 2012-08-04 11:41:33 +01:00
Kobolog
08749c8e7b Removed an unneeded include in tests 2012-06-17 02:38:15 +04:00
Kobolog
6da48aed3a Fixed tests 2012-06-17 02:36:08 +04:00
Kobolog
829d0003be Verbose ROUTER socket behavior patch 2012-06-17 02:33:43 +04:00
Ian Barber
c7c834a945 Add unistd header to test_connect_delay header
For sleep and usleep
2012-06-13 12:18:22 +01:00
Ian Barber
35c55a2cde Add newline to end of test_connect_delay file 2012-06-13 07:47:18 +01:00
Ian Barber
e5904e63ce Allow blocking while connect() is completing
This patch, salvaged from a trainwreck accidental merge earlier, adds a
new sockopt, ZMQ_DELAY_ATTACH_ON_CONNECT which prevents a end point
being available to push messages to until it has fully connected, making
connect work more like bind. This also applies to reconnecting sockets,
which may cause message loss of in-queue messages, so it is sensible to
use this in conjunction with a low HWM and potentially an alternative
acknowledgement path.

Notes on most of the individual commits can be found the repository log.
2012-06-12 15:34:48 +01:00
Ian Barber
409d5e8fff Allow blocking while connect() is completing
This patch, salvaged from a trainwreck accidental merge earlier, adds a
new sockopt, ZMQ_DELAY_ATTACH_ON_CONNECT which prevents a end point
being available to push messages to until it has fully connected, making
connect work more like bind. This also applies to reconnecting sockets,
which may cause message loss of in-queue messages, so it is sensible to
use this in conjunction with a low HWM and potentially an alternative
acknowledgement path.

Notes on most of the individual commits can be found the repository log.
2012-06-12 15:31:23 +01:00
Ian Barber
95cbad3841 Revert "After speaking with Ben Gray and the discussion on the mailing list, this is an attempt to create a sockopt to allow connecting pipes to not immediately be available for traffic. The problem is in a PUSH to many PULL situation, where there is a connect to a PULL which is not there. This connect will immediately create a pipe (unlike bind), and traffic will be load balanced to that pipe. This means if there is a persistently unavailable end point then the traffic will queue until HWM is hit, and older messages will be lost."
This reverts commit fe3fb419fe.
2012-06-12 14:53:57 +01:00
Ian Barber
81b8362a59 Revert "Fix a number of whitespace issues in various parts of the code, add validation to most calls on the test and take a first stab at implementing the reconnection pipe blocking."
This reverts commit 6f6466f088.
2012-06-12 14:51:50 +01:00
Ian Barber
6c382c5c61 Revert "Fix whitespace in test"
This reverts commit 0b3478d6ec.
2012-06-12 14:51:19 +01:00
Ian Barber
4aaf3e6389 Revert "Add disconnect test"
This reverts commit d8f3487ee1.
2012-06-12 14:44:12 +01:00
Ian Barber
eb14890d23 Revert "Revert "Merge branch 'master' of github.com:ianbarber/libzmq""
This reverts commit 029d3dfae2.
2012-06-12 14:43:18 +01:00
Ian Barber
029d3dfae2 Revert "Merge branch 'master' of github.com:ianbarber/libzmq"
This reverts commit 3345902979, reversing
changes made to 889b0e6f29.
2012-06-12 14:13:17 +01:00
Ian Barber
6117a2b099 Revert "Replace incomplete count with a std::set"
This reverts commit 4aa5ba3d11.
Unintentional merge
2012-06-12 14:07:54 +01:00
Ian Barber
4aa5ba3d11 Replace incomplete count with a std::set
This commit removes the countdown flag and adds a set to store the pipes
that are currently being disconnected.
2012-06-12 12:13:21 +01:00
Ian Barber
d8f3487ee1 Add disconnect test
Add a new section to the connect delay test that disconnects and
reconnects a socket to ensure that some messages are appropriately
blocked.
2012-06-11 20:04:09 +01:00
Ian Barber
0bf1d0262e Merge branch 'master' of https://github.com/zeromq/libzmq 2012-06-08 23:55:58 +01:00
Hiten P
31cb1f297d Change connection failure test to use an invalid hostname
- invalid hostname set to 0mq.is.the.best (naturally!)
- issue happens as other valid-like non-existent hostnames were
  redirected by buggy Cable/ISP DNS servers
2012-06-08 13:15:45 +01:00
Ian Barber
09d18e4b3c Merge branch 'master' of https://github.com/zeromq/libzmq 2012-06-05 18:32:15 +01:00
AJ Lewis
3687789f9d Fix build on RHEL5 and SLES10
GCC 4.1.2 on RHEL5 and SLES10 don't like not having a newline at the
end of a source file, and error out if it's missing.

Signed-off-by: AJ Lewis <aj.lewis@quantum.com>
2012-06-05 09:22:22 -05:00
Ian Barber
0b3478d6ec Fix whitespace in test 2012-06-03 23:11:08 +01:00
Ian Barber
6f6466f088 Fix a number of whitespace issues in various parts of the code, add validation to most calls on the test and take a first stab at implementing the reconnection pipe blocking.
It didn't seem straightforward to use any of the existing process calls, so I have added a new command to command_t and friends called detach. This instructs the socket_base to remove the pipe from it's pipe list. The session base stores a copy of the outpipe, and will resend the bind command on reconnection. This should allow balancing again.
2012-06-03 22:57:47 +01:00
Ian Barber
fe3fb419fe After speaking with Ben Gray and the discussion on the mailing list, this is an attempt to create a sockopt to allow connecting pipes to not immediately be available for traffic. The problem is in a PUSH to many PULL situation, where there is a connect to a PULL which is not there. This connect will immediately create a pipe (unlike bind), and traffic will be load balanced to that pipe. This means if there is a persistently unavailable end point then the traffic will queue until HWM is hit, and older messages will be lost.
This patch adds a sockopt ZMQ_DELAY_ATTACH_ON_CONNECT, which if set to 1 will attempt to preempt this behavior. It does this by extending the use of the session_base to include in the outbound as well as the inbound pipe, and only associates the pipe with the socket once it receives the connected callback via a process_attach message. This works, and a test has been added to show so, but may introduce unexpected complications. The shutdown logic in this class has become marginally more awkward because of this, requiring the session to serve as the sink for both pipes if shutdown occurs with a still-connecting pipe in place. It is also possible there could be issues around flushing the messages, but as I could not directly think how to create such an issue I have not written any code with regards to that.

The documentation has been updated to reflect the change, but please do check over the code and test and review.
2012-06-01 17:58:19 +01:00
Lourens Naudé
991b7fcc04 Rename zmq_monitor to zmq_ctx_set_monitor for compat with existing context specific APIs 2012-05-22 20:15:18 +01:00
Lourens Naudé
4767159f39 Initial stab at a context level monitor callback and registration API 2012-05-21 20:47:11 +01:00
Lourens Naudé
e13b3723b8 Rename type zmq_monitor_fn -> zmq_monitor for a more natural callback definition API (zmq_monitor type, monitor.function callback) 2012-05-20 18:27:59 +01:00
Lourens Naudé
06cce15479 Change zmq_monitor_fn type to cast between pointer-to-object and pointer-to-function in a more standards compliant way 2012-05-20 18:22:13 +01:00
KennyTM~
c995de6584 Allow the ZMQ_MONITOR code compilable on gcc 4.7 on Linux.
The current ZMQ_MONITOR code does not compile in gcc 4.7, as -pedantic
and -Werror are enabled, and ISO C++ doesn't allow casting between
normal pointers (void*) and function pointers, as pedantically their
size could be different. This caused the library not compilable. This
commit workaround the problem by introducing one more indirection, i.e.
instead of calling

    (void *)listener

which is an error, we have to use

    *(void **)&listener

which is an undefined behavior :) but works on most platforms

Also, `optval_ = monitor` will not set the parameter in getsockopt(),
and the extra casting caused the LHS to be an rvalue which again makes
the code not compilable. The proper way is to pass a pointer of function
pointer and assign with indirection, i.e. `*optval_ = monitor`.

Also, fixed an asciidoc error in zmq_getsockopt.txt because the `~~~~`
is too long.
2012-05-13 20:49:05 +08:00
Lourens Naudé
5c6f72c17c ZMQ_MONITOR socket option registers a callback / event sink for changes in socket state 2012-05-04 02:32:46 +01:00
Martin Hurton
873abdd24c Rename XREP/XREQ to ROUTER/DEALER in tests 2012-04-25 01:05:38 +02:00
Sergey KHripchenko
4f668ad60a added zmq_unbind() / zmq_disconnect() test script.
it works but rises very serious questions.

Please add license header by your choice.
This file for 99% resemble crossroads-io/tests/shutdown.cpp
2012-04-21 18:39:19 +04:00
Pieter Hintjens
f26e4ab784 Simplified zmq_msg_get/set functions
* Return integer property
* Fixed up man pages, which were inaccurate
* Fixed test case
2012-03-21 14:19:40 -05:00
Pieter Hintjens
6e71a54b1e Fixed issues #337, #341, and #340
* Implemented new ctx API (_new, _destroy, _get, _set)
* Removed 'typesafe' macros from zmq.h
* Added support for MAX_SOCKETS (was tied into change for #337)
* Created new man pages
2012-03-19 19:41:20 -05:00
Mikko Koppanen
5d7450d65e Improve the test for last_endpoint, use the same ports as other tests 2012-02-19 23:19:17 -06:00
Ian Barber
5e1efc9ec3 Update documentation for last endpoint to mention inaddr_any and add a test for IPC last endpoint checking 2012-02-19 18:46:46 +00:00