From 393132ca73f2deead95c000ea7381727a25731e2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 8 Jan 2015 12:21:16 +0100 Subject: [API CHANGE] Remove osl_send/receiveResourcePipe ...they had not been documented in osl/process.h and the sal/osl/unx implementation had been stubbed out since 7b37265b8e1afe480a6bbd271bf48fa1cbb44d55 "sal: remove unx implementation of osl_sendResourcePipe/osl_receiveResourcePipe" in 2012 Change-Id: Ia3ae853d95b6f3b2d2743f06755ef8f6246501d8 --- sal/osl/all/compat.cxx | 11 +++++ sal/osl/unx/process.cxx | 17 ------- sal/osl/w32/process.cxx | 128 ------------------------------------------------ 3 files changed, 11 insertions(+), 145 deletions(-) (limited to 'sal/osl') diff --git a/sal/osl/all/compat.cxx b/sal/osl/all/compat.cxx index 3f072a11023d..592ac90ae70c 100644 --- a/sal/osl/all/compat.cxx +++ b/sal/osl/all/compat.cxx @@ -12,6 +12,8 @@ #include #include "osl/module.h" +#include "osl/pipe.h" +#include "osl/socket.h" #include "osl/time.h" #include "sal/types.h" @@ -49,6 +51,10 @@ SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_getEthernetAddress(sal_uInt8 *) { for (;;) { std::abort(); } // avoid "must return a value" warnings } +SAL_DLLPUBLIC_EXPORT oslSocket SAL_CALL osl_receiveResourcePipe(oslPipe) { + for (;;) { std::abort(); } // avoid "must return a value" warnings +} + SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_releaseSemaphore(void *) { for (;;) { std::abort(); } // avoid "must return a value" warnings } @@ -59,6 +65,11 @@ SAL_DLLPUBLIC_EXPORT sal_Int32 SAL_CALL osl_reportError( for (;;) { std::abort(); } // avoid "must return a value" warnings } +SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL osl_sendResourcePipe(oslPipe, oslSocket) +{ + for (;;) { std::abort(); } // avoid "must return a value" warnings +} + namespace { typedef void (SAL_CALL * pfunc_osl_printDebugMessage)(char const *); } diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx index 8030664d10e1..ea60b2b27049 100644 --- a/sal/osl/unx/process.cxx +++ b/sal/osl/unx/process.cxx @@ -108,23 +108,6 @@ oslProcessError SAL_CALL osl_psz_executeProcess(sal_Char *pszImageName, oslFileHandle *pOutputRead, oslFileHandle *pErrorRead ); -/****************************************************************************** - * - * New io resource transfer functions - * - *****************************************************************************/ - -sal_Bool osl_sendResourcePipe(oslPipe /*pPipe*/, oslSocket /*pSocket*/) -{ - return osl_Process_E_InvalidError; -} - -oslSocket osl_receiveResourcePipe(oslPipe /*pPipe*/) -{ - oslSocket pSocket = 0; - return pSocket; -} - /****************************************************************************** * * Functions for starting a process diff --git a/sal/osl/w32/process.cxx b/sal/osl/w32/process.cxx index 087ee2e20c01..23001f9cd4c6 100644 --- a/sal/osl/w32/process.cxx +++ b/sal/osl/w32/process.cxx @@ -506,132 +506,4 @@ oslProcessError SAL_CALL osl_setProcessLocale( rtl_Locale * pLocale ) return osl_Process_E_None; } -/************************************************ - * Portal send/receive interface implementation - ************************************************/ - -static sal_Bool ReadPipe(oslPipe hPipe, - void* pBuffer, - sal_Int32 BytesToRead, - sal_Int32* nBytes) -{ - *nBytes = osl_receivePipe(hPipe, pBuffer, BytesToRead); - OSL_TRACE("tried to receive %d, received %d.\n", - BytesToRead, *nBytes); - return (sal_Bool)((*nBytes >= 0) && (osl_getLastPipeError(hPipe) == osl_Pipe_E_None)); -} - -static sal_Bool WritePipe(oslPipe hPipe, - void* pBuffer, - sal_Int32 BytesToSend, - sal_Int32* nBytes) -{ - *nBytes = osl_sendPipe(hPipe, pBuffer, BytesToSend); - OSL_TRACE("tried to send %d, sent %d\n", - BytesToSend, *nBytes); - return (sal_Bool)((*nBytes == BytesToSend) && (osl_getLastPipeError(hPipe) == osl_Pipe_E_None)); -} - -sal_Bool SAL_CALL osl_sendResourcePipe(oslPipe hPipe, oslSocket pSocket) -{ - sal_Bool bRet = sal_False; - sal_Int32 bytes = 0; - - /* duplicate handle on this other side -> - receive remote process - duplicate handle and send it */ - DWORD remoteProcessID = 0; - HANDLE fd = (HANDLE)pSocket->m_Socket; - oslDescriptorType code = osl_Process_TypeSocket; - - OSL_TRACE("osl_sendResourcePipe: enter..."); - - if (ReadPipe(hPipe, &remoteProcessID, sizeof(remoteProcessID), &bytes)) - { - HANDLE hRemoteProc = OpenProcess(PROCESS_DUP_HANDLE, - FALSE, - remoteProcessID); - - if (hRemoteProc != (HANDLE)NULL) - { - HANDLE newFd; - - if (DuplicateHandle(GetCurrentProcess(), - fd, - hRemoteProc, - &newFd, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - { - if ( - WritePipe(hPipe, &code, sizeof(code), &bytes) && - WritePipe(hPipe, &newFd, sizeof(fd), &bytes) - ) - bRet = sal_True; - } - - CloseHandle(hRemoteProc); - } - } - - if (bRet) - { - sal_Int32 commitCode; - OSL_TRACE("osl_sendResourcePipe: handle sent successfully, verify..."); - - if ( - !ReadPipe(hPipe, &commitCode, sizeof(commitCode), &bytes) || - (commitCode <= 0) - ) - bRet = sal_False; - } - - OSL_TRACE("osl_sendResourcePipe: exit... %d", bRet); - return(bRet); -} - -oslSocket SAL_CALL osl_receiveResourcePipe(oslPipe hPipe) -{ - sal_Bool bRet = sal_False; - sal_Int32 bytes = 0; - sal_Int32 commitCode; - oslSocket pSocket = NULL; - - /* duplicate handle on the other side -> - send my process id receive duplicated handle */ - HANDLE fd = INVALID_HANDLE_VALUE; - DWORD myProcessID = GetCurrentProcessId(); - oslDescriptorType code = osl_Process_TypeNone; - - OSL_TRACE("osl_receiveResourcePipe: enter..."); - - if ( - WritePipe(hPipe, &myProcessID, sizeof(myProcessID), &bytes) && - ReadPipe(hPipe, &code, sizeof(code), &bytes) && - ReadPipe(hPipe, &fd, sizeof(fd), &bytes) - ) - { - if (code == osl_Process_TypeSocket) - { - pSocket = __osl_createSocketImpl((SOCKET)fd); - bRet = sal_True; - } - else - { - OSL_TRACE("osl_receiveResourcePipe: UNKNOWN"); - bRet = sal_False; - } - } - - if (bRet) - commitCode = 1; - else - commitCode = 0; - - WritePipe(hPipe, &commitCode, sizeof(commitCode), &bytes); - - OSL_TRACE("osl_receiveResourcePipe: exit... %d, %p", bRet, pSocket); - - return pSocket; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit