diff options
author | Simo Sorce <idra@samba.org> | 2009-02-28 15:44:30 -0500 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2009-03-02 11:02:09 -0500 |
commit | 67d41d0fc7567cf141b12e866dd227d393e33551 (patch) | |
tree | 117ee0ddd513e0d2008c02d9ff5ead1dd7818ccc /lib/async_req | |
parent | 04a2b455a0385fc3aa23850d4841ab3495efc3e6 (diff) | |
download | samba-67d41d0fc7567cf141b12e866dd227d393e33551.tar.gz samba-67d41d0fc7567cf141b12e866dd227d393e33551.tar.bz2 samba-67d41d0fc7567cf141b12e866dd227d393e33551.zip |
Make struct tevent_req opaque
Move struct tevent_req in tevent_internal, and ad getters and setters
for private data and the callback function.
This patch also renames 'private_state' into 'data'. What is held in this
pointer is in fact data and not a state like enum tevent_req_state.
Calling it 'state' is confusing.
The functions addedd are:
tevent_req_set_callback() - sets req->async.fn and req->async.private_data
tevent_req_set_print_fn() - sets req->private_print
tevent_req_callback_data() - gets req->async.private_data
tevent_req_data() - gets rea->data
This way it is much simpler to keep API/ABI compatibility in the future.
Diffstat (limited to 'lib/async_req')
-rw-r--r-- | lib/async_req/async_sock.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/async_req/async_sock.c b/lib/async_req/async_sock.c index 1f48697f26..424da952eb 100644 --- a/lib/async_req/async_sock.c +++ b/lib/async_req/async_sock.c @@ -123,8 +123,8 @@ static void async_send_handler(struct tevent_context *ev, { struct tevent_req *req = talloc_get_type_abort( private_data, struct tevent_req); - struct async_send_state *state = talloc_get_type_abort( - req->private_state, struct async_send_state); + struct async_send_state *state = + tevent_req_data(req, struct async_send_state); state->sent = send(state->fd, state->buf, state->len, state->flags); if (state->sent == -1) { @@ -136,8 +136,8 @@ static void async_send_handler(struct tevent_context *ev, ssize_t async_send_recv(struct tevent_req *req, int *perrno) { - struct async_send_state *state = talloc_get_type_abort( - req->private_state, struct async_send_state); + struct async_send_state *state = + tevent_req_data(req, struct async_send_state); if (tevent_req_is_unix_error(req, perrno)) { return -1; @@ -189,8 +189,8 @@ static void async_recv_handler(struct tevent_context *ev, { struct tevent_req *req = talloc_get_type_abort( private_data, struct tevent_req); - struct async_recv_state *state = talloc_get_type_abort( - req->private_state, struct async_recv_state); + struct async_recv_state *state = + tevent_req_data(req, struct async_recv_state); state->received = recv(state->fd, state->buf, state->len, state->flags); @@ -203,8 +203,8 @@ static void async_recv_handler(struct tevent_context *ev, ssize_t async_recv_recv(struct tevent_req *req, int *perrno) { - struct async_recv_state *state = talloc_get_type_abort( - req->private_state, struct async_recv_state); + struct async_recv_state *state = + tevent_req_data(req, struct async_recv_state); if (tevent_req_is_unix_error(req, perrno)) { return -1; @@ -317,8 +317,8 @@ static void async_connect_connected(struct tevent_context *ev, { struct tevent_req *req = talloc_get_type_abort( priv, struct tevent_req); - struct async_connect_state *state = talloc_get_type_abort( - req->private_state, struct async_connect_state); + struct async_connect_state *state = + tevent_req_data(req, struct async_connect_state); TALLOC_FREE(fde); @@ -352,8 +352,8 @@ static void async_connect_connected(struct tevent_context *ev, int async_connect_recv(struct tevent_req *req, int *perrno) { - struct async_connect_state *state = talloc_get_type_abort( - req->private_state, struct async_connect_state); + struct async_connect_state *state = + tevent_req_data(req, struct async_connect_state); int err; fcntl(state->fd, F_SETFL, state->old_sockflags); @@ -420,8 +420,8 @@ static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde, { struct tevent_req *req = talloc_get_type_abort( private_data, struct tevent_req); - struct writev_state *state = talloc_get_type_abort( - req->private_state, struct writev_state); + struct writev_state *state = + tevent_req_data(req, struct writev_state); size_t to_write, written; int i; @@ -467,8 +467,8 @@ static void writev_handler(struct tevent_context *ev, struct tevent_fd *fde, ssize_t writev_recv(struct tevent_req *req, int *perrno) { - struct writev_state *state = talloc_get_type_abort( - req->private_state, struct writev_state); + struct writev_state *state = + tevent_req_data(req, struct writev_state); if (tevent_req_is_unix_error(req, perrno)) { return -1; @@ -531,8 +531,8 @@ static void read_packet_handler(struct tevent_context *ev, { struct tevent_req *req = talloc_get_type_abort( private_data, struct tevent_req); - struct read_packet_state *state = talloc_get_type_abort( - req->private_state, struct read_packet_state); + struct read_packet_state *state = + tevent_req_data(req, struct read_packet_state); size_t total = talloc_get_size(state->buf); ssize_t nread, more; uint8_t *tmp; @@ -584,8 +584,8 @@ static void read_packet_handler(struct tevent_context *ev, ssize_t read_packet_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, uint8_t **pbuf, int *perrno) { - struct read_packet_state *state = talloc_get_type_abort( - req->private_state, struct read_packet_state); + struct read_packet_state *state = + tevent_req_data(req, struct read_packet_state); if (tevent_req_is_unix_error(req, perrno)) { return -1; |