From: VMware, Inc <> Date: Thu, 22 Dec 2011 00:33:49 +0000 (-0800) Subject: Fix signal source initialization. X-Git-Tag: 2011.12.20-562307~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bba562e974c58b2b85166e16fc93a717801e19dd;p=thirdparty%2Fopen-vm-tools.git Fix signal source initialization. Code was doing initialization multiple times and probably leaking a few fds in the process. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/libvmtools/signalSource.c b/open-vm-tools/libvmtools/signalSource.c index e35cc4f7f..aff25ef10 100644 --- a/open-vm-tools/libvmtools/signalSource.c +++ b/open-vm-tools/libvmtools/signalSource.c @@ -56,7 +56,7 @@ typedef struct SignalHandler { siginfo_t currSignal; } SignalHandler; -static SignalHandler gHandler = { FALSE, }; +static SignalHandler gHandler; G_LOCK_DEFINE_STATIC(gLock); typedef struct SignalSource { @@ -270,7 +270,6 @@ VMTools_NewSignalSource(int signum) G_LOCK(gLock); if (!gHandler.initialized) { - memset(&gHandler, 0, sizeof gHandler); if (pipe(gHandler.wakeupPipe) == -1 || fcntl(gHandler.wakeupPipe[0], F_SETFL, O_RDONLY | O_NONBLOCK) < 0 || fcntl(gHandler.wakeupPipe[1], F_SETFL, O_WRONLY | O_NONBLOCK) < 0) { @@ -280,6 +279,7 @@ VMTools_NewSignalSource(int signum) gHandler.wakeupFd.events = G_IO_IN | G_IO_ERR; gHandler.handler.sa_sigaction = SignalSourceSigHandler; gHandler.handler.sa_flags = SA_SIGINFO; + gHandler.initialized = TRUE; } G_UNLOCK(gLock);