Commit Graph

58 Commits

Author SHA1 Message Date
hjp
bbece557c9 Fix copy/paste error (#2070) 2016-07-31 00:50:07 +01:00
Peter J. Holzer
e175fe21e5 Avoid race condition with accept4 where available
Linux provides accept4(2) which will return a socket with FD_CLOEXEC set
when called with the SOCK_CLOEXEC flag. So call this when available and
fall back to fcntl(..., FD_CLOEXEC) if not.
2016-07-30 21:45:30 +02:00
Luca Boccassi
0dede9b50b Problem: std:vector.data breaks compat with C++98
Solution: use buffer address instead
2016-06-09 23:54:29 +01:00
Luca Boccassi
d570f57b6e Problem: ipc://* random dir created with USE_FD
Solution: if options.use_fd do not create temporary random
directory for ipc://*, since the socket is already created and
passed to the library by the user.
2016-04-11 00:18:51 +01:00
Luca Boccassi
f18463f323 Problem: mkdtemp not available on all platforms
Solution: check for availability in autoconf and cmake, and if not
available fall back to random file name rather than random directory.
2016-04-11 00:18:51 +01:00
Suudy
b6080a798c Updated handling of Unix Domain Sockets, make use of temporary directories, and cleanup afterward. Fix test_term_endpoint handling of optvallen 2016-03-14 12:17:49 -07:00
Steven Chamberlain
dd8ccd5e0f include sys/ucred.h for struct ucred
Platforms that have struct ucred, typically declare it in sys/ucred.h
2016-02-28 20:42:54 +00:00
Osiris
4a5af9d58b Problem: Precompiled headers not being used
Solution: Phase I - make precompiled.hpp be first file included in every source file
2016-02-18 10:56:52 -06:00
Luca Boccassi
edc4ee03e8 Problem: ZMQ_USEFD does not follow conventions
Solution: rename socket option (and variables and files) from usefd
to use_fd.
2016-02-09 09:36:14 +00:00
Luca Boccassi
c158178798 Problem: ZMQ_PRE_ALLOCATED_FD is too long
Solution: rename socket option (and variables and files) from
pre_allocated_fd to usefd.
2016-02-08 22:46:34 +00:00
Luca Boccassi
9b885b7c00 Problem: cannot use new pre-allocated FD with IPC
Solution: parse the value set by the ZMQ_PRE_ALLOCATED_FD sockopt
when creating a new IPC socket and use it if valid.
Add new tests/test_pre_allocated_fd_ipc.cpp unit test.
2016-02-04 16:57:26 +00:00
Constantin Rack
a539b0c6e8 Problem: copyright year is still 2015
Solution: update to 2016
2016-01-28 15:07:31 +01: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
Pieter Hintjens
94d9a4ffdf Problem: copyright statements are out of date
Solution: update for 2015

Fixes #1320
2015-01-22 10:32:37 +01:00
Rodrigo Mosconi
3a16b0b108 Merge remote-tracking branch 'upstream/master' 2014-07-02 21:22:51 -03:00
Rodrigo Mosconi
51b3fad8ab Fix to build on OpenBSD 2014-07-02 21:06:33 -03:00
Jan Kryl
48b37f217f sockets created by accept are leaked to child processes (ticket #956) 2014-04-02 12:25:40 -04:00
Pieter Hintjens
b3b9e046ee Updated copyright statements for 2014 2014-01-02 12:00:57 +01:00
Pieter Hintjens
bf3702395c Fixed wildcard IPC endpoint and added test case 2013-12-20 14:28:54 +01:00
Pieter Hintjens
8ba1311e34 Fixed use of deprecated tempnam 2013-12-19 21:06:32 +01:00
Brandon Carpenter
af808203d7 Fix failing test case in test_filter_ipc.
Add explicit check for primary group.
2013-12-06 00:46:14 -08:00
Brandon Carpenter
8662f44efa Intial IPC accept filter support.
Adds sets of process (Linux only), user, and group IDs for filtering
connections from peer processes over IPC transport.  If all of the
filter sets are empty, every connection is accepted.  Otherwise,
credentials for a connecting process are checked against the filter sets
and the connection is only accepted if a match is found.

This commit is part of LIBZMQ-568 and only adds the filter sets and
implements the filter in the IPC accept method.  The interface for
adding IDs to filter sets are included in a separate commit.

IPC accept filtering is supported only on Linux and OS X.
2013-12-04 14:12:29 -08:00
xinchuan
38327927ce fix memory leak in tempnam() usage 2013-06-15 16:11:50 +08: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
Martin Hurton
4eecda8af3 Implement ZMTP/3.0 PLAIN mechanism
This implements protocol handshake.
We still need to design and implement 1) API changes so a user
can set username and password, and 2) a mechanism for engine
to authenticate users.
2013-05-14 11:20:13 +02:00
Pieter Hintjens
f0f16505e5 Removed corporate advertisements from source file headers
Copyrights had become ads for Sustrik's corporate sponsors, going against the original
agreement to share copyrights with the community (that agreement was: one line stating
iMatix copyright + one reference to AUTHORS file). The proliferation of corporate ads
is also unfair to the many individual authors. I've removed ALL corporate title from
the source files so the copyright statements can now be centralized in AUTHORS and
source files can be properly updated on an annual basis.
2013-03-12 13:24:57 +01:00
Charles McGarvey
ba3e18f700 define a dummy EPROTO for platforms that don't use it
This accomplishes the same thing as 2e2ef7fd in a potentially cleaner way.
2013-01-21 17:14:26 -07:00
Charles McGarvey
2e2ef7fd33 do not use EPROTO on platforms that do not have it 2013-01-21 15:00:55 -07:00
Lourens Naudé
6d245eb6bc Copy monitor specific event endpoints to event messages as the engine etc. can be released at anytime 2012-11-17 11:29:47 +00:00
Michel Pelletier
b84d0119b5 Ported from libxs revision 123c0f5387ecef287dd11f4dc790fb76ee1c0f67
Handle insufficient resources on accept() decently

    If accept() call fails due to insuffient OS resources
    the new connection is rejected.
