--- globus_2_4_3_adv2003_fix892/mds/openldap/ldapmodules/search.c Thu Jul 3 01:33:00 2003 +++ globus_2_4_3_adv2003_fix892_fix956/mds/openldap/ldapmodules/search.c Sat Jan 3 22:35:33 2004 @@ -194,7 +194,7 @@ DataObj_gris *Dataobj_gris=NULL, *cdataobj_gris=NULL, *ndataobj_gris=NULL, *sdataobj_gris=NULL, *edataobj_gris=NULL, *tempdataobj_gris; int ttl, create_new, inx, sfxm, fdn, cntrl; FILE *fptr; - char *dn, *data, *obj, *path, *sfx, *ttlstr, *tempdata, *data1; + char *dn, *data, *obj, *path, *sfx, *ttlstr, *tempdata, *data1 = NULL; int cur_inx, errno; char *authcid, *ubuf = NULL; int search_timed_out; @@ -409,36 +409,57 @@ fclose( wfp ); fdn = fileno(rfp); - FD_ZERO( &readfds ); - FD_SET( fdn, &readfds ); start_t = ldif_current_time(); t_limit = (glist[inx])->timelimit; end_t = start_t + t_limit; - tv.tv_sec = (glist[inx])->timelimit; - tv.tv_usec = 0; - - errno = 0; - while (errno == EINTR) - rc = select (fdn + 1, &readfds, NULL, &readfds, &tv); - + for (;;) { + FD_ZERO( &readfds ); + FD_SET( fdn, &readfds ); + + tv.tv_sec = t_limit; + tv.tv_usec = 0; + + rc = select (fdn + 1, &readfds, NULL, &readfds, &tv); + + if (rc < 0 && errno == EINTR) { + if ((t_limit = end_t - ldif_current_time()) < 0) { + /* avoid EINVAL when timeout < 0 */ + t_limit = 0; + } + + continue; + } + + break; + } + + if (rc <= 0) { + char buf[128]; + + if (rc < 0) { + sprintf(buf, "select error %d", errno); + } + else { + sprintf(buf, "timelimit exceeded"); + } - if (rc < errno) - { search_timed_out = 1; if ((glist[inx])->base) - Debug (LDAP_DEBUG_ANY, "information provider %s: timelimit exceeded\n", (glist[inx])->base, 0, 0); + Debug (LDAP_DEBUG_ANY, + "information provider %s: %s\n", + (glist[inx])->base, buf, 0); else - Debug (LDAP_DEBUG_ANY, "information provider %d: timelimit exceeded\n", inx, 0, 0); + Debug (LDAP_DEBUG_ANY, + "information provider %d: %s\n", + inx, buf, 0); data = NULL; - } - else - { + } + else { search_timed_out = 0; data = ldif_getdatastr(rfp); - } - + } data1 = ldif_strip_comments(data); if (data) free (data);