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

index 0ae6c695f03138aa93c9e134cd59998e01353bce..b90a3b71d81d4c0f5084ae184bd3f8d8fc79d377 100644 (file)
@@ -50,11 +50,11 @@ struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
 wbcErr wb_req_read_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
                        struct winbindd_request **preq);
 
-struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
-                                   struct tevent_context *ev, int fd,
-                                   struct winbindd_request *wb_req);
-
-wbcErr wb_req_write_recv(struct async_req *req);
+struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
+                                    struct tevent_context *ev,
+                                    struct tevent_queue *queue, int fd,
+                                    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);
index 2051696a022184ec4c28699a80855fcee124c7a8..9fcef0bb763c7629c2e73c7bcd9dc340b218984e 100644 (file)
@@ -222,17 +222,17 @@ struct req_write_state {
 
 static void wb_req_write_done(struct tevent_req *subreq);
 
-struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
-                                   struct tevent_context *ev, int fd,
-                                   struct winbindd_request *wb_req)
+struct tevent_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
+                                    struct tevent_context *ev,
+                                    struct tevent_queue *queue, int fd,
+                                    struct winbindd_request *wb_req)
 {
-       struct async_req *result;
-       struct tevent_req *subreq;
+       struct tevent_req *result, *subreq;
        struct req_write_state *state;
        int count = 1;
 
-       if (!async_req_setup(mem_ctx, &result, &state,
-                            struct req_write_state)) {
+       result = tevent_req_create(mem_ctx, &state, struct req_write_state);
+       if (result == NULL) {
                return NULL;
        }
 
@@ -245,7 +245,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
                count = 2;
        }
 
-       subreq = writev_send(state, ev, NULL, fd, state->iov, count);
+       subreq = writev_send(state, ev, queue, fd, state->iov, count);
        if (subreq == NULL) {
                goto fail;
        }
@@ -259,23 +259,23 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
 
 static void wb_req_write_done(struct tevent_req *subreq)
 {
-       struct async_req *req =
-               tevent_req_callback_data(subreq, struct async_req);
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
        int err;
        ssize_t ret;
 
        ret = writev_recv(subreq, &err);
        TALLOC_FREE(subreq);
        if (ret < 0) {
-               async_req_error(req, map_wbc_err_from_errno(err));
+               tevent_req_error(req, map_wbc_err_from_errno(err));
                return;
        }
-       async_req_done(req);
+       tevent_req_done(req);
 }
 
-wbcErr wb_req_write_recv(struct async_req *req)
+wbcErr wb_req_write_recv(struct tevent_req *req)
 {
-       return async_req_simple_recv_wbcerr(req);
+       return tevent_req_simple_recv_wbcerr(req);
 }
 
 struct resp_read_state {
index 7034e668ed0917c7b7de0c1249067c63a07647c6..254e57b5f2e18aa3d92d7d114ec4c4db2bd6e730 100644 (file)
@@ -294,7 +294,7 @@ struct wb_int_trans_state {
        struct winbindd_response *wb_resp;
 };
 
-static void wb_int_trans_write_done(struct async_req *subreq);
+static void wb_int_trans_write_done(struct tevent_req *subreq);
 static void wb_int_trans_read_done(struct async_req *subreq);
 
 static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx,
@@ -302,7 +302,7 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx,
                                           struct winbindd_request *wb_req)
 {
        struct async_req *result;
-       struct async_req *subreq;
+       struct tevent_req *subreq;
        struct wb_int_trans_state *state;
 
        if (!async_req_setup(mem_ctx, &result, &state,
@@ -325,12 +325,12 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx,
        state->wb_req->length = sizeof(struct winbindd_request);
        state->wb_req->pid = getpid();
 
-       subreq = wb_req_write_send(state, state->ev, state->fd, state->wb_req);
+       subreq = wb_req_write_send(state, state->ev, NULL, state->fd,
+                                  state->wb_req);
        if (subreq == NULL) {
                goto fail;
        }
-       subreq->async.fn = wb_int_trans_write_done;
-       subreq->async.priv = result;
+       tevent_req_set_callback(subreq, wb_int_trans_write_done, result);
 
        return result;
 
@@ -339,12 +339,13 @@ static struct async_req *wb_int_trans_send(TALLOC_CTX *mem_ctx,
        return NULL;
 }
 
-static void wb_int_trans_write_done(struct async_req *subreq)
+static void wb_int_trans_write_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);
+       struct async_req *subreq2;
        wbcErr wbc_err;
 
        wbc_err = wb_req_write_recv(subreq);
@@ -354,12 +355,12 @@ static void wb_int_trans_write_done(struct async_req *subreq)
                return;
        }
 
-       subreq = wb_resp_read_send(state, state->ev, state->fd);
-       if (subreq == NULL) {
-               async_req_error(req, WBC_ERR_NO_MEMORY);
+       subreq2 = wb_resp_read_send(state, state->ev, state->fd);
+       if (async_req_nomem(subreq2, req)) {
+               return;
        }
-       subreq->async.fn = wb_int_trans_read_done;
-       subreq->async.priv = req;
+       subreq2->async.fn = wb_int_trans_read_done;
+       subreq2->async.priv = req;
 }
 
 static void wb_int_trans_read_done(struct async_req *subreq)