summaryrefslogtreecommitdiff
path: root/sal/osl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2017-08-28 05:08:41 +1000
committerChris Sherlock <chris.sherlock79@gmail.com>2017-08-28 05:09:04 +1000
commitd96b243c5d363f66e574fe68879e59244c338c22 (patch)
treed62b151da4e1cca4e5efabb52728a31f8f096deb /sal/osl
parent218ea8750827982dc325fb0f0daa6d9f4b2dc044 (diff)
osl: cleanup osl_(acquire|release|close)Socket
Change-Id: Ifc0b88963bcd28e5709accdf892b2cb16b2b55eb
Diffstat (limited to 'sal/osl')
-rw-r--r--sal/osl/unx/socket.cxx42
-rw-r--r--sal/osl/w32/socket.cxx14
2 files changed, 27 insertions, 29 deletions
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 594ecfdaaa81..b3ca2bb83191 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -1184,46 +1184,44 @@ oslSocket SAL_CALL osl_createSocket(
void SAL_CALL osl_acquireSocket(oslSocket pSocket)
{
- osl_atomic_increment( &(pSocket->m_nRefCount ) );
+ osl_atomic_increment(&(pSocket->m_nRefCount));
}
-void SAL_CALL osl_releaseSocket( oslSocket pSocket )
+void SAL_CALL osl_releaseSocket(oslSocket pSocket)
{
- if( pSocket && osl_atomic_decrement( &(pSocket->m_nRefCount) ) == 0 )
+ if (pSocket && osl_atomic_decrement(&(pSocket->m_nRefCount)) == 0)
{
#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT)
- if ( pSocket->m_bIsAccepting )
- {
- SAL_WARN( "sal.osl", "attempt to destroy socket while accepting" );
- return;
- }
+ if (pSocket->m_bIsAccepting)
+ {
+ SAL_WARN( "sal.osl", "attempt to destroy socket while accepting" );
+ return;
+ }
#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */
- osl_closeSocket( pSocket );
- destroySocketImpl( pSocket );
+ osl_closeSocket(pSocket);
+ destroySocketImpl(pSocket);
}
}
void SAL_CALL osl_closeSocket(oslSocket pSocket)
{
- int nRet;
- int nFD;
-
/* socket already invalid */
- if(pSocket==nullptr)
+ if (!pSocket)
return;
pSocket->m_nLastError=0;
- nFD = pSocket->m_Socket;
+ sal_Int32 nFD = pSocket->m_Socket;
if (nFD == OSL_INVALID_SOCKET)
return;
pSocket->m_Socket = OSL_INVALID_SOCKET;
+ sal_Int32 nRet=0;
#if defined(CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT)
pSocket->m_bIsInShutdown = true;
- if ( pSocket->m_bIsAccepting )
+ if (pSocket->m_bIsAccepting)
{
union {
struct sockaddr aSockAddr;
@@ -1232,21 +1230,21 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
socklen_t nSockLen = sizeof(s.aSockAddr);
nRet = getsockname(nFD, &s.aSockAddr, &nSockLen);
- if ( nRet < 0 )
+ if (nRet < 0)
{
int nErrno = errno;
SAL_WARN( "sal.osl", "getsockname call failed with error: (" << nErrno << ") " << strerror(nErrno) );
}
- if ( s.aSockAddr.sa_family == AF_INET )
+ if (s.aSockAddr.sa_family == AF_INET)
{
- if ( s.aSockAddrIn.sin_addr.s_addr == htonl(INADDR_ANY) )
+ if (s.aSockAddrIn.sin_addr.s_addr == htonl(INADDR_ANY))
{
s.aSockAddrIn.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
}
int nConnFD = socket(AF_INET, SOCK_STREAM, 0);
- if ( nConnFD < 0 )
+ if (nConnFD < 0)
{
int nErrno = errno;
SAL_WARN( "sal.osl", "socket call failed with error: (" << nErrno << ") " << strerror(nErrno) );
@@ -1254,7 +1252,7 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
else
{
nRet = connect(nConnFD, &s.aSockAddr, sizeof(s.aSockAddr));
- if ( nRet < 0 )
+ if (nRet < 0)
{
int nErrno = errno;
SAL_WARN( "sal.osl", "connect call failed with error: (" << nErrno << ") " << strerror(nErrno) );
@@ -1267,7 +1265,7 @@ void SAL_CALL osl_closeSocket(oslSocket pSocket)
#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */
nRet=close(nFD);
- if ( nRet != 0 )
+ if (nRet != 0)
{
pSocket->m_nLastError=errno;
int nErrno = errno;
diff --git a/sal/osl/w32/socket.cxx b/sal/osl/w32/socket.cxx
index bd40572ea9fd..6ae42e557515 100644
--- a/sal/osl/w32/socket.cxx
+++ b/sal/osl/w32/socket.cxx
@@ -810,24 +810,24 @@ oslSocket SAL_CALL osl_createSocket(
return pSocket;
}
-void SAL_CALL osl_acquireSocket( oslSocket pSocket )
+void SAL_CALL osl_acquireSocket(oslSocket pSocket)
{
- osl_atomic_increment( &(pSocket->m_nRefCount) );
+ osl_atomic_increment(&(pSocket->m_nRefCount));
}
-void SAL_CALL osl_releaseSocket( oslSocket pSocket )
+void SAL_CALL osl_releaseSocket(oslSocket pSocket)
{
- if( pSocket && 0 == osl_atomic_decrement( &(pSocket->m_nRefCount) ) )
+ if (pSocket && osl_atomic_decrement(&(pSocket->m_nRefCount)) == 0)
{
- osl_closeSocket( pSocket );
- destroySocketImpl( pSocket );
+ osl_closeSocket(pSocket);
+ destroySocketImpl(pSocket);
}
}
void SAL_CALL osl_closeSocket(oslSocket pSocket)
{
/* socket already invalid */
- if(pSocket==nullptr)
+ if (!pSocket)
return;
/* close */