]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/config.c
added tcp keepalive support to back-ldap
[openldap] / servers / slapd / config.c
index ea61055e9d1744d31ebb869892b22c52ced1e1d6..9c7f00db0c5c5a3ec3965d0bb782f6821afaa558 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2011 The OpenLDAP Foundation.
+ * Copyright 1998-2013 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -1259,9 +1259,11 @@ static slap_verbmasks crlkeys[] = {
 
 static slap_verbmasks vfykeys[] = {
                { BER_BVC("never"),     LDAP_OPT_X_TLS_NEVER },
-               { BER_BVC("demand"),    LDAP_OPT_X_TLS_DEMAND },
+               { BER_BVC("allow"),     LDAP_OPT_X_TLS_ALLOW },
                { BER_BVC("try"),       LDAP_OPT_X_TLS_TRY },
+               { BER_BVC("demand"),    LDAP_OPT_X_TLS_DEMAND },
                { BER_BVC("hard"),      LDAP_OPT_X_TLS_HARD },
+               { BER_BVC("true"),      LDAP_OPT_X_TLS_HARD },
                { BER_BVNULL, 0 }
        };
 #endif
@@ -1281,7 +1283,7 @@ static slap_verbmasks versionkey[] = {
        { BER_BVNULL, 0 }
 };
 
-static int 
+int 
 slap_keepalive_parse(
        struct berval *val,
        void *bc,
@@ -1923,6 +1925,29 @@ int bindconf_tls_set( slap_bindconf *bc, LDAP *ld )
 }
 #endif
 
+/*
+ * set connection keepalive options
+ */
+void
+slap_client_keepalive(LDAP *ld, slap_keepalive *sk)
+{
+       if (!sk) return;
+
+       if ( sk->sk_idle ) {
+               ldap_set_option( ld, LDAP_OPT_X_KEEPALIVE_IDLE, &sk->sk_idle );
+       }
+
+       if ( sk->sk_probes ) {
+               ldap_set_option( ld, LDAP_OPT_X_KEEPALIVE_PROBES, &sk->sk_probes );
+       }
+
+       if ( sk->sk_interval ) {
+               ldap_set_option( ld, LDAP_OPT_X_KEEPALIVE_INTERVAL, &sk->sk_interval );
+       }
+
+       return;
+}
+
 /*
  * connect to a client using the bindconf data
  * note: should move "version" into bindconf...
@@ -1961,6 +1986,10 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb )
                ldap_set_option( ld, LDAP_OPT_NETWORK_TIMEOUT, &tv );
        }
 
+       /* setting network keepalive options */
+       slap_client_keepalive(ld, &sb->sb_keepalive);
+
+#if 0
        if ( sb->sb_keepalive.sk_idle ) {
                ldap_set_option( ld, LDAP_OPT_X_KEEPALIVE_IDLE, &sb->sb_keepalive.sk_idle );
        }
@@ -1972,6 +2001,7 @@ slap_client_connect( LDAP **ldp, slap_bindconf *sb )
        if ( sb->sb_keepalive.sk_interval ) {
                ldap_set_option( ld, LDAP_OPT_X_KEEPALIVE_INTERVAL, &sb->sb_keepalive.sk_interval );
        }
+#endif /* 0 */
 
 #ifdef HAVE_TLS
        if ( sb->sb_tls_do_init ) {