[Lldb-commits] [lldb] r123803 - in /lldb/trunk/source/Plugins/Process/Linux: ProcessMonitor.cpp ProcessMonitor.h

Stephen Wilson wilsons at start.ca
Tue Jan 18 17:37:06 PST 2011


Author: wilsons
Date: Tue Jan 18 19:37:06 2011
New Revision: 123803

URL: http://llvm.org/viewvc/llvm-project?rev=123803&view=rev
Log:
Delay sync with the parent thread in ProcessLinux/ProcessMonitor.

This patch removes a potential race condition between a process monitor thread
and its parent waiting to interrogate the success/failure of the launch.


Modified:
    lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
    lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=123803&r1=123802&r2=123803&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Tue Jan 18 19:37:06 2011
@@ -607,7 +607,7 @@
     if (!Launch(args))
         return NULL;
 
-    ServeOperation(args->m_monitor);
+    ServeOperation(args);
     return NULL;
 }
 
@@ -716,8 +716,6 @@
     process.SendMessage(ProcessMessage::Trace(pid));
 
 FINISH:
-    // Sync with our parent thread now that the launch operation is complete.
-    sem_post(&args->m_semaphore);
     return args->m_error.Success();
 }
 
@@ -819,15 +817,20 @@
 }
 
 void
-ProcessMonitor::ServeOperation(ProcessMonitor *monitor)
+ProcessMonitor::ServeOperation(LaunchArgs *args)
 {
     int status;
     pollfd fdset;
+    ProcessMonitor *monitor = args->m_monitor;
 
     fdset.fd = monitor->m_server_fd;
     fdset.events = POLLIN | POLLPRI;
     fdset.revents = 0;
 
+    // We are finised with the arguments and are ready to go.  Sync with the
+    // parent thread and start serving operations on the inferior.
+    sem_post(&args->m_semaphore);
+
     for (;;)
     {
         if ((status = poll(&fdset, 1, -1)) < 0)

Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=123803&r1=123802&r2=123803&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Tue Jan 18 19:37:06 2011
@@ -197,7 +197,7 @@
     EnableIPC();
 
     static void
-    ServeOperation(ProcessMonitor *monitor);
+    ServeOperation(LaunchArgs *args);
 
     static bool
     DupDescriptor(const char *path, int fd, int flags);





More information about the lldb-commits mailing list