mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MINOR: dns: Fix SRV records with the new thread code.
srv_set_fqdn() may be called with the DNS lock already held, but tries to lock it anyway. So, add a new parameter to let it know if it was already locked or not;
This commit is contained in:
parent
a5e0590b80
commit
d16bfe6c01
@ -56,7 +56,7 @@ extern struct list updated_servers;
|
|||||||
|
|
||||||
/* functions related to server name resolution */
|
/* functions related to server name resolution */
|
||||||
int snr_update_srv_status(struct server *s, int has_no_ip);
|
int snr_update_srv_status(struct server *s, int has_no_ip);
|
||||||
const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater);
|
const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater, int dns_locked);
|
||||||
int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *nameserver);
|
int snr_resolution_cb(struct dns_requester *requester, struct dns_nameserver *nameserver);
|
||||||
int snr_resolution_error_cb(struct dns_requester *requester, int error_code);
|
int snr_resolution_error_cb(struct dns_requester *requester, int error_code);
|
||||||
struct server *snr_check_ip_callback(struct server *srv, void *ip, unsigned char *ip_family);
|
struct server *snr_check_ip_callback(struct server *srv, void *ip, unsigned char *ip_family);
|
||||||
|
@ -545,7 +545,7 @@ static void dns_check_dns_response(struct dns_resolution *res)
|
|||||||
if (dns_dn_label_to_str(item->target, item->data_len+1,
|
if (dns_dn_label_to_str(item->target, item->data_len+1,
|
||||||
hostname, DNS_MAX_NAME_SIZE) == -1)
|
hostname, DNS_MAX_NAME_SIZE) == -1)
|
||||||
continue;
|
continue;
|
||||||
msg = update_server_fqdn(srv, hostname, "SRV record");
|
msg = update_server_fqdn(srv, hostname, "SRV record", 1);
|
||||||
if (msg)
|
if (msg)
|
||||||
send_log(srv->proxy, LOG_NOTICE, "%s", msg);
|
send_log(srv->proxy, LOG_NOTICE, "%s", msg);
|
||||||
|
|
||||||
|
21
src/server.c
21
src/server.c
@ -53,7 +53,7 @@ HA_SPINLOCK_T updated_servers_lock;
|
|||||||
static void srv_register_update(struct server *srv);
|
static void srv_register_update(struct server *srv);
|
||||||
static void srv_update_state(struct server *srv, int version, char **params);
|
static void srv_update_state(struct server *srv, int version, char **params);
|
||||||
static int srv_apply_lastaddr(struct server *srv, int *err_code);
|
static int srv_apply_lastaddr(struct server *srv, int *err_code);
|
||||||
static int srv_set_fqdn(struct server *srv, const char *fqdn);
|
static int srv_set_fqdn(struct server *srv, const char *fqdn, int dns_locked);
|
||||||
|
|
||||||
/* List head of all known server keywords */
|
/* List head of all known server keywords */
|
||||||
static struct srv_kw_list srv_keywords = {
|
static struct srv_kw_list srv_keywords = {
|
||||||
@ -2911,7 +2911,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
|
|||||||
* from stats socket).
|
* from stats socket).
|
||||||
*/
|
*/
|
||||||
if (fqdn_set_by_cli) {
|
if (fqdn_set_by_cli) {
|
||||||
srv_set_fqdn(srv, fqdn);
|
srv_set_fqdn(srv, fqdn, 0);
|
||||||
srv->next_admin |= SRV_ADMF_HMAINT;
|
srv->next_admin |= SRV_ADMF_HMAINT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3764,13 +3764,14 @@ int srv_set_addr_via_libc(struct server *srv, int *err_code)
|
|||||||
/* Set the server's FDQN (->hostname) from <hostname>.
|
/* Set the server's FDQN (->hostname) from <hostname>.
|
||||||
* Returns -1 if failed, 0 if not.
|
* Returns -1 if failed, 0 if not.
|
||||||
*/
|
*/
|
||||||
int srv_set_fqdn(struct server *srv, const char *hostname)
|
int srv_set_fqdn(struct server *srv, const char *hostname, int dns_locked)
|
||||||
{
|
{
|
||||||
struct dns_resolution *resolution;
|
struct dns_resolution *resolution;
|
||||||
char *hostname_dn;
|
char *hostname_dn;
|
||||||
int hostname_len, hostname_dn_len;
|
int hostname_len, hostname_dn_len;
|
||||||
|
|
||||||
SPIN_LOCK(DNS_LOCK, &srv->resolvers->lock);
|
if (!dns_locked)
|
||||||
|
SPIN_LOCK(DNS_LOCK, &srv->resolvers->lock);
|
||||||
/* run time DNS resolution was not active for this server
|
/* run time DNS resolution was not active for this server
|
||||||
* and we can't enable it at run time for now.
|
* and we can't enable it at run time for now.
|
||||||
*/
|
*/
|
||||||
@ -3805,11 +3806,13 @@ int srv_set_fqdn(struct server *srv, const char *hostname)
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock);
|
if (!dns_locked)
|
||||||
|
SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock);
|
if (!dns_locked)
|
||||||
|
SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3936,7 +3939,7 @@ int srv_init_addr(void)
|
|||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater)
|
const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater, int dns_locked)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct chunk *msg;
|
struct chunk *msg;
|
||||||
@ -3957,7 +3960,7 @@ const char *update_server_fqdn(struct server *server, const char *fqdn, const ch
|
|||||||
chunk_appendf(msg, "%s/%s changed its FQDN from %s to %s",
|
chunk_appendf(msg, "%s/%s changed its FQDN from %s to %s",
|
||||||
server->proxy->id, server->id, server->hostname, fqdn);
|
server->proxy->id, server->id, server->hostname, fqdn);
|
||||||
|
|
||||||
if (srv_set_fqdn(server, fqdn) < 0) {
|
if (srv_set_fqdn(server, fqdn, dns_locked) < 0) {
|
||||||
chunk_reset(msg);
|
chunk_reset(msg);
|
||||||
chunk_appendf(msg, "could not update %s/%s FQDN",
|
chunk_appendf(msg, "could not update %s/%s FQDN",
|
||||||
server->proxy->id, server->id);
|
server->proxy->id, server->id);
|
||||||
@ -4185,7 +4188,7 @@ static int cli_parse_set_server(char **args, struct appctx *appctx, void *privat
|
|||||||
appctx->st0 = CLI_ST_PRINT;
|
appctx->st0 = CLI_ST_PRINT;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
warning = update_server_fqdn(sv, args[4], "stats socket command");
|
warning = update_server_fqdn(sv, args[4], "stats socket command", 0);
|
||||||
if (warning) {
|
if (warning) {
|
||||||
appctx->ctx.cli.severity = LOG_WARNING;
|
appctx->ctx.cli.severity = LOG_WARNING;
|
||||||
appctx->ctx.cli.msg = warning;
|
appctx->ctx.cli.msg = warning;
|
||||||
|
Loading…
Reference in New Issue
Block a user