The branch, v3-4-test has been updated
       via  fc0dfba28f3c6e22b1d4bb19577e735c3db16f1e (commit)
       via  1f9bfa0673d47adcd62ceee5605788cc11201f3c (commit)
       via  15ff8c88fbf1f417e8a0b0e0c25524d692d63a37 (commit)
      from  336663c921dafecb19323bbff00062779b81ff7c (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test


- Log -----------------------------------------------------------------
commit fc0dfba28f3c6e22b1d4bb19577e735c3db16f1e
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Mar 17 09:38:14 2009 +0100

    Remove some transitional code in writev_send

commit 1f9bfa0673d47adcd62ceee5605788cc11201f3c
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Mar 17 09:34:17 2009 +0100

    Convert np_read to tevent_req

commit 15ff8c88fbf1f417e8a0b0e0c25524d692d63a37
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Mar 17 09:17:16 2009 +0100

    Convert np_write to tevent_req

-----------------------------------------------------------------------

Summary of changes:
 lib/async_req/async_sock.c        |   18 +-----
 source3/include/proto.h           |   14 ++--
 source3/rpc_server/srv_pipe_hnd.c |  130 ++++++++++++++++++-------------------
 source3/smbd/ipc.c                |   26 ++++----
 source3/smbd/pipes.c              |   42 ++++++------
 5 files changed, 103 insertions(+), 127 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c
index be24bae..77df406 100644
--- a/lib/async_req/async_sock.c
+++ b/lib/async_req/async_sock.c
@@ -389,7 +389,6 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct 
tevent_context *ev,
 {
        struct tevent_req *result;
        struct writev_state *state;
-       struct tevent_fd *fde;
 
        result = tevent_req_create(mem_ctx, &state, struct writev_state);
        if (result == NULL) {
@@ -405,22 +404,7 @@ struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct 
tevent_context *ev,
                goto fail;
        }
 
-       /*
-        * This if () should go away once our callers are converted to always
-        * pass in a queue.
-        */
-
-       if (queue != NULL) {
-               if (!tevent_queue_add(queue, ev, result, writev_trigger,
-                                     NULL)) {
-                       goto fail;
-               }
-               return result;
-       }
-
-       fde = tevent_add_fd(ev, state, fd, TEVENT_FD_WRITE, writev_handler,
-                           result);
-       if (fde == NULL) {
+       if (!tevent_queue_add(queue, ev, result, writev_trigger, NULL)) {
                goto fail;
        }
        return result;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5c9404a..6510018 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5915,14 +5915,14 @@ NTSTATUS np_open(TALLOC_CTX *mem_ctx, const char *name,
                 const char *client_address,
                 struct auth_serversupplied_info *server_info,
                 struct fake_file_handle **phandle);
-struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+                                struct fake_file_handle *handle,
+                                const uint8_t *data, size_t len);
+NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten);
+struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
                                struct fake_file_handle *handle,
-                               const uint8_t *data, size_t len);
-NTSTATUS np_write_recv(struct async_req *req, ssize_t *nwritten);
-struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-                              struct fake_file_handle *handle,
-                              uint8_t *data, size_t len);
-NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread,
+                               uint8_t *data, size_t len);
+NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
                      bool *is_data_outstanding);
 
 /* The following definitions come from rpc_server/srv_samr_util.c  */
