Cleaned up the use of thread types
The THREAD type was not used everywhere and pthread_t was used instead. The thread creation function also returned the address of a stack allocated value which isn't guaranteed to be usable.
This commit is contained in:
@ -200,7 +200,11 @@ startMonitor(void *arg, void* opt)
|
||||
memset(handle->events, true, sizeof(handle->events));
|
||||
}
|
||||
|
||||
handle->tid = (THREAD) thread_start(monitorMain, mon);
|
||||
if (thread_start(&handle->thread, monitorMain, mon) == NULL)
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", mon->name);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -216,7 +220,7 @@ stopMonitor(void *arg)
|
||||
GALERA_MONITOR *handle = (GALERA_MONITOR *) mon->handle;
|
||||
|
||||
handle->shutdown = 1;
|
||||
thread_wait((void *) handle->tid);
|
||||
thread_wait(handle->thread);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
typedef struct
|
||||
{
|
||||
SPINLOCK lock; /**< The monitor spinlock */
|
||||
pthread_t tid; /**< id of monitor thread */
|
||||
THREAD thread; /**< Monitor thread */
|
||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||
int status; /**< Monitor status */
|
||||
unsigned long id; /**< Monitor ID */
|
||||
|
||||
@ -173,7 +173,12 @@ startMonitor(void *arg, void* opt)
|
||||
{
|
||||
memset(handle->events, true, sizeof(handle->events));
|
||||
}
|
||||
handle->tid = (THREAD) thread_start(monitorMain, mon);
|
||||
|
||||
if (thread_start(handle->thread, monitorMain, mon) == NULL)
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", mon->name);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -189,7 +194,7 @@ stopMonitor(void *arg)
|
||||
MM_MONITOR *handle = (MM_MONITOR *) mon->handle;
|
||||
|
||||
handle->shutdown = 1;
|
||||
thread_wait((void *) handle->tid);
|
||||
thread_wait((void *) handle->thread);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
typedef struct
|
||||
{
|
||||
SPINLOCK lock; /**< The monitor spinlock */
|
||||
pthread_t tid; /**< id of monitor thread */
|
||||
THREAD thread; /**< Monitor thread */
|
||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||
int status; /**< Monitor status */
|
||||
unsigned long id; /**< Monitor ID */
|
||||
|
||||
@ -205,7 +205,11 @@ startMonitor(void *arg, void* opt)
|
||||
memset(handle->events, true, sizeof(handle->events));
|
||||
}
|
||||
|
||||
handle->tid = (THREAD) thread_start(monitorMain, monitor);
|
||||
if (thread_start(&handle->thread, monitorMain, monitor) == NULL)
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", monitor->name);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -221,7 +225,7 @@ stopMonitor(void *arg)
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) mon->handle;
|
||||
|
||||
handle->shutdown = 1;
|
||||
thread_wait((void *) handle->tid);
|
||||
thread_wait(handle->thread);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -60,7 +60,7 @@
|
||||
typedef struct
|
||||
{
|
||||
SPINLOCK lock; /**< The monitor spinlock */
|
||||
pthread_t tid; /**< id of monitor thread */
|
||||
THREAD thread; /**< Monitor thread */
|
||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||
int status; /**< Monitor status */
|
||||
unsigned long id; /**< Monitor ID */
|
||||
|
||||
@ -164,7 +164,12 @@ startMonitor(void *arg, void* opt)
|
||||
{
|
||||
memset(handle->events, true, sizeof(handle->events));
|
||||
}
|
||||
handle->tid = (THREAD) thread_start(monitorMain, mon);
|
||||
|
||||
if (thread_start(&handle->thread, monitorMain, mon) == NULL)
|
||||
{
|
||||
MXS_ERROR("Failed to start monitor thread for monitor '%s'.", mon->name);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -180,7 +185,7 @@ stopMonitor(void *arg)
|
||||
MYSQL_MONITOR *handle = (MYSQL_MONITOR *) mon->handle;
|
||||
|
||||
handle->shutdown = 1;
|
||||
thread_wait((void *) handle->tid);
|
||||
thread_wait(handle->thread);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user