* ZMQ_DGRAM: flip more flag after successful send
In the dgram socket we have a flag that indicates the next expected message type to ensure that always a pair of "address" + "body" messages gets sent. The first one MUST have the sendmore flag, the second MUST NOT.
In case the message does not get sent because of HWM full, then the function returns EAGAIN as it should. But unfortunately the next expected message type-flag gets flipped as well. When the socket_base::send function now tries to resend the message, it became the wrong message type... If you don't stop sending pairs of messages here (like me) then the next message that gets through will be of the wrong type, which in turn crashes the udp_engine function as described in #3268
This patch fixes an issue that occurs on 64-bit architetures under
strict compiler rules. The code initially checked that the received
size stored in 'uint64_t' was not bigger than the max value of a
'size_t' variable, which is legitimate on 32-bit architectures where
'size_t' variables are stored on 32 bits. On 64-bit architectures,
this test no longer makes sense since 'uint64_t' and 'size_t' types
have the same size. The issue is fixed by ignoring this portion
of code when built for arm64.
Solution: use a monitor to wait for a disconnect instead of a sleep,
and retry to send a message until it fails since the state machine
might be delayed due to the I/O thread being pre-empted on busy
systems.
Also set a receive timeout to avoid random hangs.
Fixes#3124
Solution: allow for a range between the minimum and maximum expected.
With 2 queues, that's between 20 and 40 messages depending on the
scheduling of the 3 threads involved.
Commit 2ec5a33f6e 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>
- Lowercase all commands
- Unify indent to 2 spaces
- Remove spaces around brackets
- Remove repitition of condition in else(...) and endif(...)
Note: (re-)running CMake did not change the content of the generated files