]> git.sur5r.net Git - openldap/commitdiff
honor network timeout even when doing full async
authorPierangelo Masarati <ando@openldap.org>
Sun, 7 Jan 2007 22:05:33 +0000 (22:05 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 7 Jan 2007 22:05:33 +0000 (22:05 +0000)
libraries/libldap/ldap-int.h
libraries/libldap/open.c
libraries/libldap/request.c

index e37a7b81c3b148b14066d513342426cdc2c0585e..31f386b99c8f73c5fd2c9cc8680b9d24de1205bb 100644 (file)
@@ -243,6 +243,7 @@ typedef struct ldap_conn {
        void            *lconn_sasl_sockctx;    /* for security layer */
 #endif
        int                     lconn_refcnt;
+       time_t          lconn_created;  /* time */
        time_t          lconn_lastused; /* time */
        int                     lconn_rebind_inprogress;        /* set if rebind in progress */
        char            ***lconn_rebind_queue;          /* used if rebind in progress */
index f10eb7c1040e91dac8a928e75b39e9ff6292b5c4..4d2861911083ffd577d3f0e7efc56683fe5858b3 100644 (file)
@@ -345,6 +345,8 @@ ldap_int_open_connection(
                        break;
        }
 
+       conn->lconn_created = time( NULL );
+
 #ifdef LDAP_DEBUG
        ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
                INT_MAX, (void *)"ldap_" );
index bf81bd6f442f43426dfcfe63894b253ec3b9c96d..8e42db67a0702aec76178510af94fc9a2f2a427f 100644 (file)
@@ -223,10 +223,18 @@ ldap_send_server_request(
                        lc->lconn_status = LDAP_CONNST_CONNECTED;
                        break;
 
-               case -2:
-                       /* caller will have to call again */
-                       ld->ld_errno = LDAP_X_CONNECTING;
-                       /* fallthru */
+               case -2: {
+                       /* async only occurs if a network timeout is set */
+                               struct timeval *tvp = ld->ld_options.ldo_tm_net;
+                               assert( tvp != NULL );
+
+                               /* honor network timeout */
+                               if ( time( NULL ) - lc->lconn_created <= tvp->tv_sec )
+                               {
+                                       /* caller will have to call again */
+                                       ld->ld_errno = LDAP_X_CONNECTING;
+                               }
+                       } /* fallthru */
 
                default:
                        /* error */