[Lldb-commits] [lldb] r161533 - in /lldb/trunk: include/lldb/Core/ConnectionFileDescriptor.h source/Core/ConnectionFileDescriptor.cpp
Greg Clayton
gclayton at apple.com
Wed Aug 8 15:27:52 PDT 2012
Author: gclayton
Date: Wed Aug 8 17:27:52 2012
New Revision: 161533
URL: http://llvm.org/viewvc/llvm-project?rev=161533&view=rev
Log:
Fixed the delay that was happening when quitting lldb from the command line. We weren't initializing the command pipes when constructing a ConnectionFileDescriptor with a file descriptor.
Modified:
lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
Modified: lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h?rev=161533&r1=161532&r2=161533&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h (original)
+++ lldb/trunk/include/lldb/Core/ConnectionFileDescriptor.h Wed Aug 8 17:27:52 2012
@@ -72,10 +72,10 @@
protected:
void
- InitializeCommandFileDescriptor ();
+ OpenCommandPipe ();
void
- CloseCommandFileDescriptor ();
+ CloseCommandPipe ();
lldb::ConnectionStatus
BytesAvailable (uint32_t timeout_usec, Error *error_ptr);
@@ -110,13 +110,13 @@
FDType m_fd_send_type;
FDType m_fd_recv_type;
SocketAddress m_udp_send_sockaddr;
- bool m_should_close_fd; // True if this class should close the file descriptor when it goes away.
+ bool m_should_close_fd; // True if this class should close the file descriptor when it goes away.
uint32_t m_socket_timeout_usec;
- int m_command_fd_send; // A pipe that we select on the reading end of along with
- int m_command_fd_receive; // m_fd_recv so we can force ourselves out of the select.
+ int m_pipe_read; // A pipe that we select on the reading end of along with
+ int m_pipe_write; // m_fd_recv so we can force ourselves out of the select.
Mutex m_mutex;
- bool m_shutting_down; // This marks that we are shutting down so if we get woken up from BytesAvailable
- // to disconnect, we won't try to read again.
+ bool m_shutting_down; // This marks that we are shutting down so if we get woken up from BytesAvailable
+ // to disconnect, we won't try to read again.
static in_port_t
GetSocketPort (int fd);
Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=161533&r1=161532&r2=161533&view=diff
==============================================================================
--- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original)
+++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Wed Aug 8 17:27:52 2012
@@ -75,8 +75,8 @@
m_udp_send_sockaddr (),
m_should_close_fd (false),
m_socket_timeout_usec(0),
- m_command_fd_send(-1),
- m_command_fd_receive(-1),
+ m_pipe_read(-1),
+ m_pipe_write(-1),
m_mutex (Mutex::eMutexTypeRecursive),
m_shutting_down (false)
{
@@ -94,14 +94,15 @@
m_udp_send_sockaddr (),
m_should_close_fd (owns_fd),
m_socket_timeout_usec(0),
- m_command_fd_send(-1),
- m_command_fd_receive(-1),
+ m_pipe_read(-1),
+ m_pipe_write(-1),
m_mutex (Mutex::eMutexTypeRecursive),
m_shutting_down (false)
{
LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
if (log)
log->Printf ("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", this, fd, owns_fd);
+ OpenCommandPipe ();
}
@@ -111,13 +112,13 @@
if (log)
log->Printf ("%p ConnectionFileDescriptor::~ConnectionFileDescriptor ()", this);
Disconnect (NULL);
- CloseCommandFileDescriptor ();
+ CloseCommandPipe ();
}
void
-ConnectionFileDescriptor::InitializeCommandFileDescriptor ()
+ConnectionFileDescriptor::OpenCommandPipe ()
{
- CloseCommandFileDescriptor();
+ CloseCommandPipe();
LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
// Make the command file descriptor here:
@@ -132,24 +133,24 @@
}
else
{
- m_command_fd_receive = filedes[0];
- m_command_fd_send = filedes[1];
+ m_pipe_read = filedes[0];
+ m_pipe_write = filedes[1];
}
}
void
-ConnectionFileDescriptor::CloseCommandFileDescriptor ()
+ConnectionFileDescriptor::CloseCommandPipe ()
{
- if (m_command_fd_receive != -1)
+ if (m_pipe_read != -1)
{
- close (m_command_fd_receive);
- m_command_fd_receive = -1;
+ close (m_pipe_read);
+ m_pipe_read = -1;
}
- if (m_command_fd_send != -1)
+ if (m_pipe_write != -1)
{
- close (m_command_fd_send);
- m_command_fd_send = -1;
+ close (m_pipe_write);
+ m_pipe_write = -1;
}
}
@@ -167,7 +168,7 @@
if (log)
log->Printf ("%p ConnectionFileDescriptor::Connect (url = '%s')", this, s);
- InitializeCommandFileDescriptor();
+ OpenCommandPipe();
if (s && s[0])
{
@@ -309,11 +310,11 @@
if (!got_lock)
{
- if (m_command_fd_send != -1 )
+ if (m_pipe_write != -1 )
{
- write (m_command_fd_send, "q", 1);
- close (m_command_fd_send);
- m_command_fd_send = -1;
+ write (m_pipe_write, "q", 1);
+ close (m_pipe_write);
+ m_pipe_write = -1;
}
locker.Lock (m_mutex);
}
@@ -613,14 +614,14 @@
tv_ptr = &tv;
}
- while (IsConnected())
+ while (m_fd_recv >= 0)
{
fd_set read_fds;
FD_ZERO (&read_fds);
FD_SET (m_fd_recv, &read_fds);
- if (m_command_fd_receive != -1)
- FD_SET (m_command_fd_receive, &read_fds);
- int nfds = (m_fd_recv > m_command_fd_receive ? m_fd_recv : m_command_fd_receive) + 1;
+ if (m_pipe_read != -1)
+ FD_SET (m_pipe_read, &read_fds);
+ int nfds = std::max<int>(m_fd_recv, m_pipe_read) + 1;
Error error;
@@ -668,7 +669,7 @@
}
else if (num_set_fds > 0)
{
- if (m_command_fd_receive != -1 && FD_ISSET(m_command_fd_receive, &read_fds))
+ if (m_pipe_read != -1 && FD_ISSET(m_pipe_read, &read_fds))
{
// We got a command to exit. Read the data from that pipe:
char buffer[16];
@@ -676,7 +677,7 @@
do
{
- bytes_read = ::read (m_command_fd_receive, buffer, sizeof(buffer));
+ bytes_read = ::read (m_pipe_read, buffer, sizeof(buffer));
} while (bytes_read < 0 && errno == EINTR);
assert (bytes_read == 1 && buffer[0] == 'q');
More information about the lldb-commits
mailing list