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:
vraatikka
2013-07-26 11:27:54 +03:00
parent 03e70ab78f
commit 867eab37fc
3 changed files with 29 additions and 26 deletions

View File

@ -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;
}
@ -132,6 +132,7 @@ stopMonitor(void *arg)
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
handle->shutdown = 1;
thread_wait(handle->tid);
}
/**

View File

@ -122,7 +122,7 @@ MYSQL_MONITOR *handle;
handle->defaultPasswd = NULL;
spinlock_init(&handle->lock);
}
thread_start(monitorMain, handle);
handle->tid = thread_start(monitorMain, handle);
return handle;
}
@ -137,6 +137,7 @@ stopMonitor(void *arg)
MYSQL_MONITOR *handle = (MYSQL_MONITOR *)arg;
handle->shutdown = 1;
thread_wait(handle->tid);
}
/**

View File

@ -49,6 +49,7 @@ typedef struct monitor_servers {
*/
typedef struct {
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 */