0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-27 15:41:05 +08:00

52 Commits

Author SHA1 Message Date
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
Jose Santiago
72c8cc3912 Fix Fedora33 s390x build. 2021-02-18 11:05:29 -06: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
Fabrice Fontaine
d59dcbcaeb acinclude.m4: add -latomic to PKGCFG_LIBS_PRIVATE
Add -latomic to PKGCFG_LIBS_PRIVATE so applications linking statically
with libzmq (such czmq) will know that they have to link with -latomic
and the following build failure will be avoided:

  CCLD     src/czmq_selftest
/home/buildroot/autobuild/run/instance-3/output-1/host/opt/ext-toolchain/bin/../lib/gcc/sparc-buildroot-linux-uclibc/7.4.0/../../../../sparc-buildroot-linux-uclibc/bin/ld: /home/buildroot/autobuild/run/instance-3/output-1/host/sparc-buildroot-linux-uclibc/sysroot/usr/lib/libzmq.a(src_libzmq_la-ctx.o): in function `zmq::ctx_t::create_socket(int)':
ctx.cpp:(.text+0x1710): undefined reference to `__atomic_fetch_add_4'

Fixes:
 - http://autobuild.buildroot.org/results/4a12f1ede260cd956a0b5ccb4eec6ca8b44cb04f

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-01-12 10:18:23 +01:00
Alain Kalker
9a397666d2 acinclude.m4, configure.ac: Fix several non-portable uses of test
Fixes #3517
2019-05-22 01:30:54 +02:00
Simon Giesecke
120edd9809 Problem: selection of condition_variable_t implementation is confusing and not configurable
Solution: move configuration to build definition
2019-02-12 03:47:26 -05:00
Luca Boccassi
4a0c83fb12 Problem: yqueue false sharing issues on PPC64
Solution: detect cacheline size for aligment purposes at build time
instead of hard-coding it, so that PPC and S390 can align to a value
greater than the 64 bytes default.
Uses libc getconf program, and falls back to the previous value of 64
if not found.
2019-01-19 20:08:14 +00:00
Fabrice Fontaine
6de5f18be3 fix static build with libatomic
Commit 2ec5a33f6e986661dc92f3585ea400f919a39cae added support to link
with -latomic if needed however using LDFLAGS doesn't work when
statically linking because LDFLAGS is added before LIBS

Detection of atomic fails with:

configure:23230: /accts/mlweber1/instance-2/output/host/bin/sparc-linux-g++ -o conftest -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os   -static -static -pedantic -Werror -Wall -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -Wno-long-long -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -static -latomic conftest.cpp -lrt -lpthread -lstdc++ >&5
/tmp/ccgrvVTg.o: In function `main':
conftest.cpp:(.text.startup+0x10): undefined reference to `__atomic_fetch_add_4'
collect2: error: ld returned 1 exit status

So use LIBS instead of LDFLAGS

Fixes:
 - http://autobuild.buildroot.net/results/c471d6b1061a8516f7772735e471db68a32965aa

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2018-09-13 20:18:37 +02:00
KIU Shueng Chuan
2336e1f170 Problem: not able to use wepoll in configure script
Solution: add wepoll as a polling system
2018-06-03 11:55:26 +08:00
Simon Giesecke
d326434b37 Problem: API poller cannot be set independently from I/O thread poller, poll I/O thread poller broken on Windows
Solution: change platform definitions to separate API poller from I/O thread poller, disallow configuring poll I/O thread poller on Windows
2018-05-22 18:36:04 +02:00
Luca Boccassi
4ff814f204 Problem: getrandom test does not check if it's working
Solution: check return value in autoconf and CMake. On some platforms
the function is available but not implemented (eg: GNU/Hurd).
2018-05-09 10:41:20 +01:00
Asaf Kahlon
2ec5a33f6e acinclude.m4: check if -latomic is needed.
On some cases, -latomic is needed for likning, and since the current
acinclude.m4 checks only compilation we can sometimes miss the need for -latomic
and the linking process will fail.
Therefore, the AC_CHECK_IFELSE was replaced with AC_LINK_IFELSE. If the first
try fails, we try to link again with -latomic and add LIBS="-latmoic" in case we
succeeded.

Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
2018-05-07 22:02:25 +03:00
Brian Russell
b963542e8f Add socket option BINDTODEVICE
Linux now supports Virtual Routing and Forwarding (VRF) as per:

https://www.kernel.org/doc/Documentation/networking/vrf.txt

In order for an application to bind or connect to a socket with an
address in a VRF, they need to first bind the socket to the VRF device:

    setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, dev, strlen(dev)+1);

Note "dev" is the VRF device, eg. VRF "blue", rather than an interface
enslaved to the VRF.

Add a new socket option, ZMQ_BINDTODEVICE, to bind a socket to a device.
In general, if a socket is bound to a device, eg. an interface, only
packets received from that particular device are processed by the socket.

