notify: make notify_init() failures fatal
When a mutex cannot be created, there must be something very wrong. Induce panic and abort MPD in this case.
This commit is contained in:
parent
770b140534
commit
ee1d723ad7
13
src/notify.c
13
src/notify.c
@ -17,24 +17,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
int notify_init(struct notify *notify)
|
void notify_init(struct notify *notify)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = pthread_mutex_init(¬ify->mutex, NULL);
|
ret = pthread_mutex_init(¬ify->mutex, NULL);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
return ret;
|
FATAL("pthread_mutex_init() failed");
|
||||||
|
|
||||||
ret = pthread_cond_init(¬ify->cond, NULL);
|
ret = pthread_cond_init(¬ify->cond, NULL);
|
||||||
if (ret != 0) {
|
if (ret != 0)
|
||||||
pthread_mutex_destroy(¬ify->mutex);
|
FATAL("pthread_mutex_init() failed");
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
notify->pending = 0;
|
notify->pending = 0;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify_enter(struct notify *notify)
|
void notify_enter(struct notify *notify)
|
||||||
|
@ -27,7 +27,7 @@ typedef struct notify {
|
|||||||
int pending;
|
int pending;
|
||||||
} Notify;
|
} Notify;
|
||||||
|
|
||||||
int notify_init(struct notify *notify);
|
void notify_init(struct notify *notify);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The thread which shall be notified by this object must call this
|
* The thread which shall be notified by this object must call this
|
||||||
|
Loading…
Reference in New Issue
Block a user