Setting TCP keepalive for Cyrus daemons

Gary Mills mills at cc.umanitoba.ca
Sat Feb 13 11:00:52 EST 2010


On Sat, Feb 13, 2010 at 09:09:05PM +1100, Bron Gondwana wrote:
> On Fri, Feb 12, 2010 at 09:45:02AM -0600, Gary Mills wrote:
> > I'm willing to add a `keepalive' option to Cyrus master along with the
> > setsockopt() system call to enable that setting.  This option could be
> > added to the cyrus.conf file for any services that could benefit from
> > it. Would this be a reasonable addition to Cyrus?
> 
> How does this look?

Wow, you beat me to it!  You even covered all of the settings.

> +{ "tcp_keepalive", 0, SWITCH }
> +/* Enable keepalive on TCP connections */
> +
> +{ "tcp_keepalive_cnt", 0, INT }
> +/* Number of TCP keepalive probes to send before declaring the 
> +   connection dead (0 == system default) */
> +
> +{ "tcp_keepalive_idle", 0, INT }
> +/* Number of seconds a connection must be idle before keepalive
> +   probes are sent (0 == system default) */
> +
> +{ "tcp_keepalive_intvl", 0, INT }
> +/* Number of seconds between keepalive probes (0 == system default) */
> 
> A switch to enable keepalive, plus options to edit each of the
> tunables.  The full patch is attached - not tested except for
> a compile yet.

I can't comment on imap/sync_client.c because I don't use that
technique.  In master.c, I would have put my changes into
spawn_service(), just before master exec'ed the daemon.  However,
putting them where the connection was first accepted should be fine
too.

One thing to watch is that only SO_KEEPALIVE is standard.  The other
three symbols: TCP_KEEPCNT, TCP_KEEPIDLE, and TCP_KEEPINTVL only exist
in some operating systems.  They have global settings but don't have
per-socket options.  For these, the setsockopt() function calls need
to be conditional on the symbols.

For which Cyrus version is your patch intended.  I'm still running
cyrus-imapd-2.3.8 .

-- 
-Gary Mills-        -Unix Group-        -Computer and Network Services-


More information about the Info-cyrus mailing list