MXS-662: Service protocol check no longer ignores bind
The address of a listener was ignored when service protocols were compared.
This commit is contained in:
@ -2759,7 +2759,7 @@ int create_new_listener(CONFIG_CONTEXT *obj, bool startnow)
|
|||||||
SSL_LISTENER *ssl_info = make_ssl_structure(obj, true, &error_count);
|
SSL_LISTENER *ssl_info = make_ssl_structure(obj, true, &error_count);
|
||||||
if (socket)
|
if (socket)
|
||||||
{
|
{
|
||||||
if (serviceHasProtocol(service, protocol, 0))
|
if (serviceHasProtocol(service, protocol, address, 0))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Listener '%s', for service '%s', socket %s, already have socket.",
|
MXS_ERROR("Listener '%s', for service '%s', socket %s, already have socket.",
|
||||||
obj->object,
|
obj->object,
|
||||||
@ -2779,7 +2779,7 @@ int create_new_listener(CONFIG_CONTEXT *obj, bool startnow)
|
|||||||
|
|
||||||
if (port)
|
if (port)
|
||||||
{
|
{
|
||||||
if (serviceHasProtocol(service, protocol, atoi(port)))
|
if (serviceHasProtocol(service, protocol, address, atoi(port)))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Listener '%s', for service '%s', already have port %s.",
|
MXS_ERROR("Listener '%s', for service '%s', already have port %s.",
|
||||||
obj->object,
|
obj->object,
|
||||||
|
@ -708,8 +708,8 @@ serviceAddProtocol(SERVICE *service, char *protocol, char *address, unsigned sho
|
|||||||
* @param port The port to listen on
|
* @param port The port to listen on
|
||||||
* @return TRUE if the protocol/port is already part of the service
|
* @return TRUE if the protocol/port is already part of the service
|
||||||
*/
|
*/
|
||||||
int
|
int serviceHasProtocol(SERVICE *service, const char *protocol,
|
||||||
serviceHasProtocol(SERVICE *service, char *protocol, unsigned short port)
|
const char* address, unsigned short port)
|
||||||
{
|
{
|
||||||
SERV_LISTENER *proto;
|
SERV_LISTENER *proto;
|
||||||
|
|
||||||
@ -717,7 +717,9 @@ serviceHasProtocol(SERVICE *service, char *protocol, unsigned short port)
|
|||||||
proto = service->ports;
|
proto = service->ports;
|
||||||
while (proto)
|
while (proto)
|
||||||
{
|
{
|
||||||
if (strcmp(proto->protocol, protocol) == 0 && proto->port == port)
|
if (strcmp(proto->protocol, protocol) == 0 && proto->port == port &&
|
||||||
|
((address && proto->address && strcmp(proto->address, address) == 0) ||
|
||||||
|
(address == NULL && proto->address == NULL)))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ init_test_env(NULL);
|
|||||||
ss_info_dassert(0 == strcmp("MyService", service_get_name(service)), "Service must have given name");
|
ss_info_dassert(0 == strcmp("MyService", service_get_name(service)), "Service must have given name");
|
||||||
ss_dfprintf(stderr, "\t..done\nAdding protocol testprotocol.");
|
ss_dfprintf(stderr, "\t..done\nAdding protocol testprotocol.");
|
||||||
ss_info_dassert(0 != serviceAddProtocol(service, "testprotocol", "localhost", 9876, "MySQL", NULL), "Add Protocol should succeed");
|
ss_info_dassert(0 != serviceAddProtocol(service, "testprotocol", "localhost", 9876, "MySQL", NULL), "Add Protocol should succeed");
|
||||||
ss_info_dassert(0 != serviceHasProtocol(service, "testprotocol", 9876), "Service should have new protocol as requested");
|
ss_info_dassert(0 != serviceHasProtocol(service, "testprotocol", "localhost", 9876), "Service should have new protocol as requested");
|
||||||
serviceStartProtocol(service, "testprotocol", 9876);
|
serviceStartProtocol(service, "testprotocol", 9876);
|
||||||
mxs_log_flush_sync();
|
mxs_log_flush_sync();
|
||||||
ss_dfprintf(stderr, "\t..done\nStarting Service.");
|
ss_dfprintf(stderr, "\t..done\nStarting Service.");
|
||||||
|
@ -175,7 +175,8 @@ extern int service_free(SERVICE *);
|
|||||||
extern SERVICE *service_find(char *);
|
extern SERVICE *service_find(char *);
|
||||||
extern int service_isvalid(SERVICE *);
|
extern int service_isvalid(SERVICE *);
|
||||||
extern int serviceAddProtocol(SERVICE *, char *, char *, unsigned short, char *, SSL_LISTENER *);
|
extern int serviceAddProtocol(SERVICE *, char *, char *, unsigned short, char *, SSL_LISTENER *);
|
||||||
extern int serviceHasProtocol(SERVICE *, char *, unsigned short);
|
extern int serviceHasProtocol(SERVICE *service, const char *protocol,
|
||||||
|
const char* address, unsigned short port);
|
||||||
extern void serviceAddBackend(SERVICE *, SERVER *);
|
extern void serviceAddBackend(SERVICE *, SERVER *);
|
||||||
extern int serviceHasBackend(SERVICE *, SERVER *);
|
extern int serviceHasBackend(SERVICE *, SERVER *);
|
||||||
extern void serviceAddRouterOption(SERVICE *, char *);
|
extern void serviceAddRouterOption(SERVICE *, char *);
|
||||||
|
Reference in New Issue
Block a user