diff --git a/source3/rpc_server/srv_pipe_hnd.c 
b/source3/rpc_server/srv_pipe_hnd.c
index fb7aca5..503e22b 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -943,8 +943,8 @@ bool fsp_is_np(struct files_struct *fsp)
 }
 
 struct np_proxy_state {
-       struct async_req_queue *read_queue;
-       struct async_req_queue *write_queue;
+       struct tevent_queue *read_queue;
+       struct tevent_queue *write_queue;
        int fd;
 
        uint8_t *msg;
@@ -1104,11 +1104,11 @@ static struct np_proxy_state 
*make_external_rpc_pipe_p(TALLOC_CTX *mem_ctx,
 
        result->msg = NULL;
 
-       result->read_queue = async_req_queue_init(result);
+       result->read_queue = tevent_queue_create(result, "np_read");
        if (result->read_queue == NULL) {
                goto fail;
        }
-       result->write_queue = async_req_queue_init(result);
+       result->write_queue = tevent_queue_create(result, "np_write");
        if (result->write_queue == NULL) {
                goto fail;
        }
@@ -1175,22 +1175,21 @@ struct np_write_state {
        ssize_t nwritten;
 };
 
-static void np_write_trigger(struct async_req *req);
 static void np_write_done(struct tevent_req *subreq);
 
-struct async_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-                               struct fake_file_handle *handle,
-                               const uint8_t *data, size_t len)
+struct tevent_req *np_write_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+                                struct fake_file_handle *handle,
+                                const uint8_t *data, size_t len)
 {
-       struct async_req *result;
+       struct tevent_req *req;
        struct np_write_state *state;
        NTSTATUS status;
 
        DEBUG(6, ("np_write_send: len: %d\n", (int)len));
        dump_data(50, data, len);
 
-       if (!async_req_setup(mem_ctx, &result, &state,
-                            struct np_write_state)) {
+       req = tevent_req_create(mem_ctx, &state, struct np_write_state);
+       if (req == NULL) {
                return NULL;
        }
 
@@ -1214,68 +1213,60 @@ struct async_req *np_write_send(TALLOC_CTX *mem_ctx, 
struct event_context *ev,
        if (handle->type == FAKE_FILE_TYPE_NAMED_PIPE_PROXY) {
                struct np_proxy_state *p = talloc_get_type_abort(
                        handle->private_data, struct np_proxy_state);
+               struct tevent_req *subreq;
 
                state->ev = ev;
                state->p = p;
                state->iov.iov_base = CONST_DISCARD(void *, data);
                state->iov.iov_len = len;
 
-               if (!async_req_enqueue(p->write_queue, ev, result,
-                                      np_write_trigger)) {
+               subreq = writev_send(state, ev, p->write_queue, p->fd,
+                                    &state->iov, 1);
+               if (subreq == NULL) {
                        goto fail;
                }
-               return result;
+               tevent_req_set_callback(subreq, np_write_done, req);
+               return req;
        }
 
        status = NT_STATUS_INVALID_HANDLE;
  post_status:
-       if (async_post_ntstatus(result, ev, status)) {
-               return result;
+       if (NT_STATUS_IS_OK(status)) {
+               tevent_req_done(req);
+       } else {
+               tevent_req_nterror(req, status);
        }
+       return tevent_req_post(req, ev);
  fail:
-       TALLOC_FREE(result);
+       TALLOC_FREE(req);
        return NULL;
 }
 
-static void np_write_trigger(struct async_req *req)
-{
-       struct np_write_state *state = talloc_get_type_abort(
-               req->private_data, struct np_write_state);
-       struct tevent_req *subreq;
-
-       subreq = writev_send(state, state->ev, NULL, state->p->fd,
-                            &state->iov, 1);
-       if (async_req_nomem(subreq, req)) {
-               return;
-       }
-       tevent_req_set_callback(subreq, np_write_done, req);
-}
-
 static void np_write_done(struct tevent_req *subreq)
 {
-       struct async_req *req =
-               tevent_req_callback_data(subreq, struct async_req);
-       struct np_write_state *state = talloc_get_type_abort(
-               req->private_data, struct np_write_state);
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct np_write_state *state = tevent_req_data(
+               req, struct np_write_state);
        ssize_t received;
        int err;
 
        received = writev_recv(subreq, &err);
        if (received < 0) {
-               async_req_nterror(req, map_nt_error_from_unix(err));
+               tevent_req_nterror(req, map_nt_error_from_unix(err));
                return;
        }
        state->nwritten = received;
-       async_req_done(req);
+       tevent_req_done(req);
 }
 
-NTSTATUS np_write_recv(struct async_req *req, ssize_t *pnwritten)
+NTSTATUS np_write_recv(struct tevent_req *req, ssize_t *pnwritten)
 {
-       struct np_write_state *state = talloc_get_type_abort(
-               req->private_data, struct np_write_state);
+       struct np_write_state *state = tevent_req_data(
+               req, struct np_write_state);
        NTSTATUS status;
 
-       if (async_req_is_nterror(req, &status)) {
+       if (tevent_req_is_nterror(req, &status)) {
                return status;
        }
        *pnwritten = state->nwritten;
@@ -1313,19 +1304,19 @@ struct np_read_state {
        bool is_data_outstanding;
 };
 
-static void np_read_trigger(struct async_req *req);
+static void np_read_trigger(struct tevent_req *req, void *private_data);
 static void np_read_done(struct tevent_req *subreq);
 
-struct async_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-                              struct fake_file_handle *handle,
-                              uint8_t *data, size_t len)
+struct tevent_req *np_read_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+                               struct fake_file_handle *handle,
+                               uint8_t *data, size_t len)
 {
-       struct async_req *result;
+       struct tevent_req *req;
        struct np_read_state *state;
        NTSTATUS status;
 
-       if (!async_req_setup(mem_ctx, &result, &state,
-                            struct np_read_state)) {
+       req = tevent_req_create(mem_ctx, &state, struct np_read_state);
+       if (req == NULL) {
                return NULL;
        }
 
@@ -1370,32 +1361,35 @@ struct async_req *np_read_send(TALLOC_CTX *mem_ctx, 
struct event_context *ev,
                state->data = data;
                state->len = len;
 
-               if (!async_req_enqueue(p->read_queue, ev, result,
-                                      np_read_trigger)) {
+               if (!tevent_queue_add(p->read_queue, ev, req, np_read_trigger,
+                                     NULL)) {
                        goto fail;
                }
-               return result;
+               return req;
        }
 
        status = NT_STATUS_INVALID_HANDLE;
  post_status:
-       if (async_post_ntstatus(result, ev, status)) {
-               return result;
+       if (NT_STATUS_IS_OK(status)) {
+               tevent_req_done(req);
+       } else {
+               tevent_req_nterror(req, status);
        }
+       return tevent_req_post(req, ev);
  fail:
-       TALLOC_FREE(result);
+       TALLOC_FREE(req);
        return NULL;
 }
 
-static void np_read_trigger(struct async_req *req)
+static void np_read_trigger(struct tevent_req *req, void *private_data)
 {
-       struct np_read_state *state = talloc_get_type_abort(
-               req->private_data, struct np_read_state);
+       struct np_read_state *state = tevent_req_callback_data(
+               req, struct np_read_state);
        struct tevent_req *subreq;
 
        subreq = read_packet_send(state, state->ev, state->p->fd,
                                  RPC_HEADER_LEN, rpc_frag_more_fn, NULL);
-       if (async_req_nomem(subreq, req)) {
+       if (tevent_req_nomem(subreq, req)) {
                return;
        }
        tevent_req_set_callback(subreq, np_read_done, req);
@@ -1403,10 +1397,10 @@ static void np_read_trigger(struct async_req *req)
 
 static void np_read_done(struct tevent_req *subreq)
 {
-       struct async_req *req =
-               tevent_req_callback_data(subreq, struct async_req);
-       struct np_read_state *state = talloc_get_type_abort(
-               req->private_data, struct np_read_state);
+       struct tevent_req *req = tevent_req_callback_data(
+               subreq, struct tevent_req);
+       struct np_read_state *state = tevent_req_data(
+               req, struct np_read_state);
        ssize_t received;
        size_t thistime;
        int err;
@@ -1414,7 +1408,7 @@ static void np_read_done(struct tevent_req *subreq)
        received = read_packet_recv(subreq, state->p, &state->p->msg, &err);
        TALLOC_FREE(subreq);
        if (received == -1) {
-               async_req_nterror(req, map_nt_error_from_unix(err));
+               tevent_req_nterror(req, map_nt_error_from_unix(err));
                return;
        }
 
@@ -1431,18 +1425,18 @@ static void np_read_done(struct tevent_req *subreq)
                state->is_data_outstanding = false;
        }
 
-       async_req_done(req);
+       tevent_req_done(req);
        return;
 }
 
-NTSTATUS np_read_recv(struct async_req *req, ssize_t *nread,
+NTSTATUS np_read_recv(struct tevent_req *req, ssize_t *nread,
                      bool *is_data_outstanding)
 {
-       struct np_read_state *state = talloc_get_type_abort(
-               req->private_data, struct np_read_state);
+       struct np_read_state *state = tevent_req_data(
+               req, struct np_read_state);
        NTSTATUS status;
 
-       if (async_req_is_nterror(req, &status)) {
+       if (tevent_req_is_nterror(req, &status)) {
                return status;
        }
        *nread = state->nread;
diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c
index d18b5de..f20c851 100644
--- a/source3/smbd/ipc.c
+++ b/source3/smbd/ipc.c
@@ -211,14 +211,14 @@ struct dcerpc_cmd_state {
        size_t max_read;
 };
 
-static void api_dcerpc_cmd_write_done(struct async_req *subreq);
-static void api_dcerpc_cmd_read_done(struct async_req *subreq);
+static void api_dcerpc_cmd_write_done(struct tevent_req *subreq);
+static void api_dcerpc_cmd_read_done(struct tevent_req *subreq);
 
 static void api_dcerpc_cmd(connection_struct *conn, struct smb_request *req,
                           files_struct *fsp, uint8_t *data, size_t length,
                           size_t max_read)
 {
-       struct async_req *subreq;
+       struct tevent_req *subreq;
        struct dcerpc_cmd_state *state;
 
        if (!fsp_is_np(fsp)) {
@@ -254,14 +254,14 @@ static void api_dcerpc_cmd(connection_struct *conn, 
struct smb_request *req,
                reply_nterror(req, NT_STATUS_NO_MEMORY);
                return;
        }
-       subreq->async.fn = api_dcerpc_cmd_write_done;
-       subreq->async.priv = talloc_move(conn, &req);
+       tevent_req_set_callback(subreq, api_dcerpc_cmd_write_done,
+                               talloc_move(conn, &req));
 }
 
-static void api_dcerpc_cmd_write_done(struct async_req *subreq)
+static void api_dcerpc_cmd_write_done(struct tevent_req *subreq)
 {
-       struct smb_request *req = talloc_get_type_abort(
-               subreq->async.priv, struct smb_request);
+       struct smb_request *req = tevent_req_callback_data(
+               subreq, struct smb_request);
        struct dcerpc_cmd_state *state = talloc_get_type_abort(
                req->async_priv, struct dcerpc_cmd_state);
        NTSTATUS status;
@@ -290,9 +290,7 @@ static void api_dcerpc_cmd_write_done(struct async_req 
*subreq)
                reply_nterror(req, NT_STATUS_NO_MEMORY);
                goto send;
        }
-
-       subreq->async.fn = api_dcerpc_cmd_read_done;
-       subreq->async.priv = req;
+       tevent_req_set_callback(subreq, api_dcerpc_cmd_read_done, req);
        return;
 
  send:
@@ -305,10 +303,10 @@ static void api_dcerpc_cmd_write_done(struct async_req 
*subreq)
        TALLOC_FREE(req);
 }
 
-static void api_dcerpc_cmd_read_done(struct async_req *subreq)
+static void api_dcerpc_cmd_read_done(struct tevent_req *subreq)
 {
-       struct smb_request *req = talloc_get_type_abort(
-               subreq->async.priv, struct smb_request);
+       struct smb_request *req = tevent_req_callback_data(
+               subreq, struct smb_request);
        struct dcerpc_cmd_state *state = talloc_get_type_abort(
                req->async_priv, struct dcerpc_cmd_state);
        NTSTATUS status;
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index 6fd4031..2686cf4 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -148,14 +148,14 @@ struct pipe_write_state {
        size_t numtowrite;
 };
 
-static void pipe_write_done(struct async_req *subreq);
+static void pipe_write_done(struct tevent_req *subreq);
 
 void reply_pipe_write(struct smb_request *req)
 {
        files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
        const uint8_t *data;
        struct pipe_write_state *state;
-       struct async_req *subreq;
+       struct tevent_req *subreq;
 
        if (!fsp_is_np(fsp)) {
                reply_doserror(req, ERRDOS, ERRbadfid);
@@ -188,14 +188,14 @@ void reply_pipe_write(struct smb_request *req)
                reply_nterror(req, NT_STATUS_NO_MEMORY);
                return;
        }
-       subreq->async.fn = pipe_write_done;
-       subreq->async.priv = talloc_move(req->conn, &req);
+       tevent_req_set_callback(subreq, pipe_write_done,
+                               talloc_move(req->conn, &req));
 }
 
-static void pipe_write_done(struct async_req *subreq)
+static void pipe_write_done(struct tevent_req *subreq)
 {
-       struct smb_request *req = talloc_get_type_abort(
-               subreq->async.priv, struct smb_request);
+       struct smb_request *req = tevent_req_callback_data(
+               subreq, struct smb_request);
        struct pipe_write_state *state = talloc_get_type_abort(
                req->async_priv, struct pipe_write_state);
        NTSTATUS status;
@@ -235,7 +235,7 @@ struct pipe_write_andx_state {
        size_t numtowrite;
 };
 
-static void pipe_write_andx_done(struct async_req *subreq);
+static void pipe_write_andx_done(struct tevent_req *subreq);
 
 void reply_pipe_write_and_X(struct smb_request *req)
 {
@@ -243,7 +243,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
        int smb_doff = SVAL(req->vwv+11, 0);
        uint8_t *data;
        struct pipe_write_andx_state *state;
-       struct async_req *subreq;
+       struct tevent_req *subreq;
 
        if (!fsp_is_np(fsp)) {
                reply_doserror(req, ERRDOS, ERRbadfid);
@@ -297,14 +297,14 @@ void reply_pipe_write_and_X(struct smb_request *req)
                reply_nterror(req, NT_STATUS_NO_MEMORY);
                return;
        }
-       subreq->async.fn = pipe_write_andx_done;
-       subreq->async.priv = talloc_move(req->conn, &req);
+       tevent_req_set_callback(subreq, pipe_write_andx_done,
+                               talloc_move(req->conn, &req));
 }
 
-static void pipe_write_andx_done(struct async_req *subreq)
+static void pipe_write_andx_done(struct tevent_req *subreq)
 {
-       struct smb_request *req = talloc_get_type_abort(
-               subreq->async.priv, struct smb_request);
+       struct smb_request *req = tevent_req_callback_data(
+               subreq, struct smb_request);
        struct pipe_write_andx_state *state = talloc_get_type_abort(
                req->async_priv, struct pipe_write_andx_state);
        NTSTATUS status;
@@ -340,14 +340,14 @@ struct pipe_read_andx_state {
        int smb_maxcnt;
 };
 
-static void pipe_read_andx_done(struct async_req *subreq);
+static void pipe_read_andx_done(struct tevent_req *subreq);
 
 void reply_pipe_read_and_X(struct smb_request *req)
 {
        files_struct *fsp = file_fsp(req, SVAL(req->vwv+0, 0));
        uint8_t *data;
        struct pipe_read_andx_state *state;
-       struct async_req *subreq;
+       struct tevent_req *subreq;
 
        /* we don't use the offset given to use for pipe reads. This
            is deliberate, instead we always return the next lump of
@@ -392,14 +392,14 @@ void reply_pipe_read_and_X(struct smb_request *req)
                reply_nterror(req, NT_STATUS_NO_MEMORY);
                return;
        }
-       subreq->async.fn = pipe_read_andx_done;


-- 
Samba Shared Repository

Reply via email to