sal/osl/unx/socket.cxx | 26 +++++++++++++------------- sal/osl/unx/sockimpl.hxx | 6 +++++- 2 files changed, 18 insertions(+), 14 deletions(-)
New commits: commit 309aa845a8e413519d634680aff112a3567e2e61 Author: Damjan Jovanovic <dam...@apache.org> Date: Tue Oct 13 18:22:30 2015 +0000 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 diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx index d1a937a..63b079f 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 993c850..772a583 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits