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 04:18:44 +0000 (21:18 -0700)
commit10dc53e24ee265f1adae4ba951a6010e67193bea
treeb9cd9081abb8efac47d63ec5639a3078b72a447a
parent5fd1c0ed4efdb8342e14fd101b1c62a18b4d00d4
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