From 8e1afecf43d703ccadbadcc5b322c8b29baa30f1 Mon Sep 17 00:00:00 2001 From: Lukasz Janyst Date: Thu, 21 Nov 2013 18:00:48 +0100 Subject: [PATCH] [XrdCl] Make the new client use the private semaphore implementation Conflicts: src/XrdCl/XrdClMessageUtils.hh src/XrdCl/XrdClUglyHacks.hh --- src/XrdCl/CMakeLists.txt | 1 + src/XrdCl/XrdClChannel.cc | 13 +++++++------ src/XrdCl/XrdClClassicCopyJob.cc | 4 ++-- src/XrdCl/XrdClMessageUtils.hh | 7 ++++--- src/XrdCl/XrdClRequestSync.hh | 9 +++++---- src/XrdCl/XrdClSyncQueue.hh | 7 ++++--- src/XrdCl/XrdClThirdPartyCopyJob.cc | 10 +++++----- src/XrdCl/XrdClUglyHacks.hh | 13 +++++++++++++ 8 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/XrdCl/CMakeLists.txt b/src/XrdCl/CMakeLists.txt index 8db83c6c80c..b170d428e3b 100644 --- a/src/XrdCl/CMakeLists.txt +++ b/src/XrdCl/CMakeLists.txt @@ -69,6 +69,7 @@ add_library( XrdClJobManager.cc XrdClJobManager.hh XrdClResponseJob.hh XrdClFileTimer.cc XrdClFileTimer.hh + XrdClUglyHacks.hh ${LIBEVENT_POLLER_FILES} ) diff --git a/src/XrdCl/XrdClChannel.cc b/src/XrdCl/XrdClChannel.cc index 592663139a1..6ffeb81517e 100644 --- a/src/XrdCl/XrdClChannel.cc +++ b/src/XrdCl/XrdClChannel.cc @@ -22,6 +22,7 @@ #include "XrdCl/XrdClSocket.hh" #include "XrdCl/XrdClConstants.hh" #include "XrdCl/XrdClLog.hh" +#include "XrdCl/XrdClUglyHacks.hh" #include @@ -37,7 +38,7 @@ namespace // Constructor //------------------------------------------------------------------------ FilterHandler( XrdCl::MessageFilter *filter ): - pSem( new XrdSysSemaphore(0) ), pFilter( filter ), pMsg( 0 ) + pSem( new XrdCl::Semaphore(0) ), pFilter( filter ), pMsg( 0 ) { } @@ -98,7 +99,7 @@ namespace } private: - XrdSysSemaphore *pSem; + XrdCl::Semaphore *pSem; XrdCl::MessageFilter *pFilter; XrdCl::Message *pMsg; XrdCl::Status pStatus; @@ -114,7 +115,7 @@ namespace // Constructor //------------------------------------------------------------------------ StatusHandler( XrdCl::Message *msg ): - pSem( new XrdSysSemaphore(0) ), + pSem( new XrdCl::Semaphore(0) ), pMsg( msg ) {} //------------------------------------------------------------------------ @@ -146,9 +147,9 @@ namespace } private: - XrdSysSemaphore *pSem; - XrdCl::Status pStatus; - XrdCl::Message *pMsg; + XrdCl::Semaphore *pSem; + XrdCl::Status pStatus; + XrdCl::Message *pMsg; }; class TickGeneratorTask: public XrdCl::Task diff --git a/src/XrdCl/XrdClClassicCopyJob.cc b/src/XrdCl/XrdClClassicCopyJob.cc index 1c64c19b4cf..0da6b8c989b 100644 --- a/src/XrdCl/XrdClClassicCopyJob.cc +++ b/src/XrdCl/XrdClClassicCopyJob.cc @@ -620,7 +620,7 @@ namespace class ChunkHandler: public XrdCl::ResponseHandler { public: - ChunkHandler(): sem( new XrdSysSemaphore(0) ) {} + ChunkHandler(): sem( new XrdCl::Semaphore(0) ) {} virtual ~ChunkHandler() { delete sem; } virtual void HandleResponse( XrdCl::XRootDStatus *statusval, XrdCl::AnyObject *response ) @@ -638,7 +638,7 @@ namespace sem->Post(); } - XrdSysSemaphore *sem; + XrdCl::Semaphore *sem; XrdCl::ChunkInfo chunk; XrdCl::XRootDStatus status; }; diff --git a/src/XrdCl/XrdClMessageUtils.hh b/src/XrdCl/XrdClMessageUtils.hh index 09a928a4e77..4e357b7f0aa 100644 --- a/src/XrdCl/XrdClMessageUtils.hh +++ b/src/XrdCl/XrdClMessageUtils.hh @@ -22,7 +22,8 @@ #include "XrdCl/XrdClXRootDResponses.hh" #include "XrdCl/XrdClURL.hh" #include "XrdCl/XrdClMessage.hh" -#include "XrdSys/XrdSysPthread.hh" +#include "XrdCl/XrdClUglyHacks.hh" +#include namespace XrdCl { @@ -38,7 +39,7 @@ namespace XrdCl SyncResponseHandler(): pStatus(0), pResponse(0), - pSem( new XrdSysSemaphore(0) ) {} + pSem( new Semaphore(0) ) {} //------------------------------------------------------------------------ //! Destructor @@ -87,7 +88,7 @@ namespace XrdCl private: XRootDStatus *pStatus; AnyObject *pResponse; - XrdSysSemaphore *pSem; + Semaphore *pSem; }; //---------------------------------------------------------------------------- diff --git a/src/XrdCl/XrdClRequestSync.hh b/src/XrdCl/XrdClRequestSync.hh index 132d6d2071e..740f1b0c4f4 100644 --- a/src/XrdCl/XrdClRequestSync.hh +++ b/src/XrdCl/XrdClRequestSync.hh @@ -20,6 +20,7 @@ #define __XRD_CL_REQUEST_SYNC_HH__ #include "XrdSys/XrdSysPthread.hh" +#include "XrdCl/XrdClUglyHacks.hh" namespace XrdCl { @@ -36,8 +37,8 @@ namespace XrdCl //! @param reqQuota number of requests to be run in parallel //------------------------------------------------------------------------ RequestSync( uint32_t reqTotal, uint32_t reqQuota ): - pQuotaSem( new XrdSysSemaphore( reqQuota ) ), - pTotalSem( new XrdSysSemaphore( 0 ) ), + pQuotaSem( new Semaphore( reqQuota ) ), + pTotalSem( new Semaphore( 0 ) ), pRequestsLeft( reqTotal ), pFailureCounter( 0 ) { @@ -94,8 +95,8 @@ namespace XrdCl private: XrdSysMutex pMutex; - XrdSysSemaphore *pQuotaSem; - XrdSysSemaphore *pTotalSem; + Semaphore *pQuotaSem; + Semaphore *pTotalSem; uint32_t pRequestsLeft; uint32_t pFailureCounter; }; diff --git a/src/XrdCl/XrdClSyncQueue.hh b/src/XrdCl/XrdClSyncQueue.hh index 609b6199b4b..1ac25dba00e 100644 --- a/src/XrdCl/XrdClSyncQueue.hh +++ b/src/XrdCl/XrdClSyncQueue.hh @@ -22,6 +22,7 @@ #include #include "XrdSys/XrdSysPthread.hh" +#include "XrdCl/XrdClUglyHacks.hh" namespace XrdCl { @@ -37,7 +38,7 @@ namespace XrdCl //------------------------------------------------------------------------ SyncQueue() { - pSem = new XrdSysSemaphore(0); + pSem = new Semaphore(0); }; //------------------------------------------------------------------------ @@ -84,13 +85,13 @@ namespace XrdCl while( !pQueue.empty() ) pQueue.pop(); delete pSem; - pSem = new XrdSysSemaphore(0); + pSem = new Semaphore(0); } private: std::queue pQueue; XrdSysMutex pMutex; - XrdSysSemaphore *pSem; + Semaphore *pSem; }; } diff --git a/src/XrdCl/XrdClThirdPartyCopyJob.cc b/src/XrdCl/XrdClThirdPartyCopyJob.cc index d5a264da024..d0735efb7d3 100644 --- a/src/XrdCl/XrdClThirdPartyCopyJob.cc +++ b/src/XrdCl/XrdClThirdPartyCopyJob.cc @@ -24,8 +24,8 @@ #include "XrdCl/XrdClUtils.hh" #include "XrdCl/XrdClMessageUtils.hh" #include "XrdCl/XrdClMonitor.hh" +#include "XrdCl/XrdClUglyHacks.hh" #include "XrdOuc/XrdOucTPC.hh" -#include "XrdSys/XrdSysPthread.hh" #include "XrdSys/XrdSysTimer.hh" #include #include @@ -48,7 +48,7 @@ namespace // Constructor //------------------------------------------------------------------------ TPCStatusHandler(): - pSem( new XrdSysSemaphore(0) ), pStatus(0) + pSem( new XrdCl::Semaphore(0) ), pStatus(0) { } @@ -75,7 +75,7 @@ namespace //------------------------------------------------------------------------ // Get Mutex //------------------------------------------------------------------------ - XrdSysSemaphore *GetSemaphore() + XrdCl::Semaphore *GetSemaphore() { return pSem; } @@ -89,7 +89,7 @@ namespace } private: - XrdSysSemaphore *pSem; + XrdCl::Semaphore *pSem; XrdCl::XRootDStatus *pStatus; }; @@ -227,7 +227,7 @@ namespace XrdCl // Do the copy and follow progress //-------------------------------------------------------------------------- TPCStatusHandler statusHandler; - XrdSysSemaphore *sem = statusHandler.GetSemaphore(); + Semaphore *sem = statusHandler.GetSemaphore(); StatInfo *info = 0; FileSystem fs( pJob->target.GetHostId() ); diff --git a/src/XrdCl/XrdClUglyHacks.hh b/src/XrdCl/XrdClUglyHacks.hh index 5baf57ebcf5..9a830f0e9e4 100644 --- a/src/XrdCl/XrdClUglyHacks.hh +++ b/src/XrdCl/XrdClUglyHacks.hh @@ -25,6 +25,19 @@ #ifndef __XRD_CL_UGLY_HACKS_HH__ #define __XRD_CL_UGLY_HACKS_HH__ +#include "XrdSys/XrdSysLinuxSemaphore.hh" +#include "XrdSys/XrdSysPthread.hh" + +namespace XrdCl +{ +#if defined(__linux__) && defined(HAVE_ATOMICS) + typedef XrdSys::LinuxSemaphore Semaphore; +#else + typedef XrdSysSemaphore Semaphore; +#endif + +} + #if __cplusplus >= 201103L #define XRDCL_SMART_PTR_T std::unique_ptr #else