mirror of
https://github.com/Silicondust/libhdhomerun
synced 2025-08-20 13:33:29 -07:00
fix mutex resource leak on windows
This commit is contained in:
parent
4ea54cddbc
commit
b618171f70
6 changed files with 20 additions and 0 deletions
|
@ -111,6 +111,9 @@ void hdhomerun_debug_destroy(struct hdhomerun_debug_t *dbg)
|
|||
hdhomerun_sock_destroy(dbg->sock);
|
||||
}
|
||||
|
||||
pthread_mutex_dispose(&dbg->print_lock);
|
||||
pthread_mutex_dispose(&dbg->queue_lock);
|
||||
pthread_mutex_dispose(&dbg->send_lock);
|
||||
free(dbg);
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,10 @@ void msleep_minimum(uint64_t ms)
|
|||
}
|
||||
}
|
||||
|
||||
void pthread_mutex_dispose(pthread_mutex_t *mutex)
|
||||
{
|
||||
}
|
||||
|
||||
void thread_cond_init(thread_cond_t *cond)
|
||||
{
|
||||
cond->signaled = FALSE;
|
||||
|
|
|
@ -59,6 +59,8 @@ extern LIBHDHOMERUN_API uint64_t getcurrenttime(void);
|
|||
extern LIBHDHOMERUN_API void msleep_approx(uint64_t ms);
|
||||
extern LIBHDHOMERUN_API void msleep_minimum(uint64_t ms);
|
||||
|
||||
extern LIBHDHOMERUN_API void pthread_mutex_dispose(pthread_mutex_t *mutex);
|
||||
|
||||
extern LIBHDHOMERUN_API void thread_cond_init(thread_cond_t *cond);
|
||||
extern LIBHDHOMERUN_API void thread_cond_dispose(thread_cond_t *cond);
|
||||
extern LIBHDHOMERUN_API void thread_cond_signal(thread_cond_t *cond);
|
||||
|
|
|
@ -100,6 +100,11 @@ void pthread_mutex_init(pthread_mutex_t *mutex, void *attr)
|
|||
*mutex = CreateMutex(NULL, FALSE, NULL);
|
||||
}
|
||||
|
||||
void pthread_mutex_dispose(pthread_mutex_t *mutex)
|
||||
{
|
||||
CloseHandle(*mutex);
|
||||
}
|
||||
|
||||
void pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
{
|
||||
WaitForSingleObject(*mutex, INFINITE);
|
||||
|
|
|
@ -86,6 +86,7 @@ extern LIBHDHOMERUN_API void msleep_minimum(uint64_t ms);
|
|||
extern LIBHDHOMERUN_API int pthread_create(pthread_t *tid, void *attr, LPTHREAD_START_ROUTINE start, void *arg);
|
||||
extern LIBHDHOMERUN_API int pthread_join(pthread_t tid, void **value_ptr);
|
||||
extern LIBHDHOMERUN_API void pthread_mutex_init(pthread_mutex_t *mutex, void *attr);
|
||||
extern LIBHDHOMERUN_API void pthread_mutex_dispose(pthread_mutex_t *mutex);
|
||||
extern LIBHDHOMERUN_API void pthread_mutex_lock(pthread_mutex_t *mutex);
|
||||
extern LIBHDHOMERUN_API void pthread_mutex_unlock(pthread_mutex_t *mutex);
|
||||
|
||||
|
|
|
@ -105,9 +105,13 @@ error:
|
|||
if (vs->sock) {
|
||||
hdhomerun_sock_destroy(vs->sock);
|
||||
}
|
||||
|
||||
if (vs->buffer) {
|
||||
free(vs->buffer);
|
||||
}
|
||||
|
||||
pthread_mutex_dispose(&vs->lock);
|
||||
|
||||
free(vs);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -118,6 +122,7 @@ void hdhomerun_video_destroy(struct hdhomerun_video_sock_t *vs)
|
|||
pthread_join(vs->thread, NULL);
|
||||
|
||||
hdhomerun_sock_destroy(vs->sock);
|
||||
pthread_mutex_dispose(&vs->lock);
|
||||
free(vs->buffer);
|
||||
|
||||
free(vs);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue