summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5c11a2e)
raw | patch | inline | side by side (parent: 5c11a2e)
author | Sebastian Harl <sh@tokkee.org> | |
Sat, 19 Oct 2013 09:58:11 +0000 (11:58 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Sat, 19 Oct 2013 09:58:11 +0000 (11:58 +0200) |
All access to the channel needs to be fully synchronized.
src/utils/channel.c | patch | blob | history |
diff --git a/src/utils/channel.c b/src/utils/channel.c
index 1b687845a0f14a1f3c4b37d9d1b51f61df17fa80..c57b09d66123ba338925103f34d634cb861a4589 100644 (file)
--- a/src/utils/channel.c
+++ b/src/utils/channel.c
*/
struct sdb_channel {
- pthread_rwlock_t lock;
+ pthread_mutex_t lock;
/* maybe TODO: add support for 'nil' values using a boolean area */
chan->data_len = size;
chan->elem_size = elem_size;
- pthread_rwlock_init(&chan->lock, /* attr = */ NULL);
+ pthread_mutex_init(&chan->lock, /* attr = */ NULL);
chan->head = chan->tail = 0;
return chan;
if (! chan)
return;
- pthread_rwlock_wrlock(&chan->lock);
+ pthread_mutex_lock(&chan->lock);
free(chan->data);
chan->data = NULL;
chan->data_len = 0;
- pthread_rwlock_unlock(&chan->lock);
- pthread_rwlock_destroy(&chan->lock);
+ pthread_mutex_unlock(&chan->lock);
+ pthread_mutex_destroy(&chan->lock);
free(chan);
} /* sdb_channel_destroy */
if ((! chan) || (! data))
return -1;
- pthread_rwlock_wrlock(&chan->lock);
+ pthread_mutex_lock(&chan->lock);
status = channel_write(chan, data);
- pthread_rwlock_unlock(&chan->lock);
+ pthread_mutex_unlock(&chan->lock);
return status;
} /* sdb_channel_write */
if ((! chan) || (! data))
return -1;
- pthread_rwlock_wrlock(&chan->lock);
+ pthread_mutex_lock(&chan->lock);
status = channel_read(chan, data);
- pthread_rwlock_unlock(&chan->lock);
+ pthread_mutex_unlock(&chan->lock);
return status;
} /* sdb_channel_read */