Skip to content

Commit

Permalink
[XrdCl] Make the new client use the private semaphore implementation
Browse files Browse the repository at this point in the history
Conflicts:
	src/XrdCl/XrdClMessageUtils.hh
	src/XrdCl/XrdClUglyHacks.hh
  • Loading branch information
ljanyst committed Feb 25, 2014
1 parent 75630d9 commit 8e1afec
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 23 deletions.
1 change: 1 addition & 0 deletions src/XrdCl/CMakeLists.txt
Expand Up @@ -69,6 +69,7 @@ add_library(
XrdClJobManager.cc XrdClJobManager.hh
XrdClResponseJob.hh
XrdClFileTimer.cc XrdClFileTimer.hh
XrdClUglyHacks.hh
${LIBEVENT_POLLER_FILES}
)

Expand Down
13 changes: 7 additions & 6 deletions src/XrdCl/XrdClChannel.cc
Expand Up @@ -22,6 +22,7 @@
#include "XrdCl/XrdClSocket.hh"
#include "XrdCl/XrdClConstants.hh"
#include "XrdCl/XrdClLog.hh"
#include "XrdCl/XrdClUglyHacks.hh"

#include <ctime>

Expand All @@ -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 )
{
}

Expand Down Expand Up @@ -98,7 +99,7 @@ namespace
}

private:
XrdSysSemaphore *pSem;
XrdCl::Semaphore *pSem;
XrdCl::MessageFilter *pFilter;
XrdCl::Message *pMsg;
XrdCl::Status pStatus;
Expand All @@ -114,7 +115,7 @@ namespace
// Constructor
//------------------------------------------------------------------------
StatusHandler( XrdCl::Message *msg ):
pSem( new XrdSysSemaphore(0) ),
pSem( new XrdCl::Semaphore(0) ),
pMsg( msg ) {}

//------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/XrdCl/XrdClClassicCopyJob.cc
Expand Up @@ -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 )
Expand All @@ -638,7 +638,7 @@ namespace
sem->Post();
}

XrdSysSemaphore *sem;
XrdCl::Semaphore *sem;
XrdCl::ChunkInfo chunk;
XrdCl::XRootDStatus status;
};
Expand Down
7 changes: 4 additions & 3 deletions src/XrdCl/XrdClMessageUtils.hh
Expand Up @@ -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 <memory>

namespace XrdCl
{
Expand All @@ -38,7 +39,7 @@ namespace XrdCl
SyncResponseHandler():
pStatus(0),
pResponse(0),
pSem( new XrdSysSemaphore(0) ) {}
pSem( new Semaphore(0) ) {}

//------------------------------------------------------------------------
//! Destructor
Expand Down Expand Up @@ -87,7 +88,7 @@ namespace XrdCl
private:
XRootDStatus *pStatus;
AnyObject *pResponse;
XrdSysSemaphore *pSem;
Semaphore *pSem;
};

//----------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions src/XrdCl/XrdClRequestSync.hh
Expand Up @@ -20,6 +20,7 @@
#define __XRD_CL_REQUEST_SYNC_HH__

#include "XrdSys/XrdSysPthread.hh"
#include "XrdCl/XrdClUglyHacks.hh"

namespace XrdCl
{
Expand All @@ -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 )
{
Expand Down Expand Up @@ -94,8 +95,8 @@ namespace XrdCl

private:
XrdSysMutex pMutex;
XrdSysSemaphore *pQuotaSem;
XrdSysSemaphore *pTotalSem;
Semaphore *pQuotaSem;
Semaphore *pTotalSem;
uint32_t pRequestsLeft;
uint32_t pFailureCounter;
};
Expand Down
7 changes: 4 additions & 3 deletions src/XrdCl/XrdClSyncQueue.hh
Expand Up @@ -22,6 +22,7 @@
#include <queue>

#include "XrdSys/XrdSysPthread.hh"
#include "XrdCl/XrdClUglyHacks.hh"

namespace XrdCl
{
Expand All @@ -37,7 +38,7 @@ namespace XrdCl
//------------------------------------------------------------------------
SyncQueue()
{
pSem = new XrdSysSemaphore(0);
pSem = new Semaphore(0);
};

//------------------------------------------------------------------------
Expand Down Expand Up @@ -84,13 +85,13 @@ namespace XrdCl
while( !pQueue.empty() )
pQueue.pop();
delete pSem;
pSem = new XrdSysSemaphore(0);
pSem = new Semaphore(0);
}

private:
std::queue<Item> pQueue;
XrdSysMutex pMutex;
XrdSysSemaphore *pSem;
Semaphore *pSem;
};
}

Expand Down
10 changes: 5 additions & 5 deletions src/XrdCl/XrdClThirdPartyCopyJob.cc
Expand Up @@ -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 <iostream>
#include <cctype>
Expand All @@ -48,7 +48,7 @@ namespace
// Constructor
//------------------------------------------------------------------------
TPCStatusHandler():
pSem( new XrdSysSemaphore(0) ), pStatus(0)
pSem( new XrdCl::Semaphore(0) ), pStatus(0)
{
}

Expand All @@ -75,7 +75,7 @@ namespace
//------------------------------------------------------------------------
// Get Mutex
//------------------------------------------------------------------------
XrdSysSemaphore *GetSemaphore()
XrdCl::Semaphore *GetSemaphore()
{
return pSem;
}
Expand All @@ -89,7 +89,7 @@ namespace
}

private:
XrdSysSemaphore *pSem;
XrdCl::Semaphore *pSem;
XrdCl::XRootDStatus *pStatus;
};

Expand Down Expand Up @@ -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() );

Expand Down
13 changes: 13 additions & 0 deletions src/XrdCl/XrdClUglyHacks.hh
Expand Up @@ -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
Expand Down

0 comments on commit 8e1afec

Please sign in to comment.