]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix signal source initialization.
authorVMware, Inc <>
Thu, 22 Dec 2011 00:33:49 +0000 (16:33 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 22 Dec 2011 00:33:49 +0000 (16:33 -0800)
Code was doing initialization multiple times and probably leaking a few
fds in the process.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/libvmtools/signalSource.c

index e35cc4f7f73db7e9fe3dc46ee5daf6e05f93deb9..aff25ef108cf500bb4ef2099c9aa9552e2d48e34 100644 (file)
@@ -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);