From: Ben Pfaff Date: Wed, 24 Apr 2013 21:00:13 +0000 (-0700) Subject: vlog: Make VLOG_ONCE thread-safe. X-Git-Tag: sliver-openvswitch-2.0.90-1~36^2~15 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f1de299e0cee4b438e8d2b535c14ffbb75309a09;p=sliver-openvswitch.git vlog: Make VLOG_ONCE thread-safe. Of course, the code it calls into isn't thread-safe itself yet. Signed-off-by: Ben Pfaff --- diff --git a/lib/vlog.h b/lib/vlog.h index 3466d964b..eeec5fce7 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -231,13 +231,13 @@ void vlog_usage(void); vlog_rate_limit(THIS_MODULE, level__, RL, __VA_ARGS__); \ } \ } while (0) -#define VLOG_ONCE(LEVEL, ...) \ - do { \ - static bool already_logged; \ - if (!already_logged) { \ - already_logged = true; \ - vlog(THIS_MODULE, LEVEL, __VA_ARGS__); \ - } \ +#define VLOG_ONCE(LEVEL, ...) \ + do { \ + static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; \ + if (ovsthread_once_start(&once)) { \ + vlog(THIS_MODULE, LEVEL, __VA_ARGS__); \ + ovsthread_once_done(&once); \ + } \ } while (0) #define VLOG_DEFINE_MODULE__(MODULE) \