mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-22 13:46:52 +00:00
MINOR: server: add a global list of all known servers
It's a real pain not to have access to the list of all registered servers, because whenever there is a need to late adjust their configuration, only those attached to regular proxies are seen, but not the peers, lua, logs nor DNS. What this patch does is that new_server() will automatically add the newly created server to a global list, and it does so as well for the 1 or 2 statically allocated servers created for Lua. This way it will be possible to iterate over all of them.
This commit is contained in:
parent
0f143afe1b
commit
198e92a8e5
@ -210,6 +210,7 @@ struct server {
|
|||||||
enum srv_admin next_admin, cur_admin; /* server maintenance status : SRV_ADMF_* */
|
enum srv_admin next_admin, cur_admin; /* server maintenance status : SRV_ADMF_* */
|
||||||
signed char use_ssl; /* ssl enabled (1: on, 0: disabled, -1 forced off) */
|
signed char use_ssl; /* ssl enabled (1: on, 0: disabled, -1 forced off) */
|
||||||
unsigned int pp_opts; /* proxy protocol options (SRV_PP_*) */
|
unsigned int pp_opts; /* proxy protocol options (SRV_PP_*) */
|
||||||
|
struct list global_list; /* attach point in the global servers_list */
|
||||||
struct server *next;
|
struct server *next;
|
||||||
int cklen; /* the len of the cookie, to speed up checks */
|
int cklen; /* the len of the cookie, to speed up checks */
|
||||||
int rdr_len; /* the length of the redirection prefix */
|
int rdr_len; /* the length of the redirection prefix */
|
||||||
|
@ -39,6 +39,7 @@ __decl_thread(extern HA_SPINLOCK_T idle_conn_srv_lock);
|
|||||||
extern struct idle_conns idle_conns[MAX_THREADS];
|
extern struct idle_conns idle_conns[MAX_THREADS];
|
||||||
extern struct eb_root idle_conn_srv;
|
extern struct eb_root idle_conn_srv;
|
||||||
extern struct task *idle_conn_task;
|
extern struct task *idle_conn_task;
|
||||||
|
extern struct list servers_list;
|
||||||
extern struct dict server_key_dict;
|
extern struct dict server_key_dict;
|
||||||
|
|
||||||
int srv_downtime(const struct server *s);
|
int srv_downtime(const struct server *s);
|
||||||
|
@ -2675,6 +2675,7 @@ void deinit(void)
|
|||||||
srvdf->fct(s);
|
srvdf->fct(s);
|
||||||
|
|
||||||
EXTRA_COUNTERS_FREE(s->extra_counters);
|
EXTRA_COUNTERS_FREE(s->extra_counters);
|
||||||
|
LIST_DEL(&s->global_list);
|
||||||
free(s);
|
free(s);
|
||||||
s = s_next;
|
s = s_next;
|
||||||
}/* end while(s) */
|
}/* end while(s) */
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
#include <haproxy/proxy-t.h>
|
#include <haproxy/proxy-t.h>
|
||||||
#include <haproxy/regex.h>
|
#include <haproxy/regex.h>
|
||||||
#include <haproxy/sample.h>
|
#include <haproxy/sample.h>
|
||||||
#include <haproxy/server-t.h>
|
#include <haproxy/server.h>
|
||||||
#include <haproxy/session.h>
|
#include <haproxy/session.h>
|
||||||
#include <haproxy/stats-t.h>
|
#include <haproxy/stats-t.h>
|
||||||
#include <haproxy/stream.h>
|
#include <haproxy/stream.h>
|
||||||
@ -9179,6 +9179,7 @@ void hlua_init(void) {
|
|||||||
socket_tcp.pendconns = EB_ROOT;
|
socket_tcp.pendconns = EB_ROOT;
|
||||||
socket_tcp.idle_conns_tree = NULL;
|
socket_tcp.idle_conns_tree = NULL;
|
||||||
socket_tcp.safe_conns_tree = NULL;
|
socket_tcp.safe_conns_tree = NULL;
|
||||||
|
LIST_ADD(&servers_list, &socket_tcp.global_list);
|
||||||
socket_tcp.next_state = SRV_ST_RUNNING; /* early server setup */
|
socket_tcp.next_state = SRV_ST_RUNNING; /* early server setup */
|
||||||
socket_tcp.last_change = 0;
|
socket_tcp.last_change = 0;
|
||||||
socket_tcp.conf.file = strdup("HLUA_INTERNAL");
|
socket_tcp.conf.file = strdup("HLUA_INTERNAL");
|
||||||
@ -9226,6 +9227,7 @@ void hlua_init(void) {
|
|||||||
socket_ssl.pendconns = EB_ROOT;
|
socket_ssl.pendconns = EB_ROOT;
|
||||||
socket_ssl.idle_conns_tree = NULL;
|
socket_ssl.idle_conns_tree = NULL;
|
||||||
socket_ssl.safe_conns_tree = NULL;
|
socket_ssl.safe_conns_tree = NULL;
|
||||||
|
LIST_ADD(&servers_list, &socket_ssl.global_list);
|
||||||
socket_ssl.next_state = SRV_ST_RUNNING; /* early server setup */
|
socket_ssl.next_state = SRV_ST_RUNNING; /* early server setup */
|
||||||
socket_ssl.last_change = 0;
|
socket_ssl.last_change = 0;
|
||||||
socket_ssl.conf.file = strdup("HLUA_INTERNAL");
|
socket_ssl.conf.file = strdup("HLUA_INTERNAL");
|
||||||
|
@ -58,6 +58,7 @@ static struct srv_kw_list srv_keywords = {
|
|||||||
__decl_thread(HA_SPINLOCK_T idle_conn_srv_lock);
|
__decl_thread(HA_SPINLOCK_T idle_conn_srv_lock);
|
||||||
struct eb_root idle_conn_srv = EB_ROOT;
|
struct eb_root idle_conn_srv = EB_ROOT;
|
||||||
struct task *idle_conn_task = NULL;
|
struct task *idle_conn_task = NULL;
|
||||||
|
struct list servers_list = LIST_HEAD_INIT(servers_list);
|
||||||
|
|
||||||
/* The server names dictionary */
|
/* The server names dictionary */
|
||||||
struct dict server_key_dict = {
|
struct dict server_key_dict = {
|
||||||
@ -1736,6 +1737,9 @@ static void srv_settings_cpy(struct server *srv, struct server *src, int srv_tmp
|
|||||||
srv->socks4_addr = src->socks4_addr;
|
srv->socks4_addr = src->socks4_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* allocate a server and attach it to the global servers_list. Returns
|
||||||
|
* the server on success, otherwise NULL.
|
||||||
|
*/
|
||||||
struct server *new_server(struct proxy *proxy)
|
struct server *new_server(struct proxy *proxy)
|
||||||
{
|
{
|
||||||
struct server *srv;
|
struct server *srv;
|
||||||
@ -1748,6 +1752,7 @@ struct server *new_server(struct proxy *proxy)
|
|||||||
srv->proxy = proxy;
|
srv->proxy = proxy;
|
||||||
MT_LIST_INIT(&srv->actconns);
|
MT_LIST_INIT(&srv->actconns);
|
||||||
srv->pendconns = EB_ROOT;
|
srv->pendconns = EB_ROOT;
|
||||||
|
LIST_ADDQ(&servers_list, &srv->global_list);
|
||||||
|
|
||||||
srv->next_state = SRV_ST_RUNNING; /* early server setup */
|
srv->next_state = SRV_ST_RUNNING; /* early server setup */
|
||||||
srv->last_change = now.tv_sec;
|
srv->last_change = now.tv_sec;
|
||||||
@ -1923,6 +1928,7 @@ static int server_template_init(struct server *srv, struct proxy *px)
|
|||||||
#endif
|
#endif
|
||||||
free_check(&newsrv->agent);
|
free_check(&newsrv->agent);
|
||||||
free_check(&newsrv->check);
|
free_check(&newsrv->check);
|
||||||
|
LIST_DEL(&newsrv->global_list);
|
||||||
}
|
}
|
||||||
free(newsrv);
|
free(newsrv);
|
||||||
return i - srv->tmpl_info.nb_low;
|
return i - srv->tmpl_info.nb_low;
|
||||||
|
Loading…
Reference in New Issue
Block a user