2012-09-30 11:52:43 -07: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
Lourens Naudé
9dc248f6ab Fix invalid address metadata for ZMQ_EVENT_DISCONNECTED 2012-08-04 11:41:33 +01:00
Martin Hurton
62b5b914f5 Always mark socket as retired when closing ipc_listener
When closing an ipc listener, the library may try to unlink
the associated file. When this fails, the underlying
socket is not marked as retired and this triggers
assertion failure.

Fixes issue #397
2012-07-13 15:46:05 +02:00
Martin Hurton
c84ca01e95 Be more conservative about when to generate ZMQ_EVENT_CLOSE_FAILED
This also fixes a bug in tcp_connecter and tcp_listener, which
generated the event not when they failed to close the socket but
when the succeed to close it.
2012-07-11 19:02:31 +02:00
Martin Hurton
75d67286cc {tcp|ipc}_listener: close socket when set_address () fails 2012-06-13 14:49:43 +02:00
Ian Barber
bdd4e1351d Revert "Revert "Merge branch 'master' of github.com:zeromq/libzmq""
This reverts commit dde69fb9fb.
2012-06-12 14:28:32 +01:00
Ian Barber
dde69fb9fb Revert "Merge branch 'master' of github.com:zeromq/libzmq"
This reverts commit 7b10586558, reversing
changes made to 3345902979.
2012-06-12 14:12:03 +01:00
Martin Hurton
3ec8e576d9 Fix race conditions in {tcp,ipc}_connecter
Once the object has been terminated, it is unsafe for this object
to refer to its parent.

The bug was responsible for occasional
test_shutdown_stress failures.
2012-06-12 01:47:31 +02:00
AJ Lewis
97c48ccda6 Fix build on HPUX 11iv3
The socket length variable for getsockname and accept must be an
(int *) instead of a (socklen_t *) on HPUX.

Signed-off-by: AJ Lewis <aj.lewis@quantum.com>
2012-06-05 09:44:02 -05: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
Sergey KHripchenko
057fab09a8 fixes for zmq_unbind() / zmq_disconnect() usage corner cases
1. when we call zmq_bind()/zmq_connect() to create endpoint
we send ourselfs(through launch_child()) command to process_own(endpoint)
(and add it to own_t::owned)
in the application thread we could call zmq_unbind() / zmq_disconnect() _BEFORE_
we run process_own() in ZMQ thread and in this situation we will be unable to find it in
own_t::owned. in other words own_t::owned.find(endpoint) will not be deleted but it will be deleted from
socket_base_t::endpoints.

2. when you zmq_unbind() the lisnening TCP/IPC socket was terminated only in destructor...
so the whole ZMQ_LINGER time listening TCP/IPC socket was able to accept() new connections
but unable to handle them.

this all geting even worse since unfortunately zmq has a bug and '*_listener_t' object not terminated
untill the socket's zmq_close().
AT LEAST FOR PUSH SOCKETS.
Everything is ok for SUB sockets.

Easy to reproduce without my fix:

zmq_socket(PUSH)
zmq_bind(tcp);
// connect to  it from PULL socket
zmq_unbind(tcp);

sleep(forever)

// netstat -anp | grep 'tcp listening socket'

With my fix you could see that after zmq_unbind(tcp) all previously connected tcp sessions
will not be finished untill the zmq_close(socket) regardless of ZMQ_LINGER value.

(*_listener_t terminates all owned session_base_t(connect=false) and they call pipe_t::terminate()
which in turn should call session_base_t::terminated() but this never happens)
2012-04-21 18:56:10 +04:00
Sergey KHripchenko
7b8e728e43 implement zmq_unbind(),zmq_disconnect(), zmq->sock->getsockopt(ZMQ_LAST_ENDPOINT_ID) 2012-04-18 23:42:11 +04:00
Rob Gagnon
3aabbbaefa Fix IPC transport domain socket stream file not being removed when connection is closed 2012-03-01 21:49:46 +00:00
Mikko Koppanen
d00d4843be More fixes for ZMQ_LAST_ENDPOINT. Added a test 2012-02-18 20:44:41 +00:00
Mikko Koppanen
56aa49ff3d Fix build on solaris 2012-02-17 21:45:17 +00:00
Staffan Gimåker
b9fb48f47b Resolve addresses in the calling thread on connect.
This allows us to actually report an error to the caller on resolve
failure, rather than asserting later on in the io thread.

Signed-off-by: Staffan Gimåker <staffan@spotify.com>
2012-02-16 14:42:55 +01:00
Ian Barber
b5d3373905 Moving to std::string in options 2012-02-14 23:10:06 +00:00
Ian Barber
770f84331f Allowing value 0, and moving code to get_address functions based on feedback 2012-02-11 15:09:03 +00:00
Ian Barber
7b32c9cb51 Adding ZMQ_LAST_ENDPOINT for wildcard support on TCP and IPC sockets 2012-02-08 22:06:46 +00:00
Martin Sustrik
8e21d64c97 Copyright dates adjusted to reflect reality
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
2011-11-01 18:06:11 +01:00