r17514: Simplify the way to set ldb errors and add another
[abartlet/samba.git/.git] / source4 / lib / ldb / modules / sort.c
index 261bae7e78c0f799cbfae9ce18292aa9880a16df..0ae16d08ab9a265b703764f283bd5f0bb216315b 100644 (file)
@@ -72,7 +72,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
 
        h = talloc_zero(mem_ctx, struct ldb_handle);
        if (h == NULL) {
-               ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+               ldb_set_errstring(module->ldb, "Out of Memory");
                return NULL;
        }
 
@@ -80,7 +80,7 @@ static struct ldb_handle *init_handle(void *mem_ctx, struct ldb_module *module,
 
        ac = talloc_zero(h, struct sort_context);
        if (ac == NULL) {
-               ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+               ldb_set_errstring(module->ldb, "Out of Memory");
                talloc_free(h);
                return NULL;
        }
@@ -171,7 +171,7 @@ static int server_sort_search_callback(struct ldb_context *ldb, void *context, s
        struct sort_context *ac = NULL;
        
        if (!context || !ares) {
-               ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+               ldb_set_errstring(ldb, "NULL Context or Result in callback");
                goto error;
        }       
 
@@ -242,14 +242,15 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
                return ldb_next_request(module, req);
        }
 
-       req->async.handle = NULL;
+       req->handle = NULL;
 
-       if (!req->async.callback || !req->async.context) {
-               ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
+       if (!req->callback || !req->context) {
+               ldb_set_errstring(module->ldb,
+                                 "Async interface called with NULL callback function or NULL context");
                return LDB_ERR_OPERATIONS_ERROR;
        }
        
-       h = init_handle(req, module, req->async.context, req->async.callback);
+       h = init_handle(req, module, req->context, req->callback);
        if (!h) {
                return LDB_ERR_OPERATIONS_ERROR;
        }
@@ -310,11 +311,11 @@ static int server_sort_search(struct ldb_module *module, struct ldb_request *req
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       ac->req->async.context = ac;
-       ac->req->async.callback = server_sort_search_callback;
+       ac->req->context = ac;
+       ac->req->callback = server_sort_search_callback;
        ldb_set_timeout_from_prev_req(module->ldb, req, ac->req);
 
-       req->async.handle = h;
+       req->handle = h;
 
        return ldb_next_request(module, ac->req);
 }
@@ -398,15 +399,15 @@ static int server_sort_wait(struct ldb_handle *handle, enum ldb_wait_type type)
 
        ac = talloc_get_type(handle->private_data, struct sort_context);
 
-       ret = ldb_wait(ac->req->async.handle, type);
+       ret = ldb_wait(ac->req->handle, type);
 
        if (ret != LDB_SUCCESS) {
                handle->status = ret;
                return ret;
        }
                
-       handle->state = ac->req->async.handle->state;
-       handle->status = ac->req->async.handle->status;
+       handle->state = ac->req->handle->state;
+       handle->status = ac->req->handle->status;
 
        if (handle->status != LDB_SUCCESS) {
                return handle->status;