Monitors that run on separate thread call thread_wait in stopMonitor.
Fixes problem with ordering of calls to mysql_library_end (in main) and mysql_thread_end (in monitor thr).
This commit is contained in:
@ -117,7 +117,7 @@ MYSQL_MONITOR *handle;
|
||||
handle->deaultPasswd = NULL;
|
||||
spinlock_init(&handle->lock);
|
||||
}
|
||||
thread_start(monitorMain, handle);
|
||||
handle->tid = thread_start(monitorMain, handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -131,7 +131,8 @@ stopMonitor(void *arg)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||
|
||||
handle->shutdown = 1;
|
||||
handle->shutdown = 1;
|
||||
thread_wait(handle->tid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -107,23 +107,23 @@ startMonitor(void *arg)
|
||||
{
|
||||
MYSQL_MONITOR *handle;
|
||||
|
||||
if (arg)
|
||||
{
|
||||
handle = arg; /* Must be a restart */
|
||||
handle->shutdown = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
||||
return NULL;
|
||||
handle->databases = NULL;
|
||||
handle->shutdown = 0;
|
||||
handle->defaultUser = NULL;
|
||||
handle->defaultPasswd = NULL;
|
||||
spinlock_init(&handle->lock);
|
||||
}
|
||||
thread_start(monitorMain, handle);
|
||||
return handle;
|
||||
if (arg)
|
||||
{
|
||||
handle = arg; /* Must be a restart */
|
||||
handle->shutdown = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((handle = (MYSQL_MONITOR *)malloc(sizeof(MYSQL_MONITOR))) == NULL)
|
||||
return NULL;
|
||||
handle->databases = NULL;
|
||||
handle->shutdown = 0;
|
||||
handle->defaultUser = NULL;
|
||||
handle->defaultPasswd = NULL;
|
||||
spinlock_init(&handle->lock);
|
||||
}
|
||||
handle->tid = thread_start(monitorMain, handle);
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,7 +136,8 @@ stopMonitor(void *arg)
|
||||
{
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
|
||||
|
||||
handle->shutdown = 1;
|
||||
handle->shutdown = 1;
|
||||
thread_wait(handle->tid);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -48,12 +48,13 @@ typedef struct monitor_servers {
|
||||
* The handle for an instance of a MySQL Monitor module
|
||||
*/
|
||||
typedef struct {
|
||||
SPINLOCK lock; /**< The monitor spinlock */
|
||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||
int status; /**< Monitor status */
|
||||
char *defaultUser; /**< Default username for monitoring */
|
||||
char *defaultPasswd; /**< Default password for monitoring */
|
||||
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
|
||||
SPINLOCK lock; /**< The monitor spinlock */
|
||||
pthread_t tid; /**< id of monitor thread */
|
||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||
int status; /**< Monitor status */
|
||||
char *defaultUser; /**< Default username for monitoring */
|
||||
char *defaultPasswd; /**< Default password for monitoring */
|
||||
MONITOR_SERVERS *databases; /**< Linked list of servers to monitor */
|
||||
} MYSQL_MONITOR;
|
||||
|
||||
#define MONITOR_RUNNING 1
|
||||
|
||||
Reference in New Issue
Block a user