tags 474178 + patch thanks Here is a better patch, making sure to only search once when the first search succeeds.
Index: nslcd/common.h =================================================================== --- nslcd/common.h (revision 729) +++ nslcd/common.h (working copy) @@ -124,6 +124,10 @@ { \ /* define common variables */ \ int32_t tmpint32; \ + int tries = 2; \ + int retval = -1; \ + int count = 0; \ + int headerprinted = 0; \ MYLDAP_SEARCH *search; \ MYLDAP_ENTRY *entry; \ int rc; \ @@ -131,9 +135,6 @@ readfn; \ /* log call */ \ logcall; \ - /* write the response header */ \ - WRITE_INT32(fp,NSLCD_VERSION); \ - WRITE_INT32(fp,action); \ /* prepare the search filter */ \ if (mkfilter) \ { \ @@ -142,21 +143,37 @@ } \ /* build the list of attributes */ \ db##_init(); \ - /* do the LDAP search */ \ - if ((search=myldap_search(session,db##_base,db##_scope,filter,db##_attrs))==NULL) \ - return -1; \ - /* go over results */ \ - while ((entry=myldap_get_entry(search,&rc))!=NULL) \ - { \ - if (writefn) \ - return -1; \ - } \ - /* write the final result code */ \ - if (rc==LDAP_SUCCESS) \ - { \ - WRITE_INT32(fp,NSLCD_RESULT_END); \ - } \ - return 0; \ + do { \ + /* do the LDAP search */ \ + if ((search=myldap_search(session,db##_base,db##_scope,filter,db##_attrs))==NULL) { \ + log_log(LOG_WARNING,"nslcd_" __STRING(db) "_" __STRING(fn) "(): search failed, retrying?"); \ + continue; \ + } \ + /* write the response header */ \ + if (!headerprinted) { \ + WRITE_INT32(fp,NSLCD_VERSION); \ + WRITE_INT32(fp,action); \ + headerprinted = 1; \ + } \ + /* go over results */ \ + while ((entry=myldap_get_entry(search,&rc))!=NULL) \ + { \ + count++ ; \ + if (writefn) \ + return -1; \ + } \ + if (0 == count) {\ + log_log(LOG_WARNING,"nslcd_" __STRING(db) "_" __STRING(fn) "(): result failed, retrying?"); \ + continue; \ + } \ + /* write the final result code */ \ + if (rc==LDAP_SUCCESS) \ + { \ + WRITE_INT32(fp,NSLCD_RESULT_END); \ + retval = 0; \ + } \ + } while (0 != retval && 0 < --tries); \ + return retval; \ } #endif /* not _SERVER_COMMON_H */ Happy hacking, -- Petter Reinholdtsen -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]