mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
preemptive time limit check in proxy backends
This commit is contained in:
parent
63f6e91a97
commit
e12c4ca230
@ -137,6 +137,7 @@ ldap_back_search(
|
||||
{
|
||||
struct ldapconn *lc;
|
||||
struct timeval tv;
|
||||
time_t stoptime;
|
||||
LDAPMessage *res,
|
||||
*e;
|
||||
int rc = 0,
|
||||
@ -171,6 +172,7 @@ ldap_back_search(
|
||||
if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
|
||||
tv.tv_sec = op->ors_tlimit;
|
||||
tv.tv_usec = 0;
|
||||
stoptime = op->o_time + op->ors_tlimit;
|
||||
|
||||
} else {
|
||||
tv.tv_sec = 0;
|
||||
@ -260,9 +262,18 @@ fail:;
|
||||
tv.tv_usec = 100000;
|
||||
ldap_pvt_thread_yield();
|
||||
|
||||
/* check time limit */
|
||||
if ( op->ors_tlimit != SLAP_NO_LIMIT
|
||||
&& slap_get_time() > stoptime )
|
||||
{
|
||||
ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
|
||||
rc = rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
} else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
|
||||
Entry ent = {0};
|
||||
struct berval bdn;
|
||||
Entry ent = { 0 };
|
||||
struct berval bdn = BER_BVNULL;
|
||||
int abort = 0;
|
||||
|
||||
do_retry = 0;
|
||||
|
@ -54,13 +54,13 @@ meta_back_search_start(
|
||||
)
|
||||
{
|
||||
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
|
||||
struct berval realbase = op->o_req_dn;
|
||||
int realscope = op->ors_scope;
|
||||
ber_len_t suffixlen = 0;
|
||||
struct berval mbase = BER_BVNULL;
|
||||
struct berval mfilter = BER_BVNULL;
|
||||
char **mapped_attrs = NULL;
|
||||
int rc;
|
||||
struct berval realbase = op->o_req_dn;
|
||||
int realscope = op->ors_scope;
|
||||
ber_len_t suffixlen = 0;
|
||||
struct berval mbase = BER_BVNULL;
|
||||
struct berval mfilter = BER_BVNULL;
|
||||
char **mapped_attrs = NULL;
|
||||
int rc;
|
||||
|
||||
/* should we check return values? */
|
||||
if ( op->ors_deref != -1 ) {
|
||||
@ -228,18 +228,19 @@ done:;
|
||||
int
|
||||
meta_back_search( Operation *op, SlapReply *rs )
|
||||
{
|
||||
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
|
||||
metaconn_t *mc;
|
||||
struct timeval tv = { 0, 0 };
|
||||
LDAPMessage *res = NULL, *e;
|
||||
int rc = 0, sres = LDAP_SUCCESS;
|
||||
char *matched = NULL;
|
||||
int i, last = 0, ncandidates = 0,
|
||||
initial_candidates = 0, candidate_match = 0;
|
||||
dncookie dc;
|
||||
int is_ok = 0;
|
||||
void *savepriv;
|
||||
SlapReply *candidates = meta_back_candidates_get( op );
|
||||
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
|
||||
metaconn_t *mc;
|
||||
struct timeval tv = { 0, 0 };
|
||||
time_t stoptime;
|
||||
LDAPMessage *res = NULL, *e;
|
||||
int rc = 0, sres = LDAP_SUCCESS;
|
||||
char *matched = NULL;
|
||||
int i, last = 0, ncandidates = 0,
|
||||
initial_candidates = 0, candidate_match = 0;
|
||||
dncookie dc;
|
||||
int is_ok = 0;
|
||||
void *savepriv;
|
||||
SlapReply *candidates = meta_back_candidates_get( op );
|
||||
|
||||
/*
|
||||
* controls are set in ldap_back_dobind()
|
||||
@ -321,6 +322,11 @@ meta_back_search( Operation *op, SlapReply *rs )
|
||||
* but this is necessary for version matching, and for ACL processing.
|
||||
*/
|
||||
|
||||
if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
|
||||
stoptime = op->o_time + op->ors_tlimit;
|
||||
tv.tv_sec = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* In case there are no candidates, no cycle takes place...
|
||||
*
|
||||
@ -358,6 +364,19 @@ meta_back_search( Operation *op, SlapReply *rs )
|
||||
/* FIXME: res should not need to be freed */
|
||||
assert( res == NULL );
|
||||
|
||||
/* check time limit */
|
||||
if ( op->ors_tlimit != SLAP_NO_LIMIT
|
||||
&& slap_get_time() > stoptime )
|
||||
{
|
||||
doabandon = 1;
|
||||
rc = rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
|
||||
savepriv = op->o_private;
|
||||
op->o_private = (void *)i;
|
||||
send_ldap_result( op, rs );
|
||||
op->o_private = savepriv;
|
||||
goto finish;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
} else if ( rc == -1 ) {
|
||||
|
Loading…
Reference in New Issue
Block a user