Bug 1162524: Fix error handling |UnixSocketWatcher::Connect|, r=kmachulis
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 08 May 2015 09:42:46 +0200
changeset 274366 7f7d734605b1fb598c14bfb39b9a5f3700b2f63a
parent 274365 72aebeb467146e0494d31275f28f3a05d96d14de
child 274367 a099b6c773663a030777571ffa1e7ede5cd6649c
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmachulis
bugs1162524
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1162524: Fix error handling |UnixSocketWatcher::Connect|, r=kmachulis With this patch, it's not an error if the connection operations stalls on a non-blocking socket; so don't return an error code. The patch also makes |connect| restart if it was aborted by a signal.
ipc/unixfd/UnixSocketWatcher.cpp
--- a/ipc/unixfd/UnixSocketWatcher.cpp
+++ b/ipc/unixfd/UnixSocketWatcher.cpp
@@ -24,24 +24,24 @@ void UnixSocketWatcher::Close()
 
 nsresult
 UnixSocketWatcher::Connect(const struct sockaddr* aAddr, socklen_t aAddrLen)
 {
   MOZ_ASSERT(MessageLoopForIO::current() == GetIOLoop());
   MOZ_ASSERT(IsOpen());
   MOZ_ASSERT(aAddr || !aAddrLen);
 
-  if (connect(GetFd(), aAddr, aAddrLen) < 0) {
+  if (TEMP_FAILURE_RETRY(connect(GetFd(), aAddr, aAddrLen) < 0)) {
     if (errno == EINPROGRESS) {
       mConnectionStatus = SOCKET_IS_CONNECTING;
       // Set up a write watch to receive the connect signal
       AddWatchers(WRITE_WATCHER, false);
-    } else {
-      OnError("connect", errno);
+      return NS_OK;
     }
+    OnError("connect", errno);
     return NS_ERROR_FAILURE;
   }
 
   mConnectionStatus = SOCKET_IS_CONNECTED;
   OnConnected();
 
   return NS_OK;
 }