Shutdown all monitors when shutting down the gateway

This commit is contained in:
Mark Riddoch 2013-07-24 14:44:29 +02:00
parent 7cdffb26e6
commit 8482c560f7
4 changed files with 24 additions and 1 deletions

View File

@ -50,6 +50,7 @@
#include <stdlib.h>
#include <mysql.h>
#include <monitor.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -407,6 +408,9 @@ char ddopt[1024];
for (n = 0; n < n_threads - 1; n++)
thread_wait(threads[n]);
/* Stop all the monitors */
monitorStopAll();
skygw_log_write(NULL, LOGFILE_MESSAGE, "MaxScale shutdown, PID %i\n", getpid());
return 0;

View File

@ -104,6 +104,24 @@ MONITOR *ptr;
free(mon);
}
/**
* Shutdown all running monitors
*/
void
monitorStopAll()
{
MONITOR *ptr;
spinlock_acquire(&monLock);
ptr = allMonitors;
while (ptr)
{
ptr->module->stopMonitor(ptr->handle);
ptr = ptr->next;
}
spinlock_release(&monLock);
}
/**
* Add a server to a monitor. Simply register the server that needs to be
* monitored to the running monitor module.

View File

@ -39,7 +39,7 @@ static int
secrets_random_str(unsigned char *output, int len)
{
int i;
srand(time(0L));
srand((unsigned long )time(0L) ^ (unsigned long )output);
for ( i = 0; i < len; ++i )
{

View File

@ -78,4 +78,5 @@ extern MONITOR *monitor_alloc(char *, char *);
extern void monitor_free(MONITOR *);
extern void monitorAddServer(MONITOR *, SERVER *);
extern void monitorAddUser(MONITOR *, char *, char *);
extern void monitorStopAll();
#endif