diff options
author | Simo Sorce <idra@samba.org> | 2008-10-15 14:03:20 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2008-10-16 13:42:22 -0400 |
commit | 8b0afbc4aa94628290d74165cab6bec97c7e532b (patch) | |
tree | 11d9529563f88a929de1ff44364be0d5864031bd /ldb/common | |
parent | f11b502bf535ff5e09e595dbb95d9bdd5e2e7857 (diff) | |
download | sssd-8b0afbc4aa94628290d74165cab6bec97c7e532b.tar.gz sssd-8b0afbc4aa94628290d74165cab6bec97c7e532b.tar.bz2 sssd-8b0afbc4aa94628290d74165cab6bec97c7e532b.zip |
Transform the sequence_number operation into a normal extended operation as it should always have been. Make it also async so that it is not a special case.
(Sync from upstream)
Diffstat (limited to 'ldb/common')
-rw-r--r-- | ldb/common/ldb.c | 50 | ||||
-rw-r--r-- | ldb/common/ldb_modules.c | 4 |
2 files changed, 29 insertions, 25 deletions
diff --git a/ldb/common/ldb.c b/ldb/common/ldb.c index 4ec86851..bb710334 100644 --- a/ldb/common/ldb.c +++ b/ldb/common/ldb.c @@ -530,10 +530,6 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req) FIRST_OP(ldb, extended); ret = module->ops->extended(module, req); break; - case LDB_SEQUENCE_NUMBER: - FIRST_OP(ldb, sequence_number); - ret = module->ops->sequence_number(module, req); - break; default: FIRST_OP(ldb, request); ret = module->ops->request(module, req); @@ -1175,35 +1171,47 @@ int ldb_rename(struct ldb_context *ldb, int ldb_sequence_number(struct ldb_context *ldb, enum ldb_sequence_type type, uint64_t *seq_num) { - struct ldb_request *req; + struct ldb_seqnum_request *seq; + struct ldb_seqnum_result *seqr; + struct ldb_result *res; + TALLOC_CTX *tmp_ctx; int ret; - req = talloc_zero(ldb, struct ldb_request); - if (req == NULL) { + *seq_num = 0; + + tmp_ctx = talloc_zero(ldb, struct ldb_request); + if (tmp_ctx == NULL) { ldb_set_errstring(ldb, "Out of Memory"); return LDB_ERR_OPERATIONS_ERROR; } + seq = talloc_zero(tmp_ctx, struct ldb_seqnum_request); + if (seq == NULL) { + ldb_set_errstring(ldb, "Out of Memory"); + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; + } + seq->type = type; - req->operation = LDB_SEQUENCE_NUMBER; - req->controls = NULL; - req->context = NULL; - req->callback = ldb_op_default_callback; - ldb_set_timeout(ldb, req, 0); /* use default timeout */ - - req->op.seq_num.type = type; - /* do request and autostart a transaction */ - ret = ldb_request(ldb, req); + ret = ldb_extended(ldb, LDB_EXTENDED_SEQUENCE_NUMBER, seq, &res); + if (ret != LDB_SUCCESS) { + goto done; + } + talloc_steal(tmp_ctx, res); - if (ret == LDB_SUCCESS) { - *seq_num = req->op.seq_num.seq_num; + if (strcmp(LDB_EXTENDED_SEQUENCE_NUMBER, res->extended->oid) != 0) { + ldb_set_errstring(ldb, "Invalid OID in reply"); + ret = LDB_ERR_OPERATIONS_ERROR; + goto done; } + seqr = talloc_get_type(res->extended->data, + struct ldb_seqnum_result); + *seq_num = seqr->seq_num; - talloc_free(req); +done: + talloc_free(tmp_ctx); return ret; } - - /* return extended error information */ diff --git a/ldb/common/ldb_modules.c b/ldb/common/ldb_modules.c index 5cc8de29..2b453bb0 100644 --- a/ldb/common/ldb_modules.c +++ b/ldb/common/ldb_modules.c @@ -517,10 +517,6 @@ int ldb_next_request(struct ldb_module *module, struct ldb_request *request) FIND_OP(module, extended); ret = module->ops->extended(module, request); break; - case LDB_SEQUENCE_NUMBER: - FIND_OP(module, sequence_number); - ret = module->ops->sequence_number(module, request); - break; default: FIND_OP(module, request); ret = module->ops->request(module, request); |