1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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>
This commit is contained in:
Volker Lendecke 2018-05-02 15:26:05 +02:00
parent 87284da7a2
commit 4109236cfd

View File

@ -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);
}
}