Allow NULL parameters for start/stop functions
The functions that start and stop monitors and services now accept NULL parameters.
This commit is contained in:
@ -164,18 +164,21 @@ monitor_free(MXS_MONITOR *mon)
|
|||||||
void
|
void
|
||||||
monitorStart(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
|
monitorStart(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
|
||||||
{
|
{
|
||||||
spinlock_acquire(&monitor->lock);
|
if (monitor)
|
||||||
|
|
||||||
if ((monitor->handle = (*monitor->module->startMonitor)(monitor, params)))
|
|
||||||
{
|
{
|
||||||
monitor->state = MONITOR_STATE_RUNNING;
|
spinlock_acquire(&monitor->lock);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MXS_ERROR("Failed to start monitor '%s'.", monitor->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
spinlock_release(&monitor->lock);
|
if ((monitor->handle = (*monitor->module->startMonitor)(monitor, params)))
|
||||||
|
{
|
||||||
|
monitor->state = MONITOR_STATE_RUNNING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MXS_ERROR("Failed to start monitor '%s'.", monitor->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
spinlock_release(&monitor->lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -203,26 +206,29 @@ void monitorStartAll()
|
|||||||
void
|
void
|
||||||
monitorStop(MXS_MONITOR *monitor)
|
monitorStop(MXS_MONITOR *monitor)
|
||||||
{
|
{
|
||||||
spinlock_acquire(&monitor->lock);
|
if (monitor)
|
||||||
|
|
||||||
/** Only stop the monitor if it is running */
|
|
||||||
if (monitor->state == MONITOR_STATE_RUNNING)
|
|
||||||
{
|
{
|
||||||
monitor->state = MONITOR_STATE_STOPPING;
|
spinlock_acquire(&monitor->lock);
|
||||||
monitor->module->stopMonitor(monitor);
|
|
||||||
monitor->state = MONITOR_STATE_STOPPED;
|
|
||||||
|
|
||||||
MXS_MONITOR_SERVERS* db = monitor->databases;
|
/** Only stop the monitor if it is running */
|
||||||
while (db)
|
if (monitor->state == MONITOR_STATE_RUNNING)
|
||||||
{
|
{
|
||||||
// TODO: Create a generic entry point for this or move it inside stopMonitor
|
monitor->state = MONITOR_STATE_STOPPING;
|
||||||
mysql_close(db->con);
|
monitor->module->stopMonitor(monitor);
|
||||||
db->con = NULL;
|
monitor->state = MONITOR_STATE_STOPPED;
|
||||||
db = db->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spinlock_release(&monitor->lock);
|
MXS_MONITOR_SERVERS* db = monitor->databases;
|
||||||
|
while (db)
|
||||||
|
{
|
||||||
|
// TODO: Create a generic entry point for this or move it inside stopMonitor
|
||||||
|
mysql_close(db->con);
|
||||||
|
db->con = NULL;
|
||||||
|
db = db->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
spinlock_release(&monitor->lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -627,23 +627,24 @@ int service_launch_all()
|
|||||||
|
|
||||||
bool serviceStop(SERVICE *service)
|
bool serviceStop(SERVICE *service)
|
||||||
{
|
{
|
||||||
SERV_LISTENER *port;
|
|
||||||
int listeners = 0;
|
int listeners = 0;
|
||||||
|
|
||||||
port = service->ports;
|
if (service)
|
||||||
while (port)
|
|
||||||
{
|
{
|
||||||
if (port->listener && port->listener->session->state == SESSION_STATE_LISTENER)
|
for (SERV_LISTENER * port = service->ports; port; port = port->next)
|
||||||
{
|
{
|
||||||
if (poll_remove_dcb(port->listener) == 0)
|
if (port->listener && port->listener->session->state == SESSION_STATE_LISTENER)
|
||||||
{
|
{
|
||||||
port->listener->session->state = SESSION_STATE_LISTENER_STOPPED;
|
if (poll_remove_dcb(port->listener) == 0)
|
||||||
listeners++;
|
{
|
||||||
|
port->listener->session->state = SESSION_STATE_LISTENER_STOPPED;
|
||||||
|
listeners++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
port = port->next;
|
|
||||||
|
service->state = SERVICE_STATE_STOPPED;
|
||||||
}
|
}
|
||||||
service->state = SERVICE_STATE_STOPPED;
|
|
||||||
|
|
||||||
return listeners > 0;
|
return listeners > 0;
|
||||||
}
|
}
|
||||||
@ -658,23 +659,25 @@ bool serviceStop(SERVICE *service)
|
|||||||
*/
|
*/
|
||||||
bool serviceStart(SERVICE *service)
|
bool serviceStart(SERVICE *service)
|
||||||
{
|
{
|
||||||
SERV_LISTENER *port;
|
|
||||||
int listeners = 0;
|
int listeners = 0;
|
||||||
|
|
||||||
port = service->ports;
|
if (service)
|
||||||
while (port)
|
|
||||||
{
|
{
|
||||||
if (port->listener && port->listener->session->state == SESSION_STATE_LISTENER_STOPPED)
|
for (SERV_LISTENER* port = service->ports; port; port = port->next)
|
||||||
{
|
{
|
||||||
if (poll_add_dcb(port->listener) == 0)
|
if (port->listener && port->listener->session->state == SESSION_STATE_LISTENER_STOPPED)
|
||||||
{
|
{
|
||||||
port->listener->session->state = SESSION_STATE_LISTENER;
|
if (poll_add_dcb(port->listener) == 0)
|
||||||
listeners++;
|
{
|
||||||
|
port->listener->session->state = SESSION_STATE_LISTENER;
|
||||||
|
listeners++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
port = port->next;
|
|
||||||
|
service->state = SERVICE_STATE_STARTED;
|
||||||
}
|
}
|
||||||
service->state = SERVICE_STATE_STARTED;
|
|
||||||
return listeners > 0;
|
return listeners > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user