1 //===-- ConnectionFileDescriptorPosix.cpp -----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #if defined(__APPLE__)
11 // Enable this special support for Apple builds where we can have unlimited
12 // select bounds. We tried switching to poll() and kqueue and we were panicing
13 // the kernel, so we have to stick with select for now.
14 #define _DARWIN_UNLIMITED_SELECT
17 #include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
18 #include "lldb/Host/Config.h"
19 #include "lldb/Host/IOObject.h"
20 #include "lldb/Host/SocketAddress.h"
21 #include "lldb/Host/Socket.h"
22 #include "lldb/Host/StringConvert.h"
29 #include <sys/types.h>
31 #ifndef LLDB_DISABLE_POSIX
36 // Other libraries and framework includes
37 #include "llvm/Support/ErrorHandling.h"
38 #if defined(__APPLE__)
39 #include "llvm/ADT/SmallVector.h"
42 #include "lldb/Core/Communication.h"
43 #include "lldb/Core/Log.h"
44 #include "lldb/Core/StreamString.h"
45 #include "lldb/Core/Timer.h"
46 #include "lldb/Host/Host.h"
47 #include "lldb/Host/Socket.h"
48 #include "lldb/Interpreter/Args.h"
51 using namespace lldb_private;
53 ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
56 , m_mutex(Mutex::eMutexTypeRecursive)
57 , m_shutting_down(false)
58 , m_waiting_for_accept(false)
59 , m_child_processes_inherit(child_processes_inherit)
61 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
63 log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor ()", static_cast<void *>(this));
66 ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
69 , m_mutex(Mutex::eMutexTypeRecursive)
70 , m_shutting_down(false)
71 , m_waiting_for_accept(false)
72 , m_child_processes_inherit(false)
74 m_write_sp.reset(new File(fd, owns_fd));
75 m_read_sp.reset(new File(fd, false));
77 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
79 log->Printf("%p ConnectionFileDescriptor::ConnectionFileDescriptor (fd = %i, owns_fd = %i)", static_cast<void *>(this), fd,
84 ConnectionFileDescriptor::ConnectionFileDescriptor(Socket* socket)
87 , m_mutex(Mutex::eMutexTypeRecursive)
88 , m_shutting_down(false)
89 , m_waiting_for_accept(false)
90 , m_child_processes_inherit(false)
92 InitializeSocket(socket);
95 ConnectionFileDescriptor::~ConnectionFileDescriptor()
97 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION | LIBLLDB_LOG_OBJECT));
99 log->Printf("%p ConnectionFileDescriptor::~ConnectionFileDescriptor ()", static_cast<void *>(this));
105 ConnectionFileDescriptor::OpenCommandPipe()
109 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
110 // Make the command file descriptor here:
111 Error result = m_pipe.CreateNew(m_child_processes_inherit);
112 if (!result.Success())
115 log->Printf("%p ConnectionFileDescriptor::OpenCommandPipe () - could not make pipe: %s", static_cast<void *>(this),
121 log->Printf("%p ConnectionFileDescriptor::OpenCommandPipe() - success readfd=%d writefd=%d", static_cast<void *>(this),
122 m_pipe.GetReadFileDescriptor(), m_pipe.GetWriteFileDescriptor());
127 ConnectionFileDescriptor::CloseCommandPipe()
129 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
131 log->Printf("%p ConnectionFileDescriptor::CloseCommandPipe()", static_cast<void *>(this));
137 ConnectionFileDescriptor::IsConnected() const
139 return (m_read_sp && m_read_sp->IsValid()) || (m_write_sp && m_write_sp->IsValid());
143 ConnectionFileDescriptor::Connect(const char *s, Error *error_ptr)
145 Mutex::Locker locker(m_mutex);
146 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
148 log->Printf("%p ConnectionFileDescriptor::Connect (url = '%s')", static_cast<void *>(this), s);
154 if (strstr(s, "listen://") == s)
156 // listen://HOST:PORT
157 return SocketListenAndAccept(s + strlen("listen://"), error_ptr);
159 else if (strstr(s, "accept://") == s)
162 return NamedSocketAccept(s + strlen("accept://"), error_ptr);
164 else if (strstr(s, "unix-accept://") == s)
167 return NamedSocketAccept(s + strlen("unix-accept://"), error_ptr);
169 else if (strstr(s, "adb://") == s)
172 sscanf(s, "adb://%*[^:]:%d", &port);
173 char host_and_port[sizeof("localhost:65535")];
174 snprintf(host_and_port, sizeof(host_and_port), "localhost:%d", port);
175 return ConnectTCP(host_and_port, error_ptr);
177 else if (strstr(s, "connect://") == s)
179 return ConnectTCP(s + strlen("connect://"), error_ptr);
181 else if (strstr(s, "tcp-connect://") == s)
183 return ConnectTCP(s + strlen("tcp-connect://"), error_ptr);
185 else if (strstr(s, "udp://") == s)
187 return ConnectUDP(s + strlen("udp://"), error_ptr);
189 #ifndef LLDB_DISABLE_POSIX
190 else if (strstr(s, "fd://") == s)
192 // Just passing a native file descriptor within this current process
193 // that is already opened (possibly from a service or other source).
194 s += strlen("fd://");
195 bool success = false;
196 int fd = StringConvert::ToSInt32(s, -1, 0, &success);
200 // We have what looks to be a valid file descriptor, but we
201 // should make sure it is. We currently are doing this by trying to
202 // get the flags from the file descriptor and making sure it
205 int flags = ::fcntl(fd, F_GETFL, 0);
206 if (flags == -1 || errno == EBADF)
209 error_ptr->SetErrorStringWithFormat("stale file descriptor: %s", s);
212 return eConnectionStatusError;
216 // Don't take ownership of a file descriptor that gets passed
217 // to us since someone else opened the file descriptor and
219 // TODO: Since are using a URL to open connection we should
220 // eventually parse options using the web standard where we
221 // have "fd://123?opt1=value;opt2=value" and we can have an
222 // option be "owns=1" or "owns=0" or something like this to
223 // allow us to specify this. For now, we assume we must
224 // assume we don't own it.
226 std::unique_ptr<Socket> tcp_socket;
227 tcp_socket.reset(new Socket(fd, Socket::ProtocolTcp, false));
228 // Try and get a socket option from this file descriptor to
229 // see if this is a socket and set m_is_socket accordingly.
231 bool is_socket = !!tcp_socket->GetOption(SOL_SOCKET, SO_REUSEADDR, resuse);
234 m_read_sp = std::move(tcp_socket);
235 m_write_sp = m_read_sp;
239 m_read_sp.reset(new File(fd, false));
240 m_write_sp.reset(new File(fd, false));
243 return eConnectionStatusSuccess;
248 error_ptr->SetErrorStringWithFormat("invalid file descriptor: \"fd://%s\"", s);
251 return eConnectionStatusError;
253 else if (strstr(s, "file://") == s)
256 const char *path = s + strlen("file://");
260 fd = ::open(path, O_RDWR);
261 } while (fd == -1 && errno == EINTR);
266 error_ptr->SetErrorToErrno();
267 return eConnectionStatusError;
272 // Set up serial terminal emulation
273 struct termios options;
274 ::tcgetattr(fd, &options);
276 // Set port speed to maximum
277 ::cfsetospeed(&options, B115200);
278 ::cfsetispeed(&options, B115200);
280 // Raw input, disable echo and signals
281 options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
283 // Make sure only one character is needed to return from a read
284 options.c_cc[VMIN] = 1;
285 options.c_cc[VTIME] = 0;
287 ::tcsetattr(fd, TCSANOW, &options);
290 int flags = ::fcntl(fd, F_GETFL, 0);
293 if ((flags & O_NONBLOCK) == 0)
296 ::fcntl(fd, F_SETFL, flags);
299 m_read_sp.reset(new File(fd, true));
300 m_write_sp.reset(new File(fd, false));
301 return eConnectionStatusSuccess;
305 error_ptr->SetErrorStringWithFormat("unsupported connection URL: '%s'", s);
306 return eConnectionStatusError;
309 error_ptr->SetErrorString("invalid connect arguments");
310 return eConnectionStatusError;
314 ConnectionFileDescriptor::InterruptRead()
316 size_t bytes_written = 0;
317 Error result = m_pipe.Write("i", 1, bytes_written);
318 return result.Success();
322 ConnectionFileDescriptor::Disconnect(Error *error_ptr)
324 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
326 log->Printf("%p ConnectionFileDescriptor::Disconnect ()", static_cast<void *>(this));
328 ConnectionStatus status = eConnectionStatusSuccess;
333 log->Printf("%p ConnectionFileDescriptor::Disconnect(): Nothing to disconnect", static_cast<void *>(this));
334 return eConnectionStatusSuccess;
337 if (m_read_sp && m_read_sp->IsValid() && m_read_sp->GetFdType() == IOObject::eFDTypeSocket)
338 static_cast<Socket &>(*m_read_sp).PreDisconnect();
340 // Try to get the ConnectionFileDescriptor's mutex. If we fail, that is quite likely
341 // because somebody is doing a blocking read on our file descriptor. If that's the case,
342 // then send the "q" char to the command file channel so the read will wake up and the connection
343 // will then know to shut down.
345 m_shutting_down = true;
347 Mutex::Locker locker;
348 bool got_lock = locker.TryLock(m_mutex);
352 if (m_pipe.CanWrite())
354 size_t bytes_written = 0;
355 Error result = m_pipe.Write("q", 1, bytes_written);
357 log->Printf("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, sent 'q' to %d, error = '%s'.",
358 static_cast<void *>(this), m_pipe.GetWriteFileDescriptor(), result.AsCString());
362 log->Printf("%p ConnectionFileDescriptor::Disconnect(): Couldn't get the lock, but no command pipe is available.",
363 static_cast<void *>(this));
365 locker.Lock(m_mutex);
368 Error error = m_read_sp->Close();
369 Error error2 = m_write_sp->Close();
370 if (error.Fail() || error2.Fail())
371 status = eConnectionStatusError;
373 *error_ptr = error.Fail() ? error : error2;
375 // Close any pipes we were using for async interrupts
379 m_shutting_down = false;
384 ConnectionFileDescriptor::Read(void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status, Error *error_ptr)
386 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
388 Mutex::Locker locker;
389 bool got_lock = locker.TryLock(m_mutex);
393 log->Printf("%p ConnectionFileDescriptor::Read () failed to get the connection lock.", static_cast<void *>(this));
395 error_ptr->SetErrorString("failed to get the connection lock for read.");
397 status = eConnectionStatusTimedOut;
403 status = eConnectionStatusError;
407 status = BytesAvailable(timeout_usec, error_ptr);
408 if (status != eConnectionStatusSuccess)
412 size_t bytes_read = dst_len;
413 error = m_read_sp->Read(dst, bytes_read);
417 log->Printf("%p ConnectionFileDescriptor::Read() fd = %" PRIu64 ", dst = %p, dst_len = %" PRIu64 ") => %" PRIu64 ", error = %s",
418 static_cast<void *>(this), static_cast<uint64_t>(m_read_sp->GetWaitableHandle()), static_cast<void *>(dst),
419 static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read), error.AsCString());
424 error.Clear(); // End-of-file. Do not automatically close; pass along for the end-of-file handlers.
425 status = eConnectionStatusEndOfFile;
433 uint32_t error_value = error.GetError();
436 case EAGAIN: // The file was marked for non-blocking I/O, and no data were ready to be read.
437 if (m_read_sp->GetFdType() == IOObject::eFDTypeSocket)
438 status = eConnectionStatusTimedOut;
440 status = eConnectionStatusSuccess;
443 case EFAULT: // Buf points outside the allocated address space.
444 case EINTR: // A read from a slow device was interrupted before any data arrived by the delivery of a signal.
445 case EINVAL: // The pointer associated with fildes was negative.
446 case EIO: // An I/O error occurred while reading from the file system.
447 // The process group is orphaned.
448 // The file is a regular file, nbyte is greater than 0,
449 // the starting position is before the end-of-file, and
450 // the starting position is greater than or equal to the
451 // offset maximum established for the open file
452 // descriptor associated with fildes.
453 case EISDIR: // An attempt is made to read a directory.
454 case ENOBUFS: // An attempt to allocate a memory buffer fails.
455 case ENOMEM: // Insufficient memory is available.
456 status = eConnectionStatusError;
457 break; // Break to close....
459 case ENOENT: // no such file or directory
460 case EBADF: // fildes is not a valid file or socket descriptor open for reading.
461 case ENXIO: // An action is requested of a device that does not exist..
462 // A requested action cannot be performed by the device.
463 case ECONNRESET: // The connection is closed by the peer during a read attempt on a socket.
464 case ENOTCONN: // A read is attempted on an unconnected socket.
465 status = eConnectionStatusLostConnection;
466 break; // Break to close....
468 case ETIMEDOUT: // A transmission timeout occurs during a read attempt on a socket.
469 status = eConnectionStatusTimedOut;
474 log->Printf("%p ConnectionFileDescriptor::Read (), unexpected error: %s", static_cast<void *>(this),
475 strerror(error_value));
476 status = eConnectionStatusError;
477 break; // Break to close....
486 ConnectionFileDescriptor::Write(const void *src, size_t src_len, ConnectionStatus &status, Error *error_ptr)
488 Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
490 log->Printf("%p ConnectionFileDescriptor::Write (src = %p, src_len = %" PRIu64 ")", static_cast<void *>(this),
491 static_cast<const void *>(src), static_cast<uint64_t>(src_len));
496 error_ptr->SetErrorString("not connected");
497 status = eConnectionStatusNoConnection;
503 size_t bytes_sent = src_len;
504 error = m_write_sp->Write(src, bytes_sent);
508 log->Printf("%p ConnectionFileDescriptor::Write(fd = %" PRIu64 ", src = %p, src_len = %" PRIu64 ") => %" PRIu64 " (error = %s)",
509 static_cast<void *>(this), static_cast<uint64_t>(m_write_sp->GetWaitableHandle()), static_cast<const void *>(src),
510 static_cast<uint64_t>(src_len), static_cast<uint64_t>(bytes_sent), error.AsCString());
518 switch (error.GetError())
522 status = eConnectionStatusSuccess;
525 case ECONNRESET: // The connection is closed by the peer during a read attempt on a socket.
526 case ENOTCONN: // A read is attempted on an unconnected socket.
527 status = eConnectionStatusLostConnection;
528 break; // Break to close....
531 status = eConnectionStatusError;
532 break; // Break to close....
538 status = eConnectionStatusSuccess;
543 ConnectionFileDescriptor::GetURI()
548 // This ConnectionFileDescriptor::BytesAvailable() uses select().
551 // - select is consistent across most unix platforms
552 // - The Apple specific version allows for unlimited fds in the fd_sets by
553 // setting the _DARWIN_UNLIMITED_SELECT define prior to including the
554 // required header files.
556 // - on non-Apple platforms, only supports file descriptors up to FD_SETSIZE.
557 // This implementation will assert if it runs into that hard limit to let
558 // users know that another ConnectionFileDescriptor::BytesAvailable() should
559 // be used or a new version of ConnectionFileDescriptor::BytesAvailable()
560 // should be written for the system that is running into the limitations.
562 #if defined(__APPLE__)
563 #define FD_SET_DATA(fds) fds.data()
565 #define FD_SET_DATA(fds) &fds
569 ConnectionFileDescriptor::BytesAvailable(uint32_t timeout_usec, Error *error_ptr)
571 // Don't need to take the mutex here separately since we are only called from Read. If we
572 // ever get used more generally we will need to lock here as well.
574 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_CONNECTION));
576 log->Printf("%p ConnectionFileDescriptor::BytesAvailable (timeout_usec = %u)", static_cast<void *>(this), timeout_usec);
578 struct timeval *tv_ptr;
580 if (timeout_usec == UINT32_MAX)
587 TimeValue time_value;
588 time_value.OffsetWithMicroSeconds(timeout_usec);
589 tv.tv_sec = time_value.seconds();
590 tv.tv_usec = time_value.microseconds();
594 // Make a copy of the file descriptors to make sure we don't
595 // have another thread change these values out from under us
596 // and cause problems in the loop below where like in FS_SET()
597 const IOObject::WaitableHandle handle = m_read_sp->GetWaitableHandle();
598 const int pipe_fd = m_pipe.GetReadFileDescriptor();
600 if (handle != IOObject::kInvalidHandleValue)
602 #if defined(_MSC_VER)
603 // select() won't accept pipes on Windows. The entire Windows codepath needs to be
604 // converted over to using WaitForMultipleObjects and event HANDLEs, but for now at least
605 // this will allow ::select() to not return an error.
606 const bool have_pipe_fd = false;
608 const bool have_pipe_fd = pipe_fd >= 0;
609 #if !defined(__APPLE__)
610 assert(handle < FD_SETSIZE);
612 assert(pipe_fd < FD_SETSIZE);
615 while (handle == m_read_sp->GetWaitableHandle())
617 const int nfds = std::max<int>(handle, pipe_fd) + 1;
618 #if defined(__APPLE__)
619 llvm::SmallVector<fd_set, 1> read_fds;
620 read_fds.resize((nfds / FD_SETSIZE) + 1);
621 for (size_t i = 0; i < read_fds.size(); ++i)
622 FD_ZERO(&read_fds[i]);
623 // FD_SET doesn't bounds check, it just happily walks off the end
624 // but we have taken care of making the extra storage with our
625 // SmallVector of fd_set objects
630 FD_SET(handle, FD_SET_DATA(read_fds));
632 FD_SET(pipe_fd, FD_SET_DATA(read_fds));
640 "%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p)...",
641 static_cast<void *>(this), nfds, handle, pipe_fd, static_cast<void *>(tv_ptr));
643 log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p)...",
644 static_cast<void *>(this), nfds, handle, static_cast<void *>(tv_ptr));
647 const int num_set_fds = ::select(nfds, FD_SET_DATA(read_fds), NULL, NULL, tv_ptr);
649 error.SetErrorToErrno();
656 log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i, %i}, NULL, NULL, timeout=%p) "
658 static_cast<void *>(this), nfds, handle, pipe_fd, static_cast<void *>(tv_ptr), num_set_fds,
661 log->Printf("%p ConnectionFileDescriptor::BytesAvailable() ::select (nfds=%i, fds={%i}, NULL, NULL, timeout=%p) => "
663 static_cast<void *>(this), nfds, handle, static_cast<void *>(tv_ptr), num_set_fds, error.AsCString());
671 switch (error.GetError())
673 case EBADF: // One of the descriptor sets specified an invalid descriptor.
674 return eConnectionStatusLostConnection;
676 case EINVAL: // The specified time limit is invalid. One of its components is negative or too large.
677 default: // Other unknown error
678 return eConnectionStatusError;
680 case EAGAIN: // The kernel was (perhaps temporarily) unable to
681 // allocate the requested number of file descriptors,
682 // or we have non-blocking IO
683 case EINTR: // A signal was delivered before the time limit
684 // expired and before any of the selected events
686 break; // Lets keep reading to until we timeout
689 else if (num_set_fds == 0)
691 return eConnectionStatusTimedOut;
693 else if (num_set_fds > 0)
695 if (FD_ISSET(handle, FD_SET_DATA(read_fds)))
696 return eConnectionStatusSuccess;
697 if (have_pipe_fd && FD_ISSET(pipe_fd, FD_SET_DATA(read_fds)))
699 // There is an interrupt or exit command in the command pipe
700 // Read the data from that pipe:
707 bytes_read = ::read(pipe_fd, buffer, sizeof(buffer));
708 } while (bytes_read < 0 && errno == EINTR);
714 log->Printf("%p ConnectionFileDescriptor::BytesAvailable() "
715 "got data: %c from the command channel.",
716 static_cast<void *>(this), buffer[0]);
717 return eConnectionStatusEndOfFile;
719 // Interrupt the current read
720 return eConnectionStatusInterrupted;
728 error_ptr->SetErrorString("not connected");
729 return eConnectionStatusLostConnection;
733 ConnectionFileDescriptor::NamedSocketAccept(const char *socket_name, Error *error_ptr)
735 Socket *socket = nullptr;
736 Error error = Socket::UnixDomainAccept(socket_name, m_child_processes_inherit, socket);
739 m_write_sp.reset(socket);
740 m_read_sp = m_write_sp;
743 return eConnectionStatusError;
745 m_uri.assign(socket_name);
746 return eConnectionStatusSuccess;
750 ConnectionFileDescriptor::NamedSocketConnect(const char *socket_name, Error *error_ptr)
752 Socket *socket = nullptr;
753 Error error = Socket::UnixDomainConnect(socket_name, m_child_processes_inherit, socket);
756 m_write_sp.reset(socket);
757 m_read_sp = m_write_sp;
760 return eConnectionStatusError;
762 m_uri.assign(socket_name);
763 return eConnectionStatusSuccess;
767 ConnectionFileDescriptor::SocketListenAndAccept(const char *s, Error *error_ptr)
769 m_port_predicate.SetValue(0, eBroadcastNever);
771 Socket *socket = nullptr;
772 m_waiting_for_accept = true;
773 Error error = Socket::TcpListen(s, m_child_processes_inherit, socket, &m_port_predicate);
777 return eConnectionStatusError;
779 std::unique_ptr<Socket> listening_socket_up;
781 listening_socket_up.reset(socket);
783 error = listening_socket_up->BlockingAccept(s, m_child_processes_inherit, socket);
784 listening_socket_up.reset();
788 return eConnectionStatusError;
790 InitializeSocket(socket);
791 return eConnectionStatusSuccess;
795 ConnectionFileDescriptor::ConnectTCP(const char *s, Error *error_ptr)
797 Socket *socket = nullptr;
798 Error error = Socket::TcpConnect(s, m_child_processes_inherit, socket);
801 m_write_sp.reset(socket);
802 m_read_sp = m_write_sp;
805 return eConnectionStatusError;
808 return eConnectionStatusSuccess;
812 ConnectionFileDescriptor::ConnectUDP(const char *s, Error *error_ptr)
814 Socket *send_socket = nullptr;
815 Socket *recv_socket = nullptr;
816 Error error = Socket::UdpConnect(s, m_child_processes_inherit, send_socket, recv_socket);
819 m_write_sp.reset(send_socket);
820 m_read_sp.reset(recv_socket);
823 return eConnectionStatusError;
826 return eConnectionStatusSuccess;
830 ConnectionFileDescriptor::GetListeningPort(uint32_t timeout_sec)
832 uint16_t bound_port = 0;
833 if (timeout_sec == UINT32_MAX)
834 m_port_predicate.WaitForValueNotEqualTo(0, bound_port);
837 TimeValue timeout = TimeValue::Now();
838 timeout.OffsetWithSeconds(timeout_sec);
839 m_port_predicate.WaitForValueNotEqualTo(0, bound_port, &timeout);
845 ConnectionFileDescriptor::GetChildProcessesInherit() const
847 return m_child_processes_inherit;
851 ConnectionFileDescriptor::SetChildProcessesInherit(bool child_processes_inherit)
853 m_child_processes_inherit = child_processes_inherit;
857 ConnectionFileDescriptor::InitializeSocket(Socket* socket)
859 m_write_sp.reset(socket);
860 m_read_sp = m_write_sp;
862 strm.Printf("connect://%s:%u",socket->GetRemoteIPAddress().c_str(), socket->GetRemotePortNumber());
863 m_uri.swap(strm.GetString());