1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-21 18:04:06 +03:00

ldb: allow a timeout of -1 result in no timeout timer at all.

This is required in order to have long running async searches,
e.g. with LDB_CONTROL_NOTIFICATION_OID.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Stefan Metzmacher 2016-01-22 08:53:57 +01:00 committed by Garming Sam
parent 5db9f865bc
commit 2b1cd4a114
3 changed files with 27 additions and 16 deletions

View File

@ -252,8 +252,11 @@ static int lldb_search(struct lldb_context *lldb_ac)
break; break;
} }
tv.tv_sec = req->timeout; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
if (req->timeout > 0) {
tv.tv_sec = req->timeout;
}
ret = ldap_search_ext(lldb->ldap, search_base, ldap_scope, ret = ldap_search_ext(lldb->ldap, search_base, ldap_scope,
expression, expression,
@ -836,12 +839,13 @@ static int lldb_handle_request(struct ldb_module *module, struct ldb_request *re
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
if (req->timeout > 0) {
tv.tv_sec = req->starttime + req->timeout; tv.tv_sec = req->starttime + req->timeout;
tv.tv_usec = 0; tv.tv_usec = 0;
te = tevent_add_timer(ev, ac, tv, lldb_timeout, ac); te = tevent_add_timer(ev, ac, tv, lldb_timeout, ac);
if (NULL == te) { if (NULL == te) {
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
}
} }
return LDB_SUCCESS; return LDB_SUCCESS;

View File

@ -1566,10 +1566,13 @@ static int lsql_handle_request(struct ldb_module *module, struct ldb_request *re
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
tv.tv_sec = req->starttime + req->timeout; if (req->timeout > 0) {
ac->timeout_event = tevent_add_timer(ev, ac, tv, lsql_timeout, ac); tv.tv_sec = req->starttime + req->timeout;
if (NULL == ac->timeout_event) { tv.tv_usec = 0;
return LDB_ERR_OPERATIONS_ERROR; ac->timeout_event = tevent_add_timer(ev, ac, tv, lsql_timeout, ac);
if (NULL == ac->timeout_event) {
return LDB_ERR_OPERATIONS_ERROR;
}
} }
return LDB_SUCCESS; return LDB_SUCCESS;

View File

@ -1469,11 +1469,15 @@ static int ltdb_handle_request(struct ldb_module *module,
return LDB_ERR_OPERATIONS_ERROR; return LDB_ERR_OPERATIONS_ERROR;
} }
tv.tv_sec = req->starttime + req->timeout; if (req->timeout > 0) {
ac->timeout_event = tevent_add_timer(ev, ac, tv, ltdb_timeout, ac); tv.tv_sec = req->starttime + req->timeout;
if (NULL == ac->timeout_event) { tv.tv_usec = 0;
talloc_free(ac); ac->timeout_event = tevent_add_timer(ev, ac, tv,
return LDB_ERR_OPERATIONS_ERROR; ltdb_timeout, ac);
if (NULL == ac->timeout_event) {
talloc_free(ac);
return LDB_ERR_OPERATIONS_ERROR;
}
} }
/* set a spy so that we do not try to use the request context /* set a spy so that we do not try to use the request context