summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2009-02-28 15:44:30 -0500
committerSimo Sorce <idra@samba.org>2009-03-02 11:02:09 -0500
commit67d41d0fc7567cf141b12e866dd227d393e33551 (patch)
tree117ee0ddd513e0d2008c02d9ff5ead1dd7818ccc /source3
parent04a2b455a0385fc3aa23850d4841ab3495efc3e6 (diff)
downloadsamba-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 'source3')
-rw-r--r--source3/lib/util_sock.c25
-rw-r--r--source3/lib/wb_reqtrans.c28
-rw-r--r--source3/rpc_client/rpc_transport_sock.c14
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c14
4 files changed, 35 insertions, 46 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 6e75a67a85..3604be369f 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1033,8 +1033,7 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
timeval_current_ofs(0, state->wait_nsec))) {
goto fail;
}
- subreq->async.fn = open_socket_out_connected;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, open_socket_out_connected, result);
return result;
post_status:
@@ -1047,10 +1046,10 @@ struct tevent_req *open_socket_out_send(TALLOC_CTX *mem_ctx,
static void open_socket_out_connected(struct tevent_req *subreq)
{
- struct tevent_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct tevent_req);
- struct open_socket_out_state *state = talloc_get_type_abort(
- req->private_state, struct open_socket_out_state);
+ struct tevent_req *req =
+ tevent_req_callback_data(subreq, struct tevent_req);
+ struct open_socket_out_state *state =
+ tevent_req_data(req, struct open_socket_out_state);
int ret;
int sys_errno;
@@ -1089,8 +1088,7 @@ static void open_socket_out_connected(struct tevent_req *subreq)
tevent_req_nterror(req, NT_STATUS_NO_MEMORY);
return;
}
- subreq->async.fn = open_socket_out_connected;
- subreq->async.private_data = req;
+ tevent_req_set_callback(subreq, open_socket_out_connected, req);
return;
}
@@ -1107,8 +1105,8 @@ static void open_socket_out_connected(struct tevent_req *subreq)
NTSTATUS open_socket_out_recv(struct tevent_req *req, int *pfd)
{
- struct open_socket_out_state *state = talloc_get_type_abort(
- req->private_state, struct open_socket_out_state);
+ struct open_socket_out_state *state =
+ tevent_req_data(req, struct open_socket_out_state);
NTSTATUS status;
if (tevent_req_is_nterror(req, &status)) {
@@ -1217,14 +1215,13 @@ static void open_socket_out_defer_waited(struct async_req *subreq)
if (async_req_nomem(subreq2, req)) {
return;
}
- subreq2->async.fn = open_socket_out_defer_connected;
- subreq2->async.private_data = req;
+ tevent_req_set_callback(subreq2, open_socket_out_defer_connected, req);
}
static void open_socket_out_defer_connected(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct open_socket_out_defer_state *state = talloc_get_type_abort(
req->private_data, struct open_socket_out_defer_state);
NTSTATUS status;
diff --git a/source3/lib/wb_reqtrans.c b/source3/lib/wb_reqtrans.c
index 65906dcb91..63a25fb896 100644
--- a/source3/lib/wb_reqtrans.c
+++ b/source3/lib/wb_reqtrans.c
@@ -103,8 +103,7 @@ struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
goto nomem;
}
- subreq->async.fn = wb_req_read_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wb_req_read_done, result);
return result;
nomem:
TALLOC_FREE(result);
@@ -140,8 +139,8 @@ static ssize_t wb_req_more(uint8_t *buf, size_t buflen, void *private_data)
static void wb_req_read_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct req_read_state *state = talloc_get_type_abort(
req->private_data, struct req_read_state);
int err;
@@ -213,8 +212,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = wb_req_write_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(wb_req_write_done, result);
return result;
fail:
@@ -224,8 +222,8 @@ 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 = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
int err;
ssize_t ret;
@@ -266,8 +264,7 @@ struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto nomem;
}
- subreq->async.fn = wb_resp_read_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wb_resp_read_done, result);
return result;
nomem:
@@ -293,8 +290,8 @@ static ssize_t wb_resp_more(uint8_t *buf, size_t buflen, void *private_data)
static void wb_resp_read_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct resp_read_state *state = talloc_get_type_abort(
req->private_data, struct resp_read_state);
uint8_t *buf;
@@ -367,8 +364,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = wb_resp_write_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, wb_resp_write_done, result);
return result;
fail:
@@ -378,8 +374,8 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
static void wb_resp_write_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_re_callback_data(subreq, struct async_req);
int err;
ssize_t ret;
diff --git a/source3/rpc_client/rpc_transport_sock.c b/source3/rpc_client/rpc_transport_sock.c
index 658ffe30d6..b1d9d8fbe1 100644
--- a/source3/rpc_client/rpc_transport_sock.c
+++ b/source3/rpc_client/rpc_transport_sock.c
@@ -61,8 +61,7 @@ static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = rpc_sock_read_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, rpc_sock_read_done, result);
return result;
fail:
TALLOC_FREE(result);
@@ -71,8 +70,8 @@ static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
static void rpc_sock_read_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct rpc_sock_read_state *state = talloc_get_type_abort(
req->private_data, struct rpc_sock_read_state);
int err;
@@ -123,8 +122,7 @@ static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
if (subreq == NULL) {
goto fail;
}
- subreq->async.fn = rpc_sock_write_done;
- subreq->async.private_data = result;
+ tevent_req_set_callback(subreq, rpc_sock_write_done, result);
return result;
fail:
TALLOC_FREE(result);
@@ -133,8 +131,8 @@ static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
static void rpc_sock_write_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ struct async_req *req =
+ tevent_req_callback_data(subreq, struct async_req);
struct rpc_sock_write_state *state = talloc_get_type_abort(
req->private_data, struct rpc_sock_write_state);
int err;
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index 33e89c8acb..a5d059c06a 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -1247,14 +1247,13 @@ static void np_write_trigger(struct async_req *req)
if (async_req_nomem(subreq, req)) {
return;
}
- subreq->async.fn = np_write_done;
- subreq->async.private_data = req;
+ tevent_req_set_callback(subreq, np_write_done, req);
}
static void np_write_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ 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);
ssize_t received;
@@ -1398,14 +1397,13 @@ static void np_read_trigger(struct async_req *req)
if (async_req_nomem(subreq, req)) {
return;
}
- subreq->async.fn = np_read_done;
- subreq->async.private_data = req;
+ tevent_req_set_callback(subreq, np_read_done, req);
}
static void np_read_done(struct tevent_req *subreq)
{
- struct async_req *req = talloc_get_type_abort(
- subreq->async.private_data, struct async_req);
+ 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);
ssize_t received;