diff options
author | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-07-24 20:58:41 +0200 |
---|---|---|
committer | Michał Łyszczek <michal.lyszczek@bofc.pl> | 2017-07-24 20:58:41 +0200 |
commit | 6e0e8fceeb4bf5c36e1413b856b353c7ce38d412 (patch) | |
tree | daf6e138f2144adfe2ca9ed8ec2d16104bbb1ed5 /rb | |
parent | 0bb7849eccb66dc76ca0a3f04f9ec901a61f4973 (diff) | |
download | librb-6e0e8fceeb4bf5c36e1413b856b353c7ce38d412.tar.gz librb-6e0e8fceeb4bf5c36e1413b856b353c7ce38d412.tar.bz2 librb-6e0e8fceeb4bf5c36e1413b856b353c7ce38d412.zip |
Fixed working on uninitialized mutex in nonblock mode
Diffstat (limited to 'rb')
-rw-r--r-- | rb/rb.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -756,7 +756,7 @@ long rb_send int rb_clear ( - struct rb* rb /* rb object */ + struct rb* rb, /* rb object */ int clear /* if set to 1, also clears memory */ ) { @@ -767,19 +767,25 @@ int rb_clear } #if HAVE_PTHREAD - pthread_mutex_lock(&rb->lock); + if ((rb->flags & O_NONBLOCK) == 0) + { + pthread_mutex_lock(&rb->lock); + } #endif if (clear) { - memset(buffer, 0x00, rb->count * rb->object_size); + memset(rb->buffer, 0x00, rb->count * rb->object_size); } rb->head = 0; rb->tail = 0; #if HAVE_PTHREAD - pthread_mutex_unlock(&rb->lock); + if ((rb->flags & O_NONBLOCK) == 0) + { + pthread_mutex_unlock(&rb->lock); + } #endif return 0; |