Bug 1162524: Fix error handling |UnixSocketWatcher::Connect|, r=kmachulis
authorThomas Zimmermann <tdz@users.sourceforge.net>
Fri, 08 May 2015 09:42:46 +0200
changeset 260163 7f7d734605b1fb598c14bfb39b9a5f3700b2f63a
parent 260162 72aebeb467146e0494d31275f28f3a05d96d14de
child 260164 a099b6c773663a030777571ffa1e7ede5cd6649c
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-esr52@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmachulis
bugs1162524
milestone40.0a1
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;
 }