Slightly restructure the async winbind request calling convention
authorVolker Lendecke <vl@samba.org>
Fri, 31 Jul 2009 14:16:24 +0000 (16:16 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 31 Jul 2009 15:28:53 +0000 (17:28 +0200)
The main loop now allocates the response, this has to be done everywhere

source3/winbindd/wb_ping.c
source3/winbindd/winbindd.c
source3/winbindd/winbindd.h
source3/winbindd/winbindd_proto.h

index 56ecc6671c231174cb6f0f2c5aedff358927be0d..12013984376b06b2c08d77f1b73db1fb35419d8d 100644 (file)
@@ -39,15 +39,7 @@ struct tevent_req *wb_ping_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
        return req;
 }
 
-NTSTATUS wb_ping_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-                     struct winbindd_response **presp)
+NTSTATUS wb_ping_recv(struct tevent_req *req, struct winbindd_response *presp)
 {
-       struct winbindd_response *resp;
-
-       resp = talloc_zero(mem_ctx, struct winbindd_response);
-       if (resp == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
-       *presp = resp;
        return NT_STATUS_OK;
 }
index 6863e93415fc8ab4bc42ac520c20b7d738180f04..4b6ebd2c42e5f251711aa393ce365847f9ad882a 100644 (file)
@@ -519,8 +519,8 @@ struct winbindd_async_dispatch_table {
        struct tevent_req *(*send_req)(TALLOC_CTX *mem_ctx,
                                       struct tevent_context *ev,
                                       struct winbindd_request *request);
-       NTSTATUS (*recv_req)(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-                            struct winbindd_response **presp);
+       NTSTATUS (*recv_req)(struct tevent_req *req,
+                            struct winbindd_response *presp);
 };
 
 static struct winbindd_async_dispatch_table async_nonpriv_table[] = {
@@ -602,17 +602,22 @@ static void wb_request_done(struct tevent_req *req)
        struct winbindd_cli_state *state = tevent_req_callback_data(
                req, struct winbindd_cli_state);
        NTSTATUS status;
-       struct winbindd_response *response;
 
-       status = state->recv_fn(req, state->mem_ctx, &response);
+       state->response = talloc_zero(state, struct winbindd_response);
+       if (state->response == NULL) {
+               remove_client(state);
+               return;
+       }
+       state->response->result = WINBINDD_PENDING;
+       state->response->length = sizeof(struct winbindd_response);
+
+       status = state->recv_fn(req, state->response);
        TALLOC_FREE(req);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("returning %s\n", nt_errstr(status)));
                request_error(state);
+               return;
        }
-       state->response = response;
-       state->response->result = WINBINDD_PENDING;
-       state->response->length = sizeof(struct winbindd_response);
        request_ok(state);
 }
 
index 804c0afa5d78f6649da4e7ac8686268235cbc992..e6bf8a5e833251a1208d2c1db4b50dec066422aa 100644 (file)
@@ -55,8 +55,8 @@ struct winbindd_cli_state {
        bool privileged;                           /* Is the client 'privileged' */
 
        TALLOC_CTX *mem_ctx;                      /* memory per request */
-       NTSTATUS (*recv_fn)(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-                           struct winbindd_response **presp);
+       NTSTATUS (*recv_fn)(struct tevent_req *req,
+                           struct winbindd_response *presp);
        struct winbindd_request *request;         /* Request from client */
        struct tevent_queue *out_queue;
        struct winbindd_response *response;        /* Respose to client */
index 35863e930e579367d389aa334d7658df3f15b292..03e254cbb96a2ee2ca71b45c3de51caa1b5d905d 100644 (file)
@@ -588,8 +588,8 @@ void winbindd_wins_byname(struct winbindd_cli_state *state);
 
 struct tevent_req *wb_ping_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                                struct winbindd_request *request);
-NTSTATUS wb_ping_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-                     struct winbindd_response **presp);
+NTSTATUS wb_ping_recv(struct tevent_req *req,
+                     struct winbindd_response *resp);
 
 enum winbindd_result winbindd_dual_ping(struct winbindd_domain *domain,
                                        struct winbindd_cli_state *state);