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.
This commit is contained in:
Thomas Zimmermann 2015-05-08 09:42:46 +02:00
parent 54a48be6eb
commit 3b73c6d279

View File

@ -29,14 +29,14 @@ UnixSocketWatcher::Connect(const struct sockaddr* aAddr, socklen_t aAddrLen)
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;
}