netlink: Make nl_dump_next() thread-safe.
authorJoe Stringer <joestringer@nicira.com>
Thu, 27 Feb 2014 22:13:06 +0000 (14:13 -0800)
committerBen Pfaff <blp@nicira.com>
Thu, 27 Feb 2014 22:26:51 +0000 (14:26 -0800)
commit0672776e58770464a4b5ae356356e164b8db58d0
tree2dfd359832edd47903bbee15b1b66061e21d8fdd
parentd57695d77efe15b0b8a98aa2a1bcfcd3e3915e90
netlink: Make nl_dump_next() thread-safe.

This patch modifies 'struct nl_dump' and nl_dump_next() to allow
multiple threads to share the same nl_dump. These changes are targeted
around synchronizing dump status between multiple callers, and
allowing callers to fully process their existing buffers before
determining whether to stop fetching flows.

The 'status' field of 'struct nl_dump' becomes atomic, so that multiple
threads may check and/or update it to communicate when there is an error
or the netlink dump is finished. The low bit holds whether the final
message was seen, while the higher bits hold an errno value.

nl_dump_next() will now read all messages from the given buffer before
checking the shared error status and attempting to fetch more. Multiple
threads may call this with the same nl_dump, but must provide
independent buffers. As previously, the final dump status can be
determined by calling nl_dump_done() from a single thread.

Signed-off-by: Joe Stringer <joestringer@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/netlink-socket.c
lib/netlink-socket.h