mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1093025: Initialize listen socket only once in |UnixSocketWatcher::Listen|, r=kyle
Sockets in listen mode may only be created and bound once. This patch fixes |unixSocketWatcher::Listen| to respect these contraints. Listening more than once will reuse the settings from the first listen operation.
This commit is contained in:
parent
a4c3938959
commit
602c829f2e
@ -53,13 +53,16 @@ UnixSocketWatcher::Listen(const struct sockaddr* aAddr, socklen_t aAddrLen)
|
||||
MOZ_ASSERT(IsOpen());
|
||||
MOZ_ASSERT(aAddr || !aAddrLen);
|
||||
|
||||
if (bind(GetFd(), aAddr, aAddrLen) < 0) {
|
||||
OnError("bind", errno);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (listen(GetFd(), 1) < 0) {
|
||||
OnError("listen", errno);
|
||||
return NS_ERROR_FAILURE;
|
||||
if (mConnectionStatus == SOCKET_IS_DISCONNECTED) {
|
||||
// We init the socket descriptor when we listen for the first time.
|
||||
if (bind(GetFd(), aAddr, aAddrLen) < 0) {
|
||||
OnError("bind", errno);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (listen(GetFd(), 1) < 0) {
|
||||
OnError("listen", errno);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
mConnectionStatus = SOCKET_IS_LISTENING;
|
||||
OnListening();
|
||||
|
Loading…
Reference in New Issue
Block a user