Commit Graph

328 Commits

Author SHA1 Message Date
E. G. Patrick Bos
9fbfa40bab Problem: when linking to libzmq in my project, I want zmq symbols to remain invisible to users of my library. There is no way to control this, since visibility is set automatically through ZMQ_EXPORT based on OS and compiler.
Solution: add a preprocessor variable ZMQ_NO_EXPORT that, when set, bypasses the automatic ZMQ_EXPORT determination block and just sets ZMQ_EXPORT to empty.

By combining this solution at configuration time with manually passing -fvisibility=hidden to CXXFLAGS, I solved my visibility problem. Just passing -fvisibility=hidden is not enough, because __attribute__ ((visibility ("default"))) has higher priority.
2021-10-07 10:48:58 +01:00
E. G. Patrick Bos
36e4c9b474
add zmq_ppoll
zmq_ppoll mostly mimics zmq_poll behavior, except for the added feature of being able to specify a signal mask. Signals in this mask will be blocked during execution of zmq_ppoll. Switching of the process' active signal mask happens atomically with the actual poll call, so that no race conditions can occur. This behavior is useful when one wants to gracefully handle POSIX signals without race conditions. See e.g. the discussion below https://250bpm.com/blog:12/ for an explanation.

Also includes two new tests:
1. test_zmq_ppoll_fd does the same thing as test_zmq_poll_fd, demonstrating backwards compatibility with zmq_poll when used with a default signal mask.
2. test_zmq_ppoll_signals demonstrates the use of zmq_ppoll with a signal mask, blocking out SIGTERM everywhere except in zmq_ppoll, allowing to handle the signal in one place without having to worry about race conditions.
2021-09-24 11:04:20 +02:00
Min RK
bcb659e00e
Problem: calling randombytes_close with libsodium can crash Contexts in other threads (#4242)
* add opt-out for randombytes_close

Problem: randombytes_close is either a no-op or unsafe when a Context is running.

Unfortunately, there does not appear to be a single always correct choice,
so let builders pick between two not-great options.

Opting out can leak an FD on /dev/urandom which may need to be closed explicitly.
However, with the default behavior,
using multiple contexts with CURVE can crash with no application-level workaround available.

randombytes_close is not threadsafe and calling it while still in use by a Context can cause a crash.

For implementations using /dev/[u]random, this can leave up to one leftover FD per process.

The libsodium docs suggest that this function rarely needs to be called explicitly.
2021-08-13 15:11:29 +01:00
Chris Thrasher
4756c04da0 Correct messages about whether or not the draft API is being built
If you cloned and built this repo or built it from a submodule, it
would always report "Build and install draft classes and methods"
which first might be wrong if ENABLE_DRAFTS is OFF but also didn't
match the tense of other similar messages about build options.
2021-08-02 21:13:14 -06:00
Chris Thrasher
4fc83178aa Use standard C11 and C++11
Retain GNU extensions for C99 and C++98 since testing old compilers
is especially difficult and these compilation modes exist to maintain
compatability.
2021-07-01 09:37:02 -06:00
Bill Torpey
ca8e30ed48
fixes for UBSAN warnings (#4223)
Problem: UBSAN shows warnings

Solution: fix alignment issues and signed to unsigned conversion
2021-06-29 13:02:35 +01:00
Chengye Ke
04c37982b1
Support so_busy_poll (#4188)
* Support so_busy_poll.
2021-05-14 23:05:56 +01:00
Luca Boccassi
cef3225370 Problem: 4.3.4 is out, need new version
Solution: bump to 4.3.5
2021-01-17 12:10:01 +00:00
Andy Heroff
2998ff34aa
Problem: No direct support for setting socket priority (#4118)
* Problem: No direct support for setting socket priority

Solution: Add ZMQ_PRIORITY socket option, which sets the
SO_PRIORITY socket option on the underlying socket. This
socket option is not supported under Windows. Check option
and set socket option on creation of underlying socket.
2021-01-06 22:22:41 +00:00
Stanisław Maciaś
26cbd4f43f if_nametoindex function is now used when available 2020-12-23 12:32:16 +01:00
Fabrice Fontaine
8cb5708829 src/compat.hpp: fix build with libbsd and strlcpy
Don't include bsd/string.h if strlcpy is also defined in string.h to
avoid the following build failure on uclibc:

In file included from src/compat.hpp:41:0,
                 from src/ipc_address.cpp:31:
/tmp/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/bsd/string.h:44:54: error: declaration of 'size_t strlcpy(char*, const char*, size_t)' has a different exception specifier
 size_t strlcpy(char *dst, const char *src, size_t siz);
                                                      ^
In file included from src/compat.hpp:34:0,
                 from src/ipc_address.cpp:31:
/tmp/instance-0/output-1/host/mips64el-buildroot-linux-uclibc/sysroot/usr/include/string.h:424:15: error: from previous declaration 'size_t strlcpy(char*, const char*, size_t) throw ()'
 extern size_t strlcpy(char *__restrict dst, const char *__restrict src,
               ^

Fixes:
 - http://autobuild.buildroot.org/results/51220b1b82774e8f6f6ed8593c58d2e3c31a1531

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-11-02 07:58:01 +01:00
Stéphane Valès
86bf83bce8
Problem: cmake generates faulty xcode projects also for dynamic lib (#4042)
* apply the use of sources for xcode project also to dynamic library

Co-authored-by: Stéphane Valès <stephane@vales.fr@users.noreply.github.com>
Co-authored-by: stephane vales <vales@ingenuity.io>
2020-09-16 15:52:18 +01:00
Stéphane Valès
c098fa3c18
Problem: using targets in CMakeLists.txt creates a corrupted xcode project with cmake (#4041)
* use sources instead of objects only when generating an xcode project

Co-authored-by: Stéphane Valès <stephane@vales.fr@users.noreply.github.com>
Co-authored-by: stephane vales <vales@ingenuity.io>
2020-09-16 14:25:46 +01:00
Luca Boccassi
f2e364777e Problem: 4.3.3 is out, need new version
Solution: bump to 4.3.4
2020-09-07 11:12:14 +01:00
Luca Boccassi
a4dbdb614e Problem: some platforms do not have strnlen
Solution: move compat redefinition to compat.hpp header so that
it can be used from msg.cpp
2020-08-21 14:39:08 +01:00
fanquake
c14817075c
build: fix gethrtime() function check in CMake
This looks like a typo introduced by
2d8ef84760.
2020-07-07 21:45:08 +08:00
Bill Torpey
1cfd41c064 update sanitizer support
- enable undefined behavior sanitizer
- force release mode for sanitizer builds
2020-06-29 15:40:20 +01:00
mjvk
b6bb3ef925
Adds NORM support to cmake (#3951) 2020-06-07 10:39:02 +01:00
serg06
c89390f0f5 Make including Clang optional
I include libzmq in my cmake project, and I don't want clang-related targets popping up in Visual Studio's solution explorer.
2020-05-25 18:34:17 +01:00
serg06
2e87390656 Initialize some CMake variables as empty before build
This prevents a bug that occurs when a parent has a `sources` variable when doing `add_subdirectory("libzmq")`.
2020-05-25 18:33:52 +01:00
Bill Torpey
c1d195641d
provide minimal support for TSAN (#3929)
* provide minimal support for thread sanitizer
2020-05-20 20:01:29 +01:00
Bill Torpey
f474b226b6 allow C/C++ standard to be specified at build time, default to C++11 if supported 2020-05-11 16:47:02 -04:00
Doron Somech
3da84c6d06 problem: no thread-safe alternative for ZMQ_PAIR
Solution: create ZMQ_CHANNEL, the thread safe alternative
2020-05-09 08:49:01 +03:00
grmt
718ad8ab96
add wss transport and fix tipc tests when building using cmake on linux (#3857)
* Allow CMAKE to generate ws and wss transports
I guess there is little use of just ws transport, so by default
GnuTLS (and libsodium) are enabled

* cmake libzmq including wss transport (ubuntu 19.10 and ubuntu 19.10 + wsl 1.0)
test_security_fails (libsodium assert !?)

* updated relicense

* make external libs gnutls nss sodium optional

* #ifdef WSS classes and functions, build test*ws* only if correct libs are included, warning if libs not present

* make libsodium optional

* cmake fix tests TIPC transport

* clang-format pointed out a wrongly placed #ifdef

* GnuTLS before 3.6.7 is not safe

* msvc doesn't agree with strlen in array declaration, test_socks now at least compiles on windows

* windows: libsodium build fails, missing include dirs set by env var

* ws transport test only works when GnuTLS is found

* Fixed condition to use NSS / built in SHA1, so that test_ws_transport should now pass, also when GnuTLS is not found
2020-04-13 23:03:19 +01:00
FeRD (Frank Dana)
31569c78d9 Problem: CMake config doesn't support multiarch
Solution: Install CMake config in arch-dependent LIBDIR/cmake

Using "share/cmake/${PROJECT_NAME}" as DESTINATION for installing
ZeroMQConfig.cmake et al works for arch-independent configs, but
is wrong for multiarch. The configs for each version of the
library should be stored below the arch-dependent LIBDIR, using
the GNUInstallDirs ${CMAKE_INSTALL_LIBDIR} variable.

Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
2020-03-16 20:22:52 -04:00
Luca Boccassi
52044b38f7
Merge pull request #3823 from somdoron/ZMQ_PEER
problem: zeromq doesn't has a thread-safe peer to peer socket
2020-02-09 21:53:18 +00:00
Doron Somech
70bc7dd925 problem: zeromq doesn't has a thread-safe peer to peer socket
Solution: a new socket type, called PEER. Very similar to SERVER, but can only connect to other PEERs. Also a new zmq_connect_peer method, that connect and return a routing-id in thread-safe and atomic operation
2020-02-09 23:20:14 +02:00
Luca Boccassi
253e9dd27b Problem: libzmq does not send ZMTP 3.1 sub/cancel commands
Solution: if all peers of a socket are >= 3.1 use sub/cancel commands
instead of the old 0/1 messages.
For backward compatibility, move the handling of 0/1 or sub/cancel
command strings to the encoders, so that the right thing can be done
depending on the protocol version.
Do not set the command flag until the encoder, so that we can handle
the inproc case (which skips the encoder).
2020-02-05 17:03:39 +00:00
Luca Boccassi
06bdebfe8d
Merge pull request #3805 from sigiesec/curve-zerocopy
CURVE: Reduce number of memory allocations and message copies
2020-02-04 08:58:31 +01:00
Simon Giesecke
2fa8185340 Problem: cannot use static libsodium library on Windows
Solution: add CMake option WITH_LIBSODIUM_STATIC
2020-02-03 22:24:16 +01:00
Luca Boccassi
d69f4dc855 Problem: commented out code in CMakeLists.txt
Solution: remove it, never used
2020-02-03 13:40:42 +01:00
Luca Boccassi
75dfbae0d1
Merge pull request #3798 from std-any-emplace/msvc-cmake-clang-buildfix
Add an extra space after "/Z7" in CMakeLists.txt.
2020-01-28 22:34:58 +00:00
std-any-emplace
e29495373e Add an extra space after "/Z7". Else the flag gets joined with the flag following this and clang-cl does not like that. 2020-01-28 21:30:56 +01:00
std-any-emplace
9b66fe2fba Both libzmq and libzmq-static are trying to work in precompiled.pch. Solution: enforce order.
Fixes https://github.com/zeromq/libzmq/issues/3776.
2020-01-28 20:57:53 +01:00
Luca Boccassi
1f00a5bf59 Problem: WS build option is independent of DRAFT
Solution: make the default depend on the value of the DRAFT build flag
2020-01-19 16:36:29 +00:00
Luca Boccassi
2c2ff01e85 Problem: CMake does not look for NSS using pkg-config
Solution: use pkg-config by default and FindPackage only as a
fallback
2019-12-28 21:17:09 +01:00
Luca Boccassi
068385c951 Problem: internal reimplementation of strlcpy used by default on Linux
Solution: use libbsd by default when available, and the internal implementation
only as a fallback, to take advantage of Linux distros maintenance of the
string libraries.
2019-12-28 16:21:06 +01:00
Simon Giesecke
334e837b88 Problem: ws_engine uses unsafe strcpy
Solution: use strcpy_s instead (define custom if not available)
2019-12-25 13:56:26 +01:00
liedtkeInTUM
65d2f1f498 Problem: if IPC enabled libzmq does not compile when in uwp build (#3747)
* Problem: if IPC enabled libzmq does not compile when in uwp build

* Problem 10.0.##### can be valid windows target versions

* Problem: No builds are triggered on uwp platform

* Problem: epoll is set before UWP platform is checked

* Problem: used wrong CMAKE_SYSTEM_NAME specifier

* Problem: build tests fails during cmake configure

* Use Win32 build step for Win32-uwp platform

* Disable compile options that produce warnings that leads to a ci fail

* winnt version is set by cmake, no need for redefinition in windows.hpp

* Eliminate all warning according Incremental and opt:icf are specified

* Prefer to disable opt flags in debug config rather than incremental linking

* CMAKE_GENERATOR should not include uwp definition

* Add release build with uwp configuration

* Problem: pointer potentially uninitialized
2019-12-06 13:27:24 +00:00
Luca Boccassi
a61db18eee Problem: WSS LAST_ENDPOINT returns WS transport
Solution: add wss_address_t subclass of ws_address_t to override the
to_string method
2019-11-28 12:37:53 +00:00
Sven Liedtke
d9d4dbbbd4 Problem: static libs are generated without given basename 2019-11-27 08:28:07 +01:00
Diego Barrios Romero
0bd8f70264 Allow renaming library from the outside 2019-11-13 12:00:47 +01:00
Simon Giesecke
66d0f3511f Problem: ipc transport not supported under Windows
Solution: implement support
2019-10-29 23:04:54 +01:00
somdoron
9be8334938 problem: sha1 external module conflict with czmq
Solution: allow to use external library (nss) for sha1 to avoid the conflict
2019-09-11 15:01:28 +03:00
somdoron
a48fdd6a7f problem: ws_engine doesn't send correct host and path
Solution: extract path and host from the address
2019-09-05 17:33:38 +03:00
Alexander Straub
2ec56d25b6 Safer regex replace, keeping options like "/Zc:twoPhase-" intact 2019-09-04 19:41:34 +02:00
Christoph Schulz
878f1d51f5 Add ENABLE_PRECOMPILED option.
You might want to disable this flag when building with Ninja.
2019-08-21 14:02:31 +02:00
bl
45243cd009 Fix build on SL6.9. Fix #3603. 2019-08-01 05:43:55 +02:00
Rishi Theivendran
afa11b0dfd Copy debug libraries for debug builds 2019-07-18 10:09:25 -04:00
Luca Boccassi
a56d36b8e5
Merge pull request #3587 from somdoron/stream_engine_base
problem: ws_engine duplicate code from stream_engine
2019-07-18 11:57:27 +01:00