If device is a VRF device, then subsequent binds/connects to that socket
use addresses in the VRF routing table.
2017-07-31 15:31:47 +01:00
Luca Boccassi
fbb6bbdcb8 Problem: reading from /dev/urandom is clunky
Solution: if available use the getrandom function as it doesn't
require any synchronization, state or cleanup
2017-07-28 11:28:19 +01:00
Luca Boccassi
2626fdfa23 Problem: tweetnacl leaks file descriptor on fork+exec
Solution: open with O_CLOEXEC if available or set FD_CLOEXEC if not
2017-07-28 11:27:55 +01:00
chuggafan
7913e96271 I have added msys building, license stuff (#2387)
(msys building is buggy, please be aware, it fails to compile on my
machine) also I modified the buildall.bat/buildbase.bat to use correct
MSVC versions instead of "visual studio 2017"
2017-03-19 22:38:43 +00:00
Jim Klimov
f8816945c2 Problem: polling does not work well OOB in OpenIndiana
Solution: even though epoll() semantics are supported in modern illumos, it may differ from what Linux developers are used to expect. Skip epoll and use poll or select semantics (both were checked to work well).
2017-02-02 18:18:37 +01:00
Luca Boccassi
f287c7a2aa Problem: eventfd leaks socket on fork+exec
Solution: if available, use eventfd with EFD_CLOEXEC flag to make
the process close the socket on fork+exec
2016-12-26 19:08:27 +01:00
Luca Boccassi
211898d243 Problem: epoll leaks socket on fork+exec
Solution: if available, use epoll_create1 with EPOLL_CLOEXEC flag to
make the process close the socket on fork+exec
2016-12-26 19:08:27 +01:00
Luca Boccassi
ba74890f2f Problem: cannot pick select for poller
Solution: fix acinclude.m4 snippet that checks if select is
available to stop it erroring out.
2016-11-24 12:44:51 +00:00
Luca Boccassi
8345fe9e95 Problem: build API incompatible with 4.1
Solution: keep the new --without-docs option, but also keep the old
--without-documentation with an added deprecation warning.
We can then remove it in the next major release, to leave enough time
for users and maintainers to change it without disruptions.
2016-10-27 14:20:19 +01:00
hnwyllmm@126.com
eee7880752 move the pollset to the position between devpoll and poll 2016-09-21 11:24:26 +08:00
Laughing
45286fa1fe add pollset poller in AIX
add a new poller named pollset which will get benefit of performance in AIX platform.
2016-09-20 10:50:50 +08:00
Pieter Hintjens
e65367ea2d Problem: some configure options are confusing
It's especially annoying to see this:

  --enable-perf           Build performance measurement tools [default=yes].
  --disable-eventfd       disable eventfd [default=no]
  --enable-curve-keygen   Build curve key-generation tool [default=yes].

Solution: all options should explain the non-default case. Also
the language should be enable/disable, with/without, rather than
yes/no. E.g. '--without-docs'.
2016-02-11 16:52:41 +01:00
Pieter Hintjens
9f8ced3f65 Problem: autotools platform.hpp is not compatible with CMake
Specifically, the poller detection code does not set macros in
platform.hpp. The configure script passed them as -D on the command
line.

Solution: rewrite the poller detection code.
2016-02-11 16:14:12 +01:00
Michael
f38062e6e3 fix configure errors for 64bit mingw
changes the search pattern for host_os from *mingw32* to *mingw* so that mingw64 can be used, and any mingw32 variable name change to mingw.
2016-02-03 23:54:22 +11:00
Michael
bdda5189f0 fix configure errors for 64bit mingw
changes the search pattern for host_os from *mingw32* to *mingw* so that mingw64 can be used
2016-02-03 23:38:33 +11:00
Pieter Hintjens
88949694db Problem: configure --without-documentation is clumsy
It's inconsistent, and should be --with-something=yes/no. Also the
term 'documentation' is long and clumy.

Solution: use --with-docs instead.
2016-01-18 21:25:22 +01:00
Lionel Orry
9daf6dd7c4 acinclude.m4: make kernel-specific flags cacheable
Specifically when cross-compiling, one can be willing to force these
variable values using the environment of a config.cache file. This
commit makes this possible.

The affected variables are:

* libzmq_cv_sock_cloexec
* libzmq_cv_so_keepalive
* libzmq_cv_tcp_keepcnt
* libzmq_cv_tcp_keepidle
* libzmq_cv_tcp_keepintvl
* libzmq_cv_tcp_keepalive

Signed-off-by: Lionel Orry <lionel.orry@gmail.com>
2015-02-06 15:11:07 +01: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
Olaf Mandel
48b50cefb4 Remove duplicate poller decision making
The decision about the poller mechanism to use (select, poll, ...)
was done twice: once by the build system and once by the code in
poller.hpp. As the build-system can actually detect the mechanisms
available, prefer that result to the hard coded defaults in
poller.hpp.

At the same time, remove the duplicate detection of select() vs.
poll()-variant from proxy.cpp, signaler.cpp and zmq.cpp.

This patch has not been tested on many build platforms: especially
the cmake build needs testing / patching. For the other builds,
hard code the result as these these are all Windows platforms.
2014-02-17 14:08:11 +01:00
Olaf Mandel
d9d73e4bf9 Clarify configure messages for --with-poller=... 2014-02-14 14:40:51 +01:00
Sergey KHripchenko
4b303402a7 more flexible keepalive options detection + awful options documentation 2012-04-06 20:04:35 +04:00
Sergey KHripchenko
0c3d917926 initial implementation of tuning TCP keep-alives for TCP socket
currently not fully cross-platform
work on linux
possibly work in *bsd
and could be enhanced to work on windows
2012-04-05 19:39:53 +04:00
m
1e5a48f521 Epoll is default for cross-compile. For regular-compile, test kernel (run) support. 2012-01-27 15:24:47 -08:00
m
c71375ea72 Fix: Case where system library has epoll but kernel does not support it. 2012-01-27 13:27:21 -08:00
Mikko Koppanen
6c1b50cfab Added compile-time test for SOCK_CLOEXEC
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2011-10-26 11:26:00 +02:00
Mikko Koppanen
e191e806ea Fix polling system detection on mingw32 build
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2011-09-06 08:51:23 +02:00
Mikko Koppanen
9d0e122bfa Added option to choose internal polling system
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2011-09-04 10:28:15 +02:00
Mikko Koppanen
a48b6cfc00 Additional gcov changes
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2011-04-03 07:34:14 +02:00
Mikko Koppanen
656b646bc6 Large rename: AC_ZMQ_ to LIBZMQ_ and ac_zmq_ to libzmq_. Fixes "warning suspicious cache-id"
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2011-04-02 22:50:46 +02:00
Mikko Koppanen
bdeddb89f7 Added code coverage checking
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2011-04-02 22:49:41 +02:00
Mikko Koppanen
cbbb1e925d Fix passing through CFLAGS/CPPFLAGS/CXXFLAGS when using --enable-debug
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-12-18 12:13:10 +01:00
Mikko Koppanen
a3353150f8 Fix werror flag store/restore
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-12-07 11:15:18 +01:00
Mikko Koppanen
aed2eeafdc Fix visibility on rhel4
Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-12-07 11:14:46 +01:00
Mikko Koppanen
5bb0a339be Prefix variables with "ac_zmq_"
- Added a macro for checking clang compiler
 - Moved basic compiler checks to a macro
 - Added a macro for checking if compiler supports a flag
 - Added --enable-debug flag
 - Added a macro for running normal autoconf check with compiler flags
 - Added a macro for checking for verbose flag for different compilers (-Wall)
 - Added a macro for turning on strict standards compliance
 - Added a macro for turning warnings to errors
 - Added a macro for checking if compiler supports given pragma
 - Most of the flags now go through checks if the compilers supports them
   rather than enumerating different compilers
 - Added DSO symbol visibility for sun compiler
 - Enabled verbose mode for sun compiler
 - Fixed build for ICC 12.x by adding -wd279 to size_t checks
 - Removed pkg-config checks as those don't seem to be used anywhere

Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-12-01 10:33:07 +01:00
Mikko Koppanen
edf7c18d79 Add a check that the compiler actually works.
The patch tests that the C and C++ compilers actually exist
and work. autoconf seems to default to 'g++' when C++ compiler is not
found, which causes the following error (when the compiler isn't
there):

checking for uuid_generate in -luuid... no
configure: error: cannot link with -luuid, install uuid-dev.

The config.log contains the real error message "g++ command not found"
but the error message shown to the user is misleading.

Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-11-19 09:10:26 +01:00
Mikko Koppanen
945c931daf Run autoupdate on the configure.in
I ran autoupdate on the configure.in, which generated most of the
patch attached. There is also a small manual fix in which removes the
warning "Remember to add LT_INIT to configure.in" which I assume is
because AC_PROG_LIBTOOL was called inside a macro.

Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-11-18 11:51:27 +01:00
Mikko Koppanen
72a7b93f12 Allow building without documentation.
Allows building without documentation even if asciidoc and xmlto are
installed. This eases up working with the build system because doc
generation take quite a while on repeated builds.

Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-11-17 15:10:43 +01:00
Mikko Koppanen
925595259b MinGW32 build fixes
After long discussions in IRC we came to conclusion that there is no
elegant way to handle static builds with MinGW32. This patch sets
AC_DISABLE_STATIC by default on MinGW32 and Cygwin

Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
2010-11-17 15:06:51 +01:00