summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-05-02 15:26:05 +0200
committerVolker Lendecke <vl@samba.org>2018-05-17 08:44:18 +0200
commit4109236cfdd9cec68acd67d46f2155f27d1549b6 (patch)
treede0e9760a90c37f7a1ae817a3791d9e783136f08 /source3/winbindd/winbindd.c
parent87284da7a28172b40504eb50510a8b57da6692a6 (diff)
downloadsamba-4109236cfdd9cec68acd67d46f2155f27d1549b6.tar.gz
winbindd: Introduce "bool_dispatch_table"
This is meant to replace the synchronous "dispatch_table". The current dispatch_table assumes that every synchronous function does the request_ok or request_error itself. This mixes two concerns: Doing the work and shipping the reply to the winbind client. This new dispatch table will make it possible to centralize shipping the reply to the client. At a later stage this will enable easier statistics on how long request processing took precisely. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/winbindd/winbindd.c')
-rw-r--r--source3/winbindd/winbindd.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 76d644b1ba6..f9bea96bf97 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -554,6 +554,13 @@ static struct winbindd_dispatch_table {
{ WINBINDD_NUM_CMDS, NULL, "NONE" }
};
+static struct winbindd_bool_dispatch_table {
+ enum winbindd_cmd cmd;
+ bool (*fn)(struct winbindd_cli_state *state);
+ const char *cmd_name;
+} bool_dispatch_table[] = {
+};
+
struct winbindd_async_dispatch_table {
enum winbindd_cmd cmd;
const char *cmd_name;
@@ -658,6 +665,8 @@ static void process_request(struct winbindd_cli_state *state)
{
struct winbindd_dispatch_table *table = dispatch_table;
struct winbindd_async_dispatch_table *atable;
+ size_t i;
+ bool ok;
state->mem_ctx = talloc_named(state, 0, "winbind request");
if (state->mem_ctx == NULL)
@@ -725,14 +734,32 @@ static void process_request(struct winbindd_cli_state *state)
table->winbindd_cmd_name ));
state->cmd_name = table->winbindd_cmd_name;
table->fn(state);
+ return;
+ }
+ }
+
+ for (i=0; i<ARRAY_SIZE(bool_dispatch_table); i++) {
+ if (bool_dispatch_table[i].cmd == state->request->cmd) {
break;
}
}
- if (!table->fn) {
+ if (i == ARRAY_SIZE(bool_dispatch_table)) {
DEBUG(10,("process_request: unknown request fn number %d\n",
(int)state->request->cmd ));
request_error(state);
+ return;
+ }
+
+ DBG_DEBUG("process_request: request fn %s\n",
+ bool_dispatch_table[i].cmd_name);
+
+ ok = bool_dispatch_table[i].fn(state);
+
+ if (ok) {
+ request_ok(state);
+ } else {
+ request_error(state);
}
}