From e2dc1fa8ca39f5a96b15c1de120bbf032af5c10c Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 26 May 2015 12:08:07 +0200 Subject: [PATCH] MEDIUM: stick-table: remove the now duplicate find_stktable() function Since proxy_tbl_by_name() already does the same job, let's not keep duplicate functions and use this one only. --- include/proto/stick_table.h | 1 - src/cfgparse.c | 2 +- src/dumpstats.c | 2 +- src/hlua.c | 2 +- src/sample.c | 2 +- src/stick_table.c | 18 ------------------ 6 files changed, 4 insertions(+), 23 deletions(-) diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h index de9fd52ea..8c97f733d 100644 --- a/include/proto/stick_table.h +++ b/include/proto/stick_table.h @@ -53,7 +53,6 @@ struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, st int stktable_compatible_sample(struct sample_expr *expr, unsigned long table_type); int stktable_register_data_store(int idx, const char *name, int std_type, int arg_type); int stktable_get_data_type(char *name); -struct proxy *find_stktable(const char *name); int stktable_trash_oldest(struct stktable *t, int to_batch); /* return allocation size for standard data type */ diff --git a/src/cfgparse.c b/src/cfgparse.c index 778edf74c..1de7a1f3a 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -3461,7 +3461,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) int myidx = 1; struct proxy *other; - other = find_stktable(curproxy->id); + other = proxy_tbl_by_name(curproxy->id); if (other) { Alert("parsing [%s:%d] : stick-table name '%s' conflicts with table declared in %s '%s' at %s:%d.\n", file, linenum, curproxy->id, proxy_type_str(other), other->id, other->conf.file, other->conf.line); diff --git a/src/dumpstats.c b/src/dumpstats.c index 559f22965..3f5c06946 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -866,7 +866,7 @@ static void stats_sock_table_request(struct stream_interface *si, char **args, i appctx->st0 = action; if (*args[2]) { - appctx->ctx.table.target = find_stktable(args[2]); + appctx->ctx.table.target = proxy_tbl_by_name(args[2]); if (!appctx->ctx.table.target) { appctx->ctx.cli.msg = "No such table\n"; appctx->st0 = STAT_CLI_PRINT; diff --git a/src/hlua.c b/src/hlua.c index 5e1bdc322..eec37fa01 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -654,7 +654,7 @@ __LJMP int hlua_lua2arg_check(lua_State *L, int first, struct arg *argp, WILL_LJMP(luaL_argerror(L, first + idx, "string expected")); memcpy(trash.str, argp[idx].data.str.str, argp[idx].data.str.len); trash.str[argp[idx].data.str.len] = 0; - argp[idx].data.prx = find_stktable(trash.str); + argp[idx].data.prx = proxy_tbl_by_name(trash.str); if (!argp[idx].data.prx) WILL_LJMP(luaL_argerror(L, first + idx, "table doesn't exist")); argp[idx].type = ARGT_TAB; diff --git a/src/sample.c b/src/sample.c index 3ad2d2081..47d48c8ba 100644 --- a/src/sample.c +++ b/src/sample.c @@ -1214,7 +1214,7 @@ int smp_resolve_args(struct proxy *p) case ARGT_TAB: if (arg->data.str.len) { pname = arg->data.str.str; - px = find_stktable(pname); + px = proxy_tbl_by_name(pname); } if (!px) { diff --git a/src/stick_table.c b/src/stick_table.c index 19d6af192..b68772c08 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -784,24 +784,6 @@ int stktable_get_data_type(char *name) return -1; } -/* Returns pointer to proxy containing table or NULL if not found */ -struct proxy *find_stktable(const char *name) -{ - struct proxy *px; - struct ebpt_node *node; - - for (node = ebis_lookup(&proxy_by_name, name); node; node = ebpt_next(node)) { - px = container_of(node, struct proxy, conf.by_name); - - if (strcmp(px->id, name) != 0) - break; - - if (px->table.size) - return px; - } - return NULL; -} - /* Casts sample to the type of the table specified in arg(0), and looks * it up into this table. Returns true if found, false otherwise. The input * type is STR so that input samples are converted to string (since all types