[sheepdog] [PATCH 1/2] sockfd cache: fix a wrong type of read/write lock
Liu Yuan
namei.unix at gmail.com
Mon Dec 3 08:36:37 CET 2012
From: Liu Yuan <tailai.ly at taobao.com>
We should use write lock for sockfd_cache_add() because it changes the
node red-black tree state.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/sockfd_cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sheep/sockfd_cache.c b/sheep/sockfd_cache.c
index 137bbe4..33e780b 100644
--- a/sheep/sockfd_cache.c
+++ b/sheep/sockfd_cache.c
@@ -265,7 +265,7 @@ void sockfd_cache_add(const struct node_id *nid)
char name[INET6_ADDRSTRLEN];
int n, i;
- pthread_rwlock_rdlock(&sockfd_cache.lock);
+ pthread_rwlock_wrlock(&sockfd_cache.lock);
new = xmalloc(sizeof(*new));
new->fds = xzalloc(sizeof(struct sockfd_cache_fd) * fds_count);
for (i = 0; i < fds_count; i++)
--
1.7.9.5
More information about the sheepdog
mailing list