Convert wb_resp_read to tevent_req
authorVolker Lendecke <vl@samba.org>
Sun, 8 Mar 2009 09:20:27 +0000 (10:20 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 8 Mar 2009 10:21:00 +0000 (11:21 +0100)
source3/include/wbc_async.h
source3/lib/wb_reqtrans.c
source3/lib/wbclient.c

index b355c8fc9ff2222597d8504da97ef30d673df34b..27af31f27a6ad84a49b9d25a41b807f17a517ced 100644 (file)
@@ -55,10 +55,9 @@ struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
                                     struct winbindd_request *wb_req);
 wbcErr wb_req_write_recv(struct tevent_req *req);
 
-struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
-                                   struct tevent_context *ev, int fd);
-
-wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
+struct tevent_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
+                                    struct tevent_context *ev, int fd);
+wbcErr wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                         struct winbindd_response **presp);
 
 struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
index 30e5f75062fda373244aef6905df967b680015b9..1f7713b02dd97a113cd87433e2fc881b95ba47b9 100644 (file)
@@ -284,15 +284,14 @@ struct resp_read_state {
 static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data);
 static void wb_resp_read_done(struct tevent_req *subreq);
 
-struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
-                                   struct tevent_context *ev, int fd)
+struct tevent_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
+                                    struct tevent_context *ev, int fd)
 {
-       struct async_req *result;
-       struct tevent_req *subreq;
+       struct tevent_req *result, *subreq;
        struct resp_read_state *state;
 
-       if (!async_req_setup(mem_ctx, &result, &state,
-                            struct resp_read_state)) {
+       result = tevent_req_create(mem_ctx, &state, struct resp_read_state);
+       if (result == NULL) {
                return NULL;
        }
 
@@ -326,10 +325,10 @@ static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data)
 
 static void wb_resp_read_done(struct tevent_req *subreq)
 {
-       struct async_req *req =
-               tevent_req_callback_data(subreq, struct async_req);
-       struct resp_read_state *state = talloc_get_type_abort(
-               req->private_data, struct resp_read_state);
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct resp_read_state *state = tevent_req_data(
+               req, struct resp_read_state);
        uint8_t *buf;
        int err;
        ssize_t ret;
@@ -337,7 +336,7 @@ static void wb_resp_read_done(struct tevent_req *subreq)
        ret = read_packet_recv(subreq, state, &buf, &err);
        TALLOC_FREE(subreq);
        if (ret == -1) {
-               async_req_error(req, map_wbc_err_from_errno(err));
+               tevent_req_error(req, map_wbc_err_from_errno(err));
                return;
        }
 
@@ -349,17 +348,17 @@ static void wb_resp_read_done(struct tevent_req *subreq)
        } else {
                state->wb_resp->extra_data.data = NULL;
        }
-       async_req_done(req);
+       tevent_req_done(req);
 }
 
-wbcErr wb_resp_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
+wbcErr wb_resp_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                         struct winbindd_response **presp)
 {
-       struct resp_read_state *state = talloc_get_type_abort(
-               req->private_data, struct resp_read_state);
+       struct resp_read_state *state = tevent_req_data(
+               req, struct resp_read_state);
        wbcErr wbc_err;
 
-       if (async_req_is_wbcerr(req, &wbc_err)) {
+       if (tevent_req_is_wbcerr(req, &wbc_err)) {
                return wbc_err;
        }
        *presp = talloc_move(mem_ctx, &state->wb_resp);
index 254e57b5f2e18aa3d92d7d114ec4c4db2bd6e730..d299914c7326eac0f6fd0b41c216a341a6744ff1 100644 (file)
@@ -295,7 +295,7 @@ struct wb_int_trans_state {
 };
 
 static void wb_int_trans_write_done(struct tevent_req *subreq);
-static void wb_int_trans_read_done(struct async_req *subreq);
+static void wb_int_trans_read_done(struct tevent_req *subreq);
 
 static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx,
                                           struct tevent_context *ev, int fd,
@@ -345,7 +345,6 @@ static void wb_int_trans_write_done(struct tevent_req *subreq)
                subreq, struct async_req);
        struct wb_int_trans_state *state = talloc_get_type_abort(
                req->private_data, struct wb_int_trans_state);
-       struct async_req *subreq2;
        wbcErr wbc_err;
 
        wbc_err = wb_req_write_recv(subreq);
@@ -355,18 +354,17 @@ static void wb_int_trans_write_done(struct tevent_req *subreq)
                return;
        }
 
-       subreq2 = wb_resp_read_send(state, state->ev, state->fd);
-       if (async_req_nomem(subreq2, req)) {
+       subreq = wb_resp_read_send(state, state->ev, state->fd);
+       if (async_req_nomem(subreq, req)) {
                return;
        }
-       subreq2->async.fn = wb_int_trans_read_done;
-       subreq2->async.priv = req;
+       tevent_req_set_callback(subreq, wb_int_trans_read_done, req);
 }
 
-static void wb_int_trans_read_done(struct async_req *subreq)
+static void wb_int_trans_read_done(struct tevent_req *subreq)
 {
-       struct async_req *req = talloc_get_type_abort(
-               subreq->async.priv, struct async_req);
+       struct async_req *req = tevent_req_callback_data(
+               subreq, struct async_req);
        struct wb_int_trans_state *state = talloc_get_type_abort(
                req->private_data, struct wb_int_trans_state);
        wbcErr wbc_err;