+ static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+ static const char *dbdir;
+
+ if (ovsthread_once_start(&once)) {
+ dbdir = getenv("OVS_DBDIR");
+ if (!dbdir || !dbdir[0]) {
+ char *sysconfdir = getenv("OVS_SYSCONFDIR");
+
+ dbdir = (sysconfdir
+ ? xasprintf("%s/openvswitch", sysconfdir)
+ : @DBDIR@);
+ }
+ ovsthread_once_done(&once);
+ }
+ return dbdir;