add async_ndr_domain_call() similar to async_domain_request()
authorStefan Metzmacher <metze@sernet.de>
Thu, 6 Sep 2007 16:05:29 +0000 (18:05 +0200)
committerStefan Metzmacher <metze@sernet.de>
Thu, 11 Oct 2007 15:21:46 +0000 (17:21 +0200)
metze

source/winbindd/winbindd_dual.c

index 097180f..c3ad11d 100644 (file)
@@ -575,7 +575,63 @@ static void domain_init_recv(void *private_data_data, BOOL success)
                      state->continuation, state->private_data_data);
 }
 
-static void recvfrom_child(void *private_data_data, BOOL success)
+struct domain_ndr_call_state {
+       TALLOC_CTX *mem_ctx;
+       struct winbindd_domain *domain;
+       struct winbindd_ndr_call *call;
+       void (*continuation)(void *private_data_data, BOOL success);
+       void *private_data_data;
+};
+
+static void domain_ndr_init_recv(void *private_data_data, BOOL success);
+
+void async_ndr_domain_call(TALLOC_CTX *mem_ctx,
+                          struct winbindd_domain *domain,
+                          struct winbindd_ndr_call *call,
+                          void (*continuation)(void *private_data_data, BOOL success),
+                          void *private_data_data)
+{
+       struct domain_ndr_call_state *state;
+
+       if (domain->initialized) {
+               async_ndr_call(mem_ctx, &domain->child, call,
+                              continuation, private_data_data);
+               return;
+       }
+
+       state = TALLOC_P(mem_ctx, struct domain_ndr_call_state);
+       if (state == NULL) {
+               DEBUG(0, ("talloc failed\n"));
+               continuation(private_data_data, False);
+               return;
+       }
+
+       state->mem_ctx = mem_ctx;
+       state->domain = domain;
+       state->call = call;
+       state->continuation = continuation;
+       state->private_data_data = private_data_data;
+
+       init_child_connection(domain, domain_ndr_init_recv, state);
+}
+
+static void domain_ndr_init_recv(void *private_data_data, BOOL success)
+{
+       struct domain_ndr_call_state *state =
+               talloc_get_type_abort(private_data_data, struct domain_ndr_call_state);
+
+       if (!success) {
+               DEBUG(5, ("Domain init returned an error\n"));
+               state->continuation(state->private_data_data, False);
+               return;
+       }
+
+       async_ndr_call(state->mem_ctx, &state->domain->child,
+                      state->call,
+                      state->continuation, state->private_data_data);
+}
+
+static void recvfrom_child_old(void *private_data_data, BOOL success)
 {
        struct winbindd_cli_state *state =
                talloc_get_type_abort(private_data_data, struct winbindd_cli_state);