[ovs-dev] [threads 10/23] ovsdb-data: Make ovsdb_atom_default() thread-safe.
Alex Wang
alexw at nicira.com
Mon Jul 22 17:51:43 UTC 2013
Looks good to me, thanks,
Review for patch 1/23~10/23 is complete.
On Thu, Jul 18, 2013 at 4:15 PM, Ben Pfaff <blp at nicira.com> wrote:
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
> lib/ovsdb-data.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/lib/ovsdb-data.c b/lib/ovsdb-data.c
> index 7ec7694..ade1971 100644
> --- a/lib/ovsdb-data.c
> +++ b/lib/ovsdb-data.c
> @@ -24,6 +24,7 @@
>
> #include "dynamic-string.h"
> #include "hash.h"
> +#include "ovs-thread.h"
> #include "ovsdb-error.h"
> #include "ovsdb-parser.h"
> #include "json.h"
> @@ -94,9 +95,9 @@ const union ovsdb_atom *
> ovsdb_atom_default(enum ovsdb_atomic_type type)
> {
> static union ovsdb_atom default_atoms[OVSDB_N_TYPES];
> - static bool inited;
> + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
>
> - if (!inited) {
> + if (ovsthread_once_start(&once)) {
> int i;
>
> for (i = 0; i < OVSDB_N_TYPES; i++) {
> @@ -104,7 +105,7 @@ ovsdb_atom_default(enum ovsdb_atomic_type type)
> ovsdb_atom_init_default(&default_atoms[i], i);
> }
> }
> - inited = true;
> + ovsthread_once_done(&once);
> }
>
> ovs_assert(ovsdb_atomic_type_is_valid(type));
> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openvswitch.org/pipermail/ovs-dev/attachments/20130722/aa223489/attachment-0003.html>
More information about the dev
mailing list