winbind: add conditional child dispatch type
authorDavid Disseldorp <ddiss@samba.org>
Mon, 15 Apr 2013 17:12:27 +0000 (19:12 +0200)
committerDavid Disseldorp <ddiss@samba.org>
Tue, 16 Apr 2013 13:51:57 +0000 (15:51 +0200)
Dispatch functions in the winbindd_child_dispatch_type structure now
carry a type enum, which identifies whether the function is synchronous
or asynchronous. Currently all functions remain synchronous.

source3/winbindd/winbindd.h
source3/winbindd/winbindd_domain.c
source3/winbindd/winbindd_dual.c
source3/winbindd/winbindd_idmap.c
source3/winbindd/winbindd_locator.c

index 33c7bbe5c684f886fd87ecb061387115c0df93e0..f36e7fd2885d972439dbd98f8ea43f99c90fe5e3 100644 (file)
@@ -119,11 +119,28 @@ struct winbindd_cm_conn {
 
 struct winbindd_domain;
 
+enum winbindd_child_dispatch_type {
+       WINBINDD_CHILD_DISPATCH_SYNC = 0,
+       WINBINDD_CHILD_DISPATCH_ASYNC,
+};
+
 struct winbindd_child_dispatch_table {
        const char *name;
        enum winbindd_cmd struct_cmd;
-       enum winbindd_result (*struct_fn)(struct winbindd_domain *domain,
-                                         struct winbindd_cli_state *state);
+       enum winbindd_child_dispatch_type type;
+       union {
+               struct {
+                       enum winbindd_result (*struct_fn)(struct winbindd_domain *domain,
+                                                         struct winbindd_cli_state *state);
+               } sync;
+               struct {
+                       struct tevent_req *(*struct_fn_send)(TALLOC_CTX *mem_ctx,
+                                                            struct tevent_context *ev,
+                                                            struct winbindd_domain *domain,
+                                                            struct winbindd_cli_state *state);
+                       enum winbindd_result (*struct_fn_recv)(struct tevent_req *req);
+               } async;
+       };
 };
 
 struct winbindd_child {
index e998275c8e2a7f78489127f60f83fe778fcb3819..e8bf92e29431307f9c1c5ac847e7664044b344e4 100644 (file)
@@ -29,39 +29,48 @@ static const struct winbindd_child_dispatch_table domain_dispatch_table[] = {
        {
                .name           = "PING",
                .struct_cmd     = WINBINDD_PING,
-               .struct_fn      = winbindd_dual_ping,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_ping,
        },{
                .name           = "LIST_TRUSTDOM",
                .struct_cmd     = WINBINDD_LIST_TRUSTDOM,
-               .struct_fn      = winbindd_dual_list_trusted_domains,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_list_trusted_domains,
        },{
                .name           = "INIT_CONNECTION",
                .struct_cmd     = WINBINDD_INIT_CONNECTION,
-               .struct_fn      = winbindd_dual_init_connection,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_init_connection,
        },{
                .name           = "PAM_AUTH",
                .struct_cmd     = WINBINDD_PAM_AUTH,
-               .struct_fn      = winbindd_dual_pam_auth,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_pam_auth,
        },{
                .name           = "AUTH_CRAP",
                .struct_cmd     = WINBINDD_PAM_AUTH_CRAP,
-               .struct_fn      = winbindd_dual_pam_auth_crap,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_pam_auth_crap,
        },{
                .name           = "PAM_LOGOFF",
                .struct_cmd     = WINBINDD_PAM_LOGOFF,
-               .struct_fn      = winbindd_dual_pam_logoff,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_pam_logoff,
        },{
                .name           = "CHNG_PSWD_AUTH_CRAP",
                .struct_cmd     = WINBINDD_PAM_CHNG_PSWD_AUTH_CRAP,
-               .struct_fn      = winbindd_dual_pam_chng_pswd_auth_crap,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_pam_chng_pswd_auth_crap,
        },{
                .name           = "PAM_CHAUTHTOK",
                .struct_cmd     = WINBINDD_PAM_CHAUTHTOK,
-               .struct_fn      = winbindd_dual_pam_chauthtok,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_pam_chauthtok,
        },{
                .name           = "NDRCMD",
                .struct_cmd     = WINBINDD_DUAL_NDRCMD,
-               .struct_fn      = winbindd_dual_ndrcmd,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_ndrcmd,
        },{
                .name           = NULL,
        }
index 7e06142c56b6e044616ea18d2bb8d4f983744b55..bcd8c0f46bffbbfa57936d245df5c1a2aae2df05 100644 (file)
@@ -455,7 +455,9 @@ static void child_process_request(struct winbindd_child *child,
                if (state->request->cmd == table->struct_cmd) {
                        DEBUG(10,("child_process_request: request fn %s\n",
                                  table->name));
-                       state->response->result = table->struct_fn(domain, state);
+                       SMB_ASSERT(table->type == WINBINDD_CHILD_DISPATCH_SYNC);
+                       state->response->result = table->sync.struct_fn(domain,
+                                                                       state);
                        return;
                }
        }
index 028026087d603e548c28b54eda9d2c4cbc9bdfbf..21b5ae1b6d5a04e09ac10642a63093efe7d3f95f 100644 (file)
@@ -38,11 +38,13 @@ static const struct winbindd_child_dispatch_table idmap_dispatch_table[] = {
        {
                .name           = "PING",
                .struct_cmd     = WINBINDD_PING,
-               .struct_fn      = winbindd_dual_ping,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_ping,
        },{
                .name           = "NDRCMD",
                .struct_cmd     = WINBINDD_DUAL_NDRCMD,
-               .struct_fn      = winbindd_dual_ndrcmd,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_ndrcmd,
        },{
                .name           = NULL,
        }
index 59e8614fdbcc9a30807a4389d2bfb07cc131af89..11545703d8cf3bc45aea1bd310f60f8a7dcd8a3f 100644 (file)
@@ -38,11 +38,13 @@ static const struct winbindd_child_dispatch_table locator_dispatch_table[] = {
        {
                .name           = "PING",
                .struct_cmd     = WINBINDD_PING,
-               .struct_fn      = winbindd_dual_ping,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_ping,
        },{
                .name           = "NDRCMD",
                .struct_cmd     = WINBINDD_DUAL_NDRCMD,
-               .struct_fn      = winbindd_dual_ndrcmd,
+               .type           = WINBINDD_CHILD_DISPATCH_SYNC,
+               .sync.struct_fn = winbindd_dual_ndrcmd,
        },{
                .name           = NULL,
        }