Check if socket server is MaxScale service
We need to handle the case that a MaxScale service is used as a server over Unix domain sockets.
This commit is contained in:
@ -337,6 +337,14 @@ SListener service_find_listener(Service* service,
|
|||||||
*/
|
*/
|
||||||
bool service_port_is_used(int port);
|
bool service_port_is_used(int port);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if a MaxScale service listens on a Unix domain socket
|
||||||
|
*
|
||||||
|
* @param path The socket path to check
|
||||||
|
* @return True if a MaxScale service uses the socket
|
||||||
|
*/
|
||||||
|
bool service_socket_is_used(const std::string& socket_path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check if the service has a listener with a matching name
|
* @brief Check if the service has a listener with a matching name
|
||||||
*
|
*
|
||||||
|
|||||||
@ -914,7 +914,14 @@ bool SERVER::is_mxs_service()
|
|||||||
bool rval = false;
|
bool rval = false;
|
||||||
|
|
||||||
/** Do a coarse check for local server pointing to a MaxScale service */
|
/** Do a coarse check for local server pointing to a MaxScale service */
|
||||||
if (strcmp(address, "127.0.0.1") == 0
|
if (address[0] == '/')
|
||||||
|
{
|
||||||
|
if (service_socket_is_used(address))
|
||||||
|
{
|
||||||
|
rval = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (strcmp(address, "127.0.0.1") == 0
|
||||||
|| strcmp(address, "::1") == 0
|
|| strcmp(address, "::1") == 0
|
||||||
|| strcmp(address, "localhost") == 0
|
|| strcmp(address, "localhost") == 0
|
||||||
|| strcmp(address, "localhost.localdomain") == 0)
|
|| strcmp(address, "localhost.localdomain") == 0)
|
||||||
|
|||||||
@ -1559,6 +1559,31 @@ bool service_port_is_used(int port)
|
|||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool service_socket_is_used(const std::string& socket_path)
|
||||||
|
{
|
||||||
|
bool rval = false;
|
||||||
|
LockGuard guard(this_unit.lock);
|
||||||
|
|
||||||
|
for (Service* service : this_unit.services)
|
||||||
|
{
|
||||||
|
for (const auto& listener : listener_find_by_service(service))
|
||||||
|
{
|
||||||
|
if (listener->address() == socket_path)
|
||||||
|
{
|
||||||
|
rval = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rval)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
static const char* service_state_to_string(int state)
|
static const char* service_state_to_string(int state)
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
|
|||||||
Reference in New Issue
Block a user