diff options
author | Damjan Jovanovic <damjan@apache.org> | 2015-10-13 18:22:30 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-10-14 09:17:44 +0100 |
commit | 309aa845a8e413519d634680aff112a3567e2e61 (patch) | |
tree | 3735ade83c5f5ec4d620fcd151b0b1d537ef1ae2 /sal | |
parent | 2c975878ff82eb911e488359f7f3fdb7ec104584 (diff) |
Resolves: #i126586# FreeBSD automation deadlock: osl_closeSocket()...
doesn't wake up thread stuck in accept().
Generalize the "#if defined(LINUX)" workarounds to the *BSDs.
(cherry picked from commit 4c7bfe32168912844a50059b2a901f6434c0f86f)
Change-Id: I1649f6d1a63ae2daf8e6ff650d8af6ea89a6d449
Diffstat (limited to 'sal')
-rw-r--r-- | sal/osl/unx/socket.cxx | 26 | ||||
-rw-r--r-- | sal/osl/unx/sockimpl.hxx | 6 |
2 files changed, 18 insertions, 14 deletions
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx index d1a937a0519c..63b079fd9cc2 100644 --- a/sal/osl/unx/socket.cxx +++ b/sal/osl/unx/socket.cxx @@ -447,7 +447,7 @@ oslSocket __osl_createSocketImpl(int Socket) pSocket->m_nLastError = 0; pSocket->m_nRefCount = 1; -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) pSocket->m_bIsAccepting = false; #endif @@ -1364,13 +1364,13 @@ void SAL_CALL osl_releaseSocket( oslSocket pSocket ) { if( pSocket && 0 == osl_atomic_decrement( &(pSocket->m_nRefCount) ) ) { -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) if ( pSocket->m_bIsAccepting ) { SAL_WARN( "sal.osl", "attempt to destroy socket while accepting" ); return; } -#endif /* LINUX */ +#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */ osl_closeSocket( pSocket ); __osl_destroySocketImpl( pSocket ); } @@ -1393,7 +1393,7 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket) pSocket->m_Socket = OSL_INVALID_SOCKET; -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) pSocket->m_bIsInShutdown = true; if ( pSocket->m_bIsAccepting ) @@ -1437,7 +1437,7 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket) } pSocket->m_bIsAccepting = false; } -#endif /* LINUX */ +#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */ nRet=close(nFD); if ( nRet != 0 ) @@ -1695,9 +1695,9 @@ oslSocket SAL_CALL osl_acceptConnectionOnSocket(oslSocket pSocket, } pSocket->m_nLastError=0; -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) pSocket->m_bIsAccepting = true; -#endif /* LINUX */ +#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */ if( ppAddr && *ppAddr ) { @@ -1718,22 +1718,22 @@ oslSocket SAL_CALL osl_acceptConnectionOnSocket(oslSocket pSocket, int nErrno = errno; SAL_WARN( "sal.osl", "accept connection failed: (" << nErrno << ") " << strerror(nErrno) ); -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) pSocket->m_bIsAccepting = false; -#endif /* LINUX */ +#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */ return 0; } assert(AddrLen == sizeof(struct sockaddr)); -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) if ( pSocket->m_bIsInShutdown ) { close(Connection); SAL_WARN( "sal.osl", "close while accept" ); return 0; } -#endif /* LINUX */ +#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */ if(ppAddr) { @@ -1758,11 +1758,11 @@ oslSocket SAL_CALL osl_acceptConnectionOnSocket(oslSocket pSocket, pConnectionSockImpl->m_Socket = Connection; pConnectionSockImpl->m_nLastError = 0; -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) pConnectionSockImpl->m_bIsAccepting = false; pSocket->m_bIsAccepting = false; -#endif /* LINUX */ +#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */ return pConnectionSockImpl; } diff --git a/sal/osl/unx/sockimpl.hxx b/sal/osl/unx/sockimpl.hxx index 993c8500b998..772a5839fe02 100644 --- a/sal/osl/unx/sockimpl.hxx +++ b/sal/osl/unx/sockimpl.hxx @@ -24,11 +24,15 @@ #include <osl/socket.h> #include <osl/interlck.h> +#if defined(LINUX) || defined(FREEBSD) || defined(NETBSD) +#define CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT 1 +#endif + struct oslSocketImpl { int m_Socket; int m_nLastError; oslInterlockedCount m_nRefCount; -#if defined(LINUX) +#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT) bool m_bIsAccepting; bool m_bIsInShutdown; #endif |