You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by tr...@apache.org on 2020/08/25 03:05:29 UTC

[openoffice] 07/07: Platforms that need CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT for sockets usually need it for pipes too, and even if it isn't necessary it can't hurt.

This is an automated email from the ASF dual-hosted git repository.

truckman pushed a commit to branch AOO418
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit ebd402a9426d626dd60adb831ce481bf05e1ad31
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Sat Feb 6 19:07:51 2016 +0000

    Platforms that need CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT for sockets usually
    need it for pipes too, and even if it isn't necessary it can't hurt.
    
    In particular, on FreeBSD 11-CURRENT it seems pipes no longer wake up
    from accept when closed in other threads, so let's deal with that before
    FreeBSD 11 is released.
    
    Reported by: Matthias Apitz <g u r u   a t   u n i x a r e a   d o t   d e>
    Patch by: me
    Tested by: Matthias Apitz <g u r u   a t   u n i x a r e a   d o t   d e>
    
    
    
    git-svn-id: https://svn.apache.org/repos/asf/openoffice/trunk@1728872 13f79535-47bb-0310-9956-ffa450edef68
---
 main/sal/osl/unx/pipe.c     | 24 ++++++++++++++----------
 main/sal/osl/unx/sockimpl.h |  2 +-
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/main/sal/osl/unx/pipe.c b/main/sal/osl/unx/pipe.c
index 4c10a8a..3ea54e0 100644
--- a/main/sal/osl/unx/pipe.c
+++ b/main/sal/osl/unx/pipe.c
@@ -115,7 +115,7 @@ oslPipe __osl_createPipeImpl()
 	pPipeImpl = (oslPipe)calloc(1, sizeof(struct oslPipeImpl));
 	pPipeImpl->m_nRefCount =1;
 	pPipeImpl->m_bClosed = sal_False;
-#if defined(LINUX)
+#if CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT
 	pPipeImpl->m_bIsInShutdown = sal_False;
 	pPipeImpl->m_bIsAccepting = sal_False;
 #endif
@@ -321,7 +321,7 @@ void SAL_CALL osl_releasePipe( oslPipe pPipe )
 void SAL_CALL osl_closePipe( oslPipe pPipe )
 {
     int nRet;
-#if defined(LINUX)
+#if CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT
     size_t	   len;
 	struct sockaddr_un addr;
     int fd;
@@ -341,10 +341,10 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
     ConnFD = pPipe->m_Socket;
 
 	/*
-	  Thread does not return from accept on linux, so
+	  Thread does not return from accept on some operating systems, so
 	  connect to the accepting pipe
 	 */
-#if defined(LINUX)
+#if CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT
     if ( pPipe->m_bIsAccepting )
     {
         pPipe->m_bIsInShutdown = sal_True;
@@ -356,7 +356,11 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
 
         addr.sun_family = AF_UNIX;
         strncpy(addr.sun_path, pPipe->m_Name, sizeof(addr.sun_path));
-		len = sizeof(addr);
+#if defined(FREEBSD)
+        len = SUN_LEN(&addr);
+#else
+        len = sizeof(addr);
+#endif
 
         nRet = connect( fd, (struct sockaddr *)&addr, len);
 #if OSL_DEBUG_LEVEL > 1
@@ -367,7 +371,7 @@ void SAL_CALL osl_closePipe( oslPipe pPipe )
 #endif /* OSL_DEBUG_LEVEL */
         close(fd);
     }
-#endif /* LINUX */
+#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */
 
 
 	nRet = shutdown(ConnFD, 2);
@@ -408,13 +412,13 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
 
 	OSL_ASSERT(strlen(pPipe->m_Name) > 0);
 
-#if defined(LINUX)
+#if CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT
     pPipe->m_bIsAccepting = sal_True;
 #endif
 
     s = accept(pPipe->m_Socket, NULL, NULL);
 
-#if defined(LINUX)
+#if CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT
     pPipe->m_bIsAccepting = sal_False;
 #endif
 
@@ -424,13 +428,13 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
 		return NULL;
 	}
 
-#if defined(LINUX)
+#if CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT
     if ( pPipe->m_bIsInShutdown  )
     {
         close(s);
         return NULL;
     }
-#endif /* LINUX */
+#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */
     else
 	{
 		/* alloc memory */
diff --git a/main/sal/osl/unx/sockimpl.h b/main/sal/osl/unx/sockimpl.h
index 2cec813..0cc0e10 100644
--- a/main/sal/osl/unx/sockimpl.h
+++ b/main/sal/osl/unx/sockimpl.h
@@ -63,7 +63,7 @@ struct oslPipeImpl {
 	sal_Char m_Name[PATH_MAX + 1];
 	oslInterlockedCount m_nRefCount;
 	sal_Bool m_bClosed;
-#if defined(LINUX)
+#if CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT
     sal_Bool m_bIsAccepting;
     sal_Bool m_bIsInShutdown;
 #endif