mirror of
https://github.com/samba-team/samba.git
synced 2025-01-27 14:04:05 +03:00
struct async_req doesn't really need to carry an event_context
This commit is contained in:
parent
141b76d747
commit
27abf6731e
@ -96,13 +96,6 @@ struct async_req {
|
||||
**/
|
||||
NTSTATUS status;
|
||||
|
||||
/**
|
||||
* @brief The event context we are using
|
||||
*
|
||||
* The event context that this async request works on.
|
||||
*/
|
||||
struct event_context *event_ctx;
|
||||
|
||||
/**
|
||||
* @brief What to do on completion
|
||||
*
|
||||
@ -122,7 +115,7 @@ struct async_req {
|
||||
} async;
|
||||
};
|
||||
|
||||
struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev);
|
||||
struct async_req *async_req_new(TALLOC_CTX *mem_ctx);
|
||||
|
||||
char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req);
|
||||
|
||||
@ -130,7 +123,8 @@ void async_req_done(struct async_req *req);
|
||||
|
||||
void async_req_error(struct async_req *req, NTSTATUS status);
|
||||
|
||||
bool async_post_status(struct async_req *req, NTSTATUS status);
|
||||
bool async_post_status(struct async_req *req, struct event_context *ev,
|
||||
NTSTATUS status);
|
||||
|
||||
bool async_req_nomem(const void *p, struct async_req *req);
|
||||
|
||||
|
@ -49,7 +49,7 @@ char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req)
|
||||
* The new async request will be initialized in state ASYNC_REQ_IN_PROGRESS
|
||||
*/
|
||||
|
||||
struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev)
|
||||
struct async_req *async_req_new(TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct async_req *result;
|
||||
|
||||
@ -58,7 +58,6 @@ struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev)
|
||||
return NULL;
|
||||
}
|
||||
result->state = ASYNC_REQ_IN_PROGRESS;
|
||||
result->event_ctx = ev;
|
||||
result->print = async_req_print;
|
||||
return result;
|
||||
}
|
||||
@ -135,12 +134,12 @@ static void async_trigger(struct event_context *ev, struct timed_event *te,
|
||||
* conventions, independent of whether the request was actually deferred.
|
||||
*/
|
||||
|
||||
bool async_post_status(struct async_req *req, NTSTATUS status)
|
||||
bool async_post_status(struct async_req *req, struct event_context *ev,
|
||||
NTSTATUS status)
|
||||
{
|
||||
req->status = status;
|
||||
|
||||
if (event_add_timed(req->event_ctx, req, timeval_zero(),
|
||||
"async_trigger",
|
||||
if (event_add_timed(ev, req, timeval_zero(), "async_trigger",
|
||||
async_trigger, req) == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ static struct async_req *async_syscall_new(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *result;
|
||||
struct async_syscall_state *state;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -628,7 +628,8 @@ struct async_req *async_connect(TALLOC_CTX *mem_ctx, struct event_context *ev,
|
||||
p->old_sockflags = sys_fcntl_long(fd, F_GETFL, 0);
|
||||
|
||||
if (p->old_sockflags == -1) {
|
||||
if (async_post_status(result, map_nt_error_from_unix(errno))) {
|
||||
if (async_post_status(result, ev,
|
||||
map_nt_error_from_unix(errno))) {
|
||||
return result;
|
||||
}
|
||||
TALLOC_FREE(result);
|
||||
@ -641,7 +642,7 @@ struct async_req *async_connect(TALLOC_CTX *mem_ctx, struct event_context *ev,
|
||||
|
||||
if (state->result.result_int == 0) {
|
||||
state->sys_errno = 0;
|
||||
if (async_post_status(result, NT_STATUS_OK)) {
|
||||
if (async_post_status(result, ev, NT_STATUS_OK)) {
|
||||
return result;
|
||||
}
|
||||
sys_fcntl_long(fd, F_SETFL, p->old_sockflags);
|
||||
@ -664,7 +665,8 @@ struct async_req *async_connect(TALLOC_CTX *mem_ctx, struct event_context *ev,
|
||||
|
||||
state->sys_errno = errno;
|
||||
|
||||
if (async_post_status(result, map_nt_error_from_unix(errno))) {
|
||||
if (async_post_status(result, ev,
|
||||
map_nt_error_from_unix(errno))) {
|
||||
return result;
|
||||
}
|
||||
sys_fcntl_long(fd, F_SETFL, p->old_sockflags);
|
||||
|
@ -435,7 +435,7 @@ static struct async_req *cli_request_chain(TALLOC_CTX *mem_ctx,
|
||||
req->async = tmp_reqs;
|
||||
req->num_async += 1;
|
||||
|
||||
req->async[req->num_async-1] = async_req_new(mem_ctx, ev);
|
||||
req->async[req->num_async-1] = async_req_new(mem_ctx);
|
||||
if (req->async[req->num_async-1] == NULL) {
|
||||
DEBUG(0, ("async_req_new failed\n"));
|
||||
req->num_async -= 1;
|
||||
|
@ -278,7 +278,7 @@ struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx,
|
||||
struct cli_pull_state *state;
|
||||
int i;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
goto failed;
|
||||
}
|
||||
@ -302,7 +302,7 @@ struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx,
|
||||
state->top_req = 0;
|
||||
|
||||
if (size == 0) {
|
||||
if (!async_post_status(result, NT_STATUS_OK)) {
|
||||
if (!async_post_status(result, ev, NT_STATUS_OK)) {
|
||||
goto failed;
|
||||
}
|
||||
return result;
|
||||
@ -843,7 +843,7 @@ static struct async_req *cli_writeall_send(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *subreq;
|
||||
struct cli_writeall_state *state;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
@ -969,7 +969,7 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
|
||||
struct cli_push_state *state;
|
||||
int i;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
goto failed;
|
||||
}
|
||||
@ -1034,7 +1034,7 @@ struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
if (!async_post_status(result, NT_STATUS_OK)) {
|
||||
if (!async_post_status(result, ev, NT_STATUS_OK)) {
|
||||
goto failed;
|
||||
}
|
||||
return result;
|
||||
|
@ -43,7 +43,7 @@ struct async_req *wb_req_read_send(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *result, *subreq;
|
||||
struct req_read_state *state;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -205,7 +205,7 @@ struct async_req *wb_req_write_send(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *result, *subreq;
|
||||
struct req_write_state *state;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -304,7 +304,7 @@ struct async_req *wb_resp_read_send(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *result, *subreq;
|
||||
struct resp_read_state *state;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -458,7 +458,7 @@ struct async_req *wb_resp_write_send(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *result, *subreq;
|
||||
struct resp_write_state *state;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@ -564,7 +564,7 @@ struct async_req *wb_trans_send(TALLOC_CTX *mem_ctx,
|
||||
struct async_req *result, *subreq;
|
||||
struct wb_trans_state *state;
|
||||
|
||||
result = async_req_new(mem_ctx, ev);
|
||||
result = async_req_new(mem_ctx);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user