ofproto: Add a ref_count to "struct rule" to protect it from being freed.
authorBen Pfaff <blp@nicira.com>
Thu, 12 Sep 2013 06:23:00 +0000 (23:23 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 13 Sep 2013 00:43:52 +0000 (17:43 -0700)
commita2143702724647df8a9aef570982738dd3721af0
tree90c9aed6de67b1cb60a0655506fb95df8150b3e6
parent6f00e29b8b3f6996eceffc57b47bf707589d8335
ofproto: Add a ref_count to "struct rule" to protect it from being freed.

Taking a read-lock on the 'rwlock' member of struct rule prevents members
of the rule from changing.  This is a short-term use of the 'rwlock': one
takes the lock, reads some members, and releases the lock.

Taking a read-lock on the 'rwlock' also prevents the rule from being freed.
This is often a relatively long-term need.  For example, until now flow
translation has held the rwlock in xlate_table_action() across the entire
recursive translation, which can call into a great deal of different code
across multiple files.

This commit switches to using a reference count for this second purpose
of struct rule's rwlock.  This means that all the code that previously
held a read-lock on the rwlock across deep stacks of functions can now
simply keep a reference.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Ethan Jackson <ethan@nicira.com>
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-dpif-xlate.c
ofproto/ofproto-dpif.c
ofproto/ofproto-dpif.h
ofproto/ofproto-provider.h
ofproto/ofproto.c