aboutsummaryrefslogtreecommitdiffstats
path: root/rb
diff options
context:
space:
mode:
authorMichał Łyszczek <michal.lyszczek@bofc.pl>2017-07-24 20:58:41 +0200
committerMichał Łyszczek <michal.lyszczek@bofc.pl>2017-07-24 20:58:41 +0200
commit6e0e8fceeb4bf5c36e1413b856b353c7ce38d412 (patch)
treedaf6e138f2144adfe2ca9ed8ec2d16104bbb1ed5 /rb
parent0bb7849eccb66dc76ca0a3f04f9ec901a61f4973 (diff)
downloadlibrb-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.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/rb/rb.c b/rb/rb.c
index 93974b7..2371e92 100644
--- a/rb/rb.c
+++ b/rb/rb.c
@@ -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;