s3/libads: use monotonic clock for ldap connection timeouts
authorBjörn Jacke <bj@sernet.de>
Tue, 7 Sep 2010 00:15:09 +0000 (02:15 +0200)
committerBjörn Jacke <bj@sernet.de>
Tue, 7 Sep 2010 18:37:53 +0000 (20:37 +0200)
source3/include/ads.h
source3/libads/ldap.c
source3/libads/ldap_utils.c

index b45d53de0797ba6ffac6e769c94950ccbcb6475c..6ef5455766c88f804b8d2b27e80fd243c6d8cb91 100644 (file)
@@ -65,7 +65,7 @@ typedef struct ads_struct {
        struct {
                LDAP *ld;
                struct sockaddr_storage ss; /* the ip of the active connection, if any */
-               time_t last_attempt; /* last attempt to reconnect */
+               time_t last_attempt; /* last attempt to reconnect, monotonic clock */
                int port;
 
                enum ads_saslwrap_type wrap_type;
index 77ab51ee2659eb8f5a5410e49f3b9c0f08d5e742..970f20a8d91788ecaaaa865f000f9d0673af1b33 100644 (file)
@@ -596,7 +596,7 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads)
        char addr[INET6_ADDRSTRLEN];
 
        ZERO_STRUCT(ads->ldap);
-       ads->ldap.last_attempt  = time(NULL);
+       ads->ldap.last_attempt  = time_mono(NULL);
        ads->ldap.wrap_type     = ADS_SASLWRAP_TYPE_PLAIN;
 
        /* try with a user specified server */
index c0c1adba30032a6558b45a344fc3e310881f5e46..0c0796115308fe4683dffb5e06beb1b78dcf9510 100644 (file)
@@ -40,7 +40,7 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
        *res = NULL;
 
        if (!ads->ldap.ld &&
-           time(NULL) - ads->ldap.last_attempt < ADS_RECONNECT_TIME) {
+           time_mono(NULL) - ads->ldap.last_attempt < ADS_RECONNECT_TIME) {
                return ADS_ERROR(LDAP_SERVER_DOWN);
        }