#define CLOCK_REALTIME 0
#define CLOCK_MONOTONIC 0
-int clock_gettime(int clk_id, struct timespec* t)
+int clock_gettime(int clk_id, struct timespec *t)
{
UINT64 time;
double seconds;
}
#endif
-static void ts_add_ms(struct timespec* ts, DWORD dwMilliseconds)
+static void ts_add_ms(struct timespec *ts, DWORD dwMilliseconds)
{
ts->tv_sec += dwMilliseconds / 1000L;
ts->tv_nsec += (dwMilliseconds % 1000L) * 1000000L;
if (status != 1)
return WAIT_TIMEOUT;
+ pthread_mutex_lock(&thread->mutex);
+
if (!thread->joined)
{
status = pthread_join(thread->thread, NULL);
if (status != 0)
{
WLog_ERR(TAG, "pthread_join failure: [%d] %s",
- status, strerror(status));
+ status, strerror(status));
}
else
thread->joined = TRUE;
}
+
+ pthread_mutex_unlock(&thread->mutex);
}
else if (Type == HANDLE_TYPE_PROCESS)
{
ULONG Type;
PVOID Object;
#ifdef HAVE_POLL_H
- struct pollfd* pollfds;
+ struct pollfd *pollfds;
#else
int maxfd;
fd_set fds;
#endif
signalled = 0;
- do
+ do
{
if (bWaitAll && (dwMilliseconds != INFINITE))
clock_gettime(CLOCK_MONOTONIC, &starttime);
#ifdef WINPR_PIPE_SEMAPHORE
fd = ((WINPR_SEMAPHORE *) Object)->pipe_fd[0];
#else
- WLog_ERR(TAG, "semaphore not supported");
- return WAIT_FAILED;
+ WLog_ERR(TAG, "semaphore not supported");
+ return WAIT_FAILED;
#endif
}
else if (Type == HANDLE_TYPE_TIMER)
{
#ifdef HAVE_POLL_H
WLog_ERR(TAG, "poll() failure [%d] %s", errno,
- strerror(errno));
+ strerror(errno));
#else
WLog_ERR(TAG, "select() failure [%d] %s", errno,
- strerror(errno));
+ strerror(errno));
#endif
return WAIT_FAILED;
}
else if (Type == HANDLE_TYPE_THREAD)
{
WINPR_THREAD *thread = (WINPR_THREAD *)Object;
+ pthread_mutex_lock(&thread->mutex);
if (!thread->joined)
{
if (status != 0)
{
WLog_ERR(TAG, "pthread_join failure: [%d] %s",
- status, strerror(status));
+ status, strerror(status));
return WAIT_FAILED;
}
else
thread->joined = TRUE;
}
+
+ pthread_mutex_unlock(&thread->mutex);
}
if (bWaitAll)