MINOR: peers: centralize configuration of the peers frontend

This is in order to stop exporting the peer_accept() function.
This commit is contained in:
Willy Tarreau 2015-03-13 15:47:26 +01:00
parent 9ff95bb18c
commit 91d9628a51
3 changed files with 15 additions and 11 deletions
include/proto
src

View File

@ -29,8 +29,7 @@
#include <types/peers.h>
void peers_register_table(struct peers *, struct stktable *table);
int peer_accept(struct session *);
void peers_setup_frontend(struct proxy *fe);
#endif /* _PROTO_PEERS_H */

View File

@ -1861,17 +1861,10 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
init_new_proxy(curpeers->peers_fe);
curpeers->peers_fe->parent = curpeers;
curpeers->peers_fe->last_change = now.tv_sec;
curpeers->peers_fe->id = strdup(args[1]);
curpeers->peers_fe->cap = PR_CAP_FE;
curpeers->peers_fe->maxconn = 0;
curpeers->peers_fe->conn_retries = CONN_RETRIES;
curpeers->peers_fe->timeout.client = MS_TO_TICKS(5000);
curpeers->peers_fe->accept = peer_accept;
curpeers->peers_fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
curpeers->peers_fe->conf.args.file = curpeers->peers_fe->conf.file = strdup(file);
curpeers->peers_fe->conf.args.line = curpeers->peers_fe->conf.line = linenum;
peers_setup_frontend(curpeers->peers_fe);
bind_conf = bind_conf_alloc(&curpeers->peers_fe->conf.bind, file, linenum, args[2]);

View File

@ -1094,7 +1094,7 @@ static void peer_session_forceshutdown(struct session * session)
* value in case of success, or zero if it is a success but the session must be
* closed ASAP and ignored.
*/
int peer_accept(struct session *s)
static int peer_accept(struct session *s)
{
s->target = &peer_applet.obj_type;
/* no need to initialize the applet, it will start with st0=st1 = 0 */
@ -1117,6 +1117,18 @@ int peer_accept(struct session *s)
return 1;
}
/* Pre-configures a peers frontend to accept incoming connections */
void peers_setup_frontend(struct proxy *fe)
{
fe->last_change = now.tv_sec;
fe->cap = PR_CAP_FE;
fe->maxconn = 0;
fe->conn_retries = CONN_RETRIES;
fe->timeout.client = MS_TO_TICKS(5000);
fe->accept = peer_accept;
fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
}
/*
* Create a new peer session in assigned state (connect will start automatically)
*/