Merge branch '2.1' into 2.2
This commit is contained in:
@ -116,6 +116,7 @@ const char CN_QUERY_RETRIES[] = "query_retries";
|
||||
const char CN_QUERY_RETRY_TIMEOUT[] = "query_retry_timeout";
|
||||
const char CN_RELATIONSHIPS[] = "relationships";
|
||||
const char CN_LINKS[] = "links";
|
||||
const char CN_LOCAL_ADDRESS[] = "local_address";
|
||||
const char CN_REQUIRED[] = "required";
|
||||
const char CN_RETRY_ON_FAILURE[] = "retry_on_failure";
|
||||
const char CN_ROUTER[] = "router";
|
||||
@ -1622,6 +1623,10 @@ handle_global_item(const char *name, const char *value)
|
||||
{
|
||||
gateway.passive = config_truth_value((char*)value);
|
||||
}
|
||||
else if (strcmp(name, CN_LOCAL_ADDRESS) == 0)
|
||||
{
|
||||
gateway.local_address = MXS_STRDUP_A(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; lognames[i].name; i++)
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
#include <openssl/sha.h>
|
||||
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/config.h>
|
||||
#include <maxscale/dcb.h>
|
||||
#include <maxscale/log_manager.h>
|
||||
#include <maxscale/limits.h>
|
||||
@ -1019,6 +1020,8 @@ int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr
|
||||
memcpy(addr, ai->ai_addr, ai->ai_addrlen);
|
||||
set_port(addr, port);
|
||||
|
||||
freeaddrinfo(ai);
|
||||
|
||||
if ((type == MXS_SOCKET_NETWORK && !configure_network_socket(so)) ||
|
||||
(type == MXS_SOCKET_LISTENER && !configure_listener_socket(so)))
|
||||
{
|
||||
@ -1032,9 +1035,39 @@ int open_network_socket(enum mxs_socket_type type, struct sockaddr_storage *addr
|
||||
close(so);
|
||||
so = -1;
|
||||
}
|
||||
}
|
||||
else if (type == MXS_SOCKET_NETWORK)
|
||||
{
|
||||
MXS_CONFIG* config = config_get_global_options();
|
||||
|
||||
freeaddrinfo(ai);
|
||||
if (config->local_address)
|
||||
{
|
||||
if ((rc = getaddrinfo(config->local_address, NULL, &hint, &ai)) == 0)
|
||||
{
|
||||
struct sockaddr_storage local_address = {};
|
||||
|
||||
memcpy(&local_address, ai->ai_addr, ai->ai_addrlen);
|
||||
freeaddrinfo(ai);
|
||||
|
||||
if (bind(so, (struct sockaddr*)&local_address, sizeof(local_address)) == 0)
|
||||
{
|
||||
MXS_INFO("Bound connecting socket to \"%s\".", config->local_address);
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Could not bind connecting socket to local address \"%s\", "
|
||||
"connecting to server using default local address: %s",
|
||||
config->local_address, mxs_strerror(errno));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_ERROR("Could not get address information for local address \"%s\", "
|
||||
"connecting to server using default local address: %s",
|
||||
config->local_address, mxs_strerror(errno));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return so;
|
||||
|
||||
Reference in New Issue
Block a user