Skip to content
Snippets Groups Projects
Verified Commit f70b699f authored by rahix's avatar rahix
Browse files

fix(streams): Warn on lock error


Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 7b8e4ae4
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include "semphr.h" #include "semphr.h"
#include "epicardium.h" #include "epicardium.h"
#include "stream.h" #include "modules/log.h"
#include "modules/stream.h"
/* Internal buffer of registered streams */ /* Internal buffer of registered streams */
static struct stream_info *stream_table[SD_MAX]; static struct stream_info *stream_table[SD_MAX];
...@@ -24,6 +25,7 @@ int stream_init() ...@@ -24,6 +25,7 @@ int stream_init()
int stream_register(int sd, struct stream_info *stream) int stream_register(int sd, struct stream_info *stream)
{ {
if (xSemaphoreTake(stream_table_lock, STREAM_MUTEX_WAIT) != pdTRUE) { if (xSemaphoreTake(stream_table_lock, STREAM_MUTEX_WAIT) != pdTRUE) {
LOG_WARN("stream", "Lock contention error");
return -EBUSY; return -EBUSY;
} }
...@@ -45,6 +47,7 @@ int stream_register(int sd, struct stream_info *stream) ...@@ -45,6 +47,7 @@ int stream_register(int sd, struct stream_info *stream)
int stream_deregister(int sd, struct stream_info *stream) int stream_deregister(int sd, struct stream_info *stream)
{ {
if (xSemaphoreTake(stream_table_lock, STREAM_MUTEX_WAIT) != pdTRUE) { if (xSemaphoreTake(stream_table_lock, STREAM_MUTEX_WAIT) != pdTRUE) {
LOG_WARN("stream", "Lock contention error");
return -EBUSY; return -EBUSY;
} }
...@@ -71,6 +74,7 @@ int epic_stream_read(int sd, void *buf, size_t count) ...@@ -71,6 +74,7 @@ int epic_stream_read(int sd, void *buf, size_t count)
* of this would look like. * of this would look like.
*/ */
if (xSemaphoreTake(stream_table_lock, STREAM_MUTEX_WAIT) != pdTRUE) { if (xSemaphoreTake(stream_table_lock, STREAM_MUTEX_WAIT) != pdTRUE) {
LOG_WARN("stream", "Lock contention error");
return -EBUSY; return -EBUSY;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment