aboutsummaryrefslogtreecommitdiff
path: root/lib/netlink-socket.c
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2013-07-30 15:31:48 -0700
committerBen Pfaff <blp@nicira.com>2013-07-30 21:30:45 -0700
commit97be153858b4cd175cbe7862b8e1624bf22ab98a (patch)
treeab1e518bef4e8bbc97fe8a069d9b91541bb9c4d4 /lib/netlink-socket.c
parent2b51596fdeba7fbf4caff323dd6af375e7f84596 (diff)
clang: Add annotations for thread safety check.
This commit adds annotations for thread safety check. And the check can be conducted by using -Wthread-safety flag in clang. Co-authored-by: Alex Wang <alexw@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/netlink-socket.c')
-rw-r--r--lib/netlink-socket.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/netlink-socket.c b/lib/netlink-socket.c
index da32284b..99bd4cc0 100644
--- a/lib/netlink-socket.c
+++ b/lib/netlink-socket.c
@@ -1012,8 +1012,8 @@ struct nl_pool {
int n;
};
-static struct nl_pool pools[MAX_LINKS];
-static pthread_mutex_t pool_mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER;
+static struct ovs_mutex pool_mutex = OVS_ADAPTIVE_MUTEX_INITIALIZER;
+static struct nl_pool pools[MAX_LINKS] OVS_GUARDED_BY(pool_mutex);
static int
nl_pool_alloc(int protocol, struct nl_sock **sockp)
@@ -1023,12 +1023,12 @@ nl_pool_alloc(int protocol, struct nl_sock **sockp)
ovs_assert(protocol >= 0 && protocol < ARRAY_SIZE(pools));
- xpthread_mutex_lock(&pool_mutex);
+ ovs_mutex_lock(&pool_mutex);
pool = &pools[protocol];
if (pool->n > 0) {
sock = pool->socks[--pool->n];
}
- xpthread_mutex_unlock(&pool_mutex);
+ ovs_mutex_unlock(&pool_mutex);
if (sock) {
*sockp = sock;
@@ -1044,12 +1044,12 @@ nl_pool_release(struct nl_sock *sock)
if (sock) {
struct nl_pool *pool = &pools[sock->protocol];
- xpthread_mutex_lock(&pool_mutex);
+ ovs_mutex_lock(&pool_mutex);
if (pool->n < ARRAY_SIZE(pool->socks)) {
pool->socks[pool->n++] = sock;
sock = NULL;
}
- xpthread_mutex_unlock(&pool_mutex);
+ ovs_mutex_unlock(&pool_mutex);
nl_sock_destroy(sock);
}