diff options
author | Volker Lendecke <vl@samba.org> | 2009-03-01 19:43:07 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-03-08 11:20:59 +0100 |
commit | fe486d7b9f580a17d23dd57582087c7d28cb738d (patch) | |
tree | a7e931addabc7b97450771fd6030f886cda39354 | |
parent | 46bcb10b5abb21758cf234764b64220ede1b7ab5 (diff) | |
download | samba-fe486d7b9f580a17d23dd57582087c7d28cb738d.tar.gz samba-fe486d7b9f580a17d23dd57582087c7d28cb738d.tar.bz2 samba-fe486d7b9f580a17d23dd57582087c7d28cb738d.zip |
Add "queue" to writev_send
Unless higher levels queue themselves somehow, writev will *always* be queued.
So the queueing should be done at the right level.
-rw-r--r-- | lib/async_req/async_sock.c | 30 | ||||
-rw-r--r-- | lib/async_req/async_sock.h | 3 | ||||
-rw-r--r-- | source3/lib/wb_reqtrans.c | 4 | ||||
-rw-r--r-- | source3/rpc_server/srv_pipe_hnd.c | 3 |
4 files changed, 34 insertions, 6 deletions
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c index 424da952eb..f803b9cc36 100644 --- a/lib/async_req/async_sock.c +++ b/lib/async_req/async_sock.c @@ -379,11 +379,13 @@ struct writev_state { size_t total_size; }; +static void writev_trigger(struct tevent_req *req, void *private_data); static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, void *private_data); struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - int fd, struct iovec *iov, int count) + struct tevent_queue *queue, int fd, + struct iovec *iov, int count) { struct tevent_req *result; struct writev_state *state; @@ -403,18 +405,42 @@ 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) { goto fail; } return result; - fail: TALLOC_FREE(result); return NULL; } +static void writev_trigger(struct tevent_req *req, void *private_data) +{ + struct writev_state *state = tevent_req_data(req, struct writev_state); + struct tevent_fd *fde; + + fde = tevent_add_fd(state->ev, state, state->fd, TEVENT_FD_WRITE, + writev_handler, req); + if (fde == NULL) { + tevent_req_error(req, ENOMEM); + } +} + static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, void *private_data) { diff --git a/lib/async_req/async_sock.h b/lib/async_req/async_sock.h index e001709d27..c5d9400eb6 100644 --- a/lib/async_req/async_sock.h +++ b/lib/async_req/async_sock.h @@ -43,7 +43,8 @@ struct tevent_req *async_connect_send(TALLOC_CTX *mem_ctx, int async_connect_recv(struct tevent_req *req, int *perrno); struct tevent_req *writev_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - int fd, struct iovec *iov, int count); + struct tevent_queue *queue, int fd, + struct iovec *iov, int count); ssize_t writev_recv(struct tevent_req *req, int *perrno); struct tevent_req *read_packet_send(TALLOC_CTX *mem_ctx, diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c index 222b64667c..26dfb783ab 100644 --- a/source3/lib/wb_reqtrans.c +++ b/source3/lib/wb_reqtrans.c @@ -208,7 +208,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, fd, state->iov, count); + subreq = writev_send(state, ev, NULL, fd, state->iov, count); if (subreq == NULL) { goto fail; } @@ -360,7 +360,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx, count = 2; } - subreq = writev_send(state, ev, fd, state->iov, count); + subreq = writev_send(state, ev, NULL, fd, state->iov, count); if (subreq == NULL) { goto fail; } diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c index a5d059c06a..fb7aca5c0f 100644 --- a/source3/rpc_server/srv_pipe_hnd.c +++ b/source3/rpc_server/srv_pipe_hnd.c @@ -1243,7 +1243,8 @@ static void np_write_trigger(struct async_req *req) req->private_data, struct np_write_state); struct tevent_req *subreq; - subreq = writev_send(state, state->ev, state->p->fd, &state->iov, 1); + subreq = writev_send(state, state->ev, NULL, state->p->fd, + &state->iov, 1); if (async_req_nomem(subreq, req)) { return; } |