aboutsummaryrefslogtreecommitdiff
path: root/lib/netdev-vport.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2013-04-26 13:20:30 -0700
committerBen Pfaff <blp@nicira.com>2013-07-23 11:38:17 -0700
commit6027d03dc347e3ea4d965571382e4ed8545fbed2 (patch)
tree06b90adb038f0f2164b8b24a14f08ece753bece9 /lib/netdev-vport.c
parentd0c79f7fe0954b5d607e4190d26bb6b5ba75ceaf (diff)
netdev-vport: Make pid checking in set_tunnel_config() thread-safe
Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Andy Zhou <azhou@nicira.com>
Diffstat (limited to 'lib/netdev-vport.c')
-rw-r--r--lib/netdev-vport.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 885bf5e3..4214b383 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -413,13 +413,17 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args)
}
if (tnl_cfg.ipsec) {
+ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static pid_t pid = 0;
+
+ pthread_mutex_lock(&mutex);
if (pid <= 0) {
char *file_name = xasprintf("%s/%s", ovs_rundir(),
"ovs-monitor-ipsec.pid");
pid = read_pidfile(file_name);
free(file_name);
}
+ pthread_mutex_unlock(&mutex);
if (pid < 0) {
VLOG_ERR("%s: IPsec requires the ovs-monitor-ipsec daemon",