summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-03-01 19:43:07 +0100
committerVolker Lendecke <vl@samba.org>2009-03-08 11:20:59 +0100
commitfe486d7b9f580a17d23dd57582087c7d28cb738d (patch)
treea7e931addabc7b97450771fd6030f886cda39354 /lib
parent46bcb10b5abb21758cf234764b64220ede1b7ab5 (diff)
downloadsamba-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.
Diffstat (limited to 'lib')
-rw-r--r--lib/async_req/async_sock.c30
-rw-r--r--lib/async_req/async_sock.h3
2 files changed, 30 insertions, 3 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,