Kaydet (Commit) 309aa845 authored tarafından Damjan Jovanovic's avatar Damjan Jovanovic Kaydeden (comit) Caolán McNamara

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 4c7bfe32)

Change-Id: I1649f6d1a63ae2daf8e6ff650d8af6ea89a6d449
üst 2c975878
......@@ -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;
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment