Automatically resize signalling socket buffer if full

If the socketpair used by signaler_t fills up, this can lead to deadlock.
This patch provides partial resolution by attempting to resize SO_SNDBUF on
the writer side, and if that fails we shall at least assert rather than
hang.

I've also refactored the signaler_t code to make the platform-dependent
parts clearer and have tested both the MSG_DONTWAIT and standard POSIX path
in recv.

The Win32 implementation currently does not implement resizing as I'm not
convinced that it's safe, but it will also assert like other platforms if
signaler_t::send() cannot succeed.

The OpenVMS implementation has been carried forward but is untested.

Signed-off-by: Martin Lucina <mato@kotelna.sk>
This commit is contained in:
Martin Lucina
2010-11-04 17:54:47 +01:00
committed by Martin Sustrik
parent 756f7df8c8
commit 1b39bcd883
3 changed files with 217 additions and 240 deletions

View File

@@ -35,10 +35,6 @@ namespace zmq
// memory allocation by approximately 99.6%
message_pipe_granularity = 256,
// Socketpair send buffer size used by signaler. The default value of
// zero means leave it at the system default.
signaler_sndbuf_size = 0,
// Determines how often does socket poll for new commands when it
// still has unprocessed messages to handle. Thus, if it is set to 100,
// socket will process 100 inbound messages before doing the poll.