MINOR: proxy: define cap PR_CAP_LUA

Define a new cap PR_CAP_LUA. It can be used to allocate the internal
proxy for lua Socket class. This cap overrides default settings for
preferable values in the lua context.
This commit is contained in:
Amaury Denoyelle 2021-03-24 10:49:34 +01:00
parent 27fefa1967
commit 6f26faecd8
2 changed files with 13 additions and 3 deletions

View File

@ -68,6 +68,7 @@ enum PR_SRV_STATE_FILE {
#define PR_CAP_BE 0x0002
#define PR_CAP_LISTEN (PR_CAP_FE|PR_CAP_BE)
#define PR_CAP_DEF 0x0004 /* defaults section */
#define PR_CAP_LUA 0x0008 /* internal proxy used by lua engine */
/* bits for proxy->options */
#define PR_O_REDISP 0x00000001 /* allow reconnection to dispatch in case of errors */

View File

@ -1342,10 +1342,14 @@ void proxy_preset_defaults(struct proxy *defproxy)
{
defproxy->mode = PR_MODE_TCP;
defproxy->disabled = 0;
defproxy->maxconn = cfg_maxpconn;
defproxy->conn_retries = CONN_RETRIES;
if (!(defproxy->cap & PR_CAP_LUA)) {
defproxy->maxconn = cfg_maxpconn;
defproxy->conn_retries = CONN_RETRIES;
}
defproxy->redispatch_after = 0;
defproxy->options = PR_O_REUSE_SAFE;
if (defproxy->cap & PR_CAP_LUA)
defproxy->options2 |= PR_O2_INDEPSTR;
defproxy->max_out_conns = MAX_SRV_LIST;
defproxy->defsrv.check.inter = DEF_CHKINTR;
@ -1376,6 +1380,9 @@ void proxy_preset_defaults(struct proxy *defproxy)
#if defined(USE_QUIC)
quic_transport_params_init(&defproxy->defsrv.quic_params, 0);
#endif
if (defproxy->cap & PR_CAP_LUA)
defproxy->timeout.connect = 5000;
}
/* Frees all dynamic settings allocated on a default proxy that's about to be
@ -1470,7 +1477,9 @@ struct proxy *alloc_new_proxy(const char *name, unsigned int cap, char **errmsg)
curproxy->last_change = now.tv_sec;
curproxy->id = strdup(name);
curproxy->cap = cap;
proxy_store_name(curproxy);
if (!(cap & PR_CAP_LUA))
proxy_store_name(curproxy);
done:
return curproxy;