summaryrefslogtreecommitdiffstats
path: root/data.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2016-03-22 19:19:17 +0100
committerSuren A. Chilingaryan <csa@suren.me>2016-03-22 19:19:17 +0100
commit954ffcdb0e16495152b613d11d205d0f31350793 (patch)
treed48b667ad42cdf9b0041b0137bd8b52749f661db /data.c
parent6fa5eb9906e9d5f47abd3f704bfe3604171c58ab (diff)
downloadipecamera-954ffcdb0e16495152b613d11d205d0f31350793.tar.gz
ipecamera-954ffcdb0e16495152b613d11d205d0f31350793.tar.bz2
ipecamera-954ffcdb0e16495152b613d11d205d0f31350793.tar.xz
ipecamera-954ffcdb0e16495152b613d11d205d0f31350793.zip
Fix minor error in rarely used path
Diffstat (limited to 'data.c')
-rw-r--r--data.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/data.c b/data.c
index 8f681e9..5a66835 100644
--- a/data.c
+++ b/data.c
@@ -79,7 +79,7 @@ ready:
}
static int ipecamera_get_next_buffer_to_process(ipecamera_t *ctx, pcilib_event_id_t *evid) {
- int res;
+ int err, res;
if (ctx->preproc_id == ctx->event_id) return -1;
@@ -101,9 +101,10 @@ static int ipecamera_get_next_buffer_to_process(ipecamera_t *ctx, pcilib_event_i
res = ctx->preproc_id%ctx->buffer_size;
- if (pthread_rwlock_trywrlock(&ctx->frame[res].mutex)) {
- pthread_mutex_unlock(&ctx->preproc_mutex);
- ipecamera_debug(HARDWARE, "Can't lock buffer %i", res);
+ if ((err = pthread_rwlock_trywrlock(&ctx->frame[res].mutex)) != 0) {
+ if (ctx->preproc)
+ pthread_mutex_unlock(&ctx->preproc_mutex);
+ ipecamera_debug(HARDWARE, "Can't lock buffer %i, errno %i", res, err);
return -1;
}