From: Ted C. Cheng Date: Wed, 30 Jan 2013 19:58:14 +0000 (-0800) Subject: ITS#7513 added TCP keepalive support to back-meta X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d3633632e121e83b1e04813b33121e3121b317ab;p=openldap ITS#7513 added TCP keepalive support to back-meta --- diff --git a/doc/man/man5/slapd-meta.5 b/doc/man/man5/slapd-meta.5 index 4f3c1c6f63..30d6b63d60 100644 --- a/doc/man/man5/slapd-meta.5 +++ b/doc/man/man5/slapd-meta.5 @@ -546,6 +546,25 @@ minutes and seconds. If set before any target specification, it affects all targets, unless overridden by any per-target directive. +.TP +.B keepalive :: +The +.B keepalive +parameter sets the values of \fIidle\fP, \fIprobes\fP, and \fIinterval\fP +used to check whether a socket is alive; +.I idle +is the number of seconds a connection needs to remain idle before TCP +starts sending keepalive probes; +.I probes +is the maximum number of keepalive probes TCP should send before dropping +the connection; +.I interval +is interval in seconds between individual keepalive probes. +Only some systems support the customization of these values; +the +.B keepalive +parameter is ignored otherwise, and system-wide settings are used. + .TP .B map "{attribute|objectclass} [|*] {|*}" This maps object classes and attributes as in the LDAP backend. diff --git a/servers/slapd/back-meta/config.c b/servers/slapd/back-meta/config.c index 231c583c93..06027a5adb 100644 --- a/servers/slapd/back-meta/config.c +++ b/servers/slapd/back-meta/config.c @@ -100,6 +100,7 @@ enum { LDAP_BACK_CFG_SUBTREE_IN, LDAP_BACK_CFG_PSEUDOROOTDN, LDAP_BACK_CFG_PSEUDOROOTPW, + LDAP_BACK_CFG_KEEPALIVE, LDAP_BACK_CFG_LAST }; @@ -407,6 +408,15 @@ static ConfigTable metacfg[] = { "SYNTAX OMsDirectoryString " "SINGLE-VALUE X-ORDERED 'SIBLINGS' )", NULL, NULL }, + { "keepalive", "keepalive", 2, 2, 0, + ARG_MAGIC|LDAP_BACK_CFG_KEEPALIVE, + meta_back_cf_gen, "( OLcfgDbAt:3.29 " + "NAME 'olcDbKeepalive' " + "DESC 'TCP keepalive' " + "SYNTAX OMsDirectoryString " + "SINGLE-VALUE )", + NULL, NULL }, + { NULL, NULL, 0, 0, 0, ARG_IGNORED, NULL, NULL, NULL, NULL } }; @@ -466,6 +476,7 @@ static ConfigOCs metaocs[] = { "$ olcDbSubtreeExclude " "$ olcDbSubtreeInclude " "$ olcDbTimeout " + "$ olcDbKeepalive " /* defaults may be inherited */ COMMON_ATTRS @@ -1589,6 +1600,16 @@ meta_back_cf_gen( ConfigArgs *c ) rc = 1; break; + case LDAP_BACK_CFG_KEEPALIVE: { + struct berval bv; + char buf[AC_LINE_MAX]; + bv.bv_len = AC_LINE_MAX; + bv.bv_val = &buf[0]; + slap_keepalive_parse(&bv, &mt->mt_tls.sb_keepalive, 0, 0, 1); + value_add_one( &c->rvalue_vals, &bv ); + break; + } + default: rc = 1; } @@ -1803,6 +1824,12 @@ meta_back_cf_gen( ConfigArgs *c ) } break; + case LDAP_BACK_CFG_KEEPALIVE: + mt->mt_tls.sb_keepalive.sk_idle = 0; + mt->mt_tls.sb_keepalive.sk_probes = 0; + mt->mt_tls.sb_keepalive.sk_interval = 0; + break; + default: rc = 1; break; @@ -2809,6 +2836,11 @@ map_fail:; break; #endif /* SLAPD_META_CLIENT_PR */ + case LDAP_BACK_CFG_KEEPALIVE: + slap_keepalive_parse( ber_bvstrdup(c->argv[1]), + &mt->mt_tls.sb_keepalive, 0, 0, 0); + break; + /* anything else */ default: return SLAP_CONF_UNKNOWN; diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index da8e0a13e3..7e63fae896 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -421,6 +421,8 @@ retry_lock:; ldap_set_option( msc->msc_ld, LDAP_OPT_REFERRALS, META_BACK_TGT_CHASE_REFERRALS( mt ) ? LDAP_OPT_ON : LDAP_OPT_OFF ); + slap_client_keepalive(msc->msc_ld, &mt->mt_tls.sb_keepalive); + #ifdef HAVE_TLS if ( !is_ldaps ) { slap_bindconf *sb = NULL;