diff options
author | Michael S. Tsirkin <mst@mellanox.co.il> | 2005-11-09 23:35:13 +0000 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-09 11:35:58 -0800 |
commit | 2301234559e24a6f172ac26dbc015cd24779e99f (patch) | |
tree | 09567919d9703fff88e58ae41990569b014458b1 | |
parent | 36e717cf0f92f70b8fe9f851cd6e7f2d57e88d03 (diff) | |
download | libibverbs-2301234559e24a6f172ac26dbc015cd24779e99f.tar.gz |
Make ibv_get_devices reentrant
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
-rw-r--r-- | src/device.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/device.c b/src/device.c index 47e771e..c425b06 100644 --- a/src/device.c +++ b/src/device.c @@ -48,13 +48,20 @@ #include "ibverbs.h" +static pthread_mutex_t device_list_lock = PTHREAD_MUTEX_INITIALIZER; static struct dlist *device_list; struct dlist *ibv_get_devices(void) { + struct dlist *l; + + pthread_mutex_lock(&device_list_lock); if (!device_list) device_list = ibverbs_init(); - return device_list; + l = device_list; + pthread_mutex_unlock(&device_list_lock); + + return l; } const char *ibv_get_device_name(struct ibv_device *device) |