fat-rwlock: fat_rwlock_tryrdlock() should never block
authorDaniele Di Proietto <ddiproietto@vmware.com>
Mon, 18 Aug 2014 19:57:42 +0000 (12:57 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 18 Aug 2014 20:17:34 +0000 (13:17 -0700)
commit1ef49150ab78f1f859bd875ce3ce7fcec778554c
tree6fa7136a008df3245304625eb43455d26cc0f74f
parent9475dfeb28a5dc0a6e3042d96534d9f8cb2ef266
fat-rwlock: fat_rwlock_tryrdlock() should never block

fat_rwlock_tryrdlock() used to call fat_rwlock_get_slot__() which could block
in the "slow path" case. This commit adds fat_rwlock_try_get_slot__() which
does not block, even in the "slow path" case.

This fixes a minor issue in dpif-netdev: when the datapath has no registered
upcall handler (e.g. if it is created with dpctl commands), dp_netdev_input()
hangs if it does not find a packet's flow in the classifier.  This is
because dpif-netdev uses its upcall_rwlock as a way to enable and disable
upcalls and thus holds the upcall_rwlock write lock as long as upcalls are
disabled.  Both holding the write lock and creating a slot require the
fat_rwlock's mutex, causing the hang.

Signed-off-by: Daniele Di Proietto <ddiproietto@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/fat-rwlock.c