Anyone familiar with the res_config_ldap code know why this particular ldap call, and not every ldap call, is wrapped in retry logic that relates to the connection status. It's almost as if someone encountered connection errors and instead of solving opted to live with them. Wanted and insight behind this while I dig in and try to solve it. Because it happens to us occasionally and might be the cause of other errors we are seeing.<br>
<br>do {<br> /* freeing ldap_result further down */<br> result = ldap_search_ext_s(ldapConn, clean_basedn,<br> LDAP_SCOPE_SUBTREE, filter, NULL, 0, NULL, NULL, NULL, LDAP_NO_LIMIT,<br> &ldap_result);<br>
if (result < 0 && is_ldap_connect_error(result)) {<br> ast_log(LOG_WARNING, "Failed to query database. Try %d/3\n",<br> tries + 1);<br> tries++;<br> if (tries < 3) {<br>
usleep(500000L * tries);<br> if (ldapConn) {<br> ldap_unbind_ext_s(ldapConn,NULL,NULL);<br> ldapConn = NULL;<br> }<br> if (!ldap_reconnect())<br>
break;<br> }<br> }<br> } while (result < 0 && tries < 3 && is_ldap_connect_error(result));<br><br>