[zeromq-dev] [PATCH] socket option ZMQ_RECONNECT_IVL_MAX

Thijs Terlouw thijsterlouw at gmail.com
Wed Jan 19 16:18:26 CET 2011


> From: Martin Sustrik <sustrik at 250bpm.com>
>> So far so good (though I think the reconnect interval should be
>> augmented by exponential back-off, perhaps by splitting it in two
>> options ZMQ_RECONNECT_IVL (the max) + ZMQ_RECONNECT_IVL_MIN ). A patch
>> for this should be easy.
>
> Yes. Makes sense. Feel free to submit a patch.

I've attached a patch to add the socket option ZMQ_RECONNECT_IVL_MAX.

Default value is the same as ZMQ_RECONNECT_IVL, so the default
behavior is unchanged. If you set a higher value, it will double the
previous reconnect interval (starting with ZMQ_RECONNECT_IVL) untill
ZMQ_RECONNECT_IVL_MAX is reached.

For example setting :

    int reconnect_ivl_min = 100;
    int reconnect_ivl_max = 20000;
    zmq_setsockopt (requester, ZMQ_RECONNECT_IVL, &reconnect_ivl_min,
sizeof(int));
    zmq_setsockopt (requester, ZMQ_RECONNECT_IVL_MAX,
&reconnect_ivl_max, sizeof(int));

will result in reconnects (+ randomization):
100,
200,
400,
800,
1600,
3200,
6400,
12800,
20000,
20000,
20000,
etc

ps. note that my patch also updated the documentation, but my
documentation version is out-of-sync with the origin documentation. It
probably needs to be merged manually.

Thijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Added-socket-option-ZMQ_RECONNECT_IVL_MAX.-Allows-to.patch
Type: application/octet-stream
Size: 10768 bytes
Desc: not available
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20110119/06a27b97/attachment.obj>


More information about the zeromq-dev mailing list