forked from xrootd/xrootd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reinstate XrdSfsCallBack.*, patch XrdOucCallBack.hh, add XrdSys,XrdSf…
…s,XrdOuc lib targets
- Loading branch information
Showing
7 changed files
with
357 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
include( XRootDCommon ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Shared library version | ||
#------------------------------------------------------------------------------- | ||
set( XRD_OUC_VERSION 1.0.0 ) | ||
set( XRD_OUC_SOVERSION 1 ) | ||
set( XRD_OUC_PRELOAD_VERSION 0.0.1 ) | ||
set( XRD_OUC_PRELOAD_SOVERSION 0 ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# The XrdOuc library | ||
#------------------------------------------------------------------------------- | ||
add_library( | ||
XrdOuc | ||
SHARED | ||
XrdOuc/XrdOuca2x.cc XrdOuc/XrdOucCallBack.cc XrdOuc/XrdOucMsubs.cc XrdOuc/XrdOucPup.cc XrdOuc/XrdOucTokenizer.cc | ||
XrdOuc/XrdOucArgs.cc XrdOuc/XrdOucCRC.cc XrdOuc/XrdOucName2Name.cc XrdOuc/XrdOucReqID.cc XrdOuc/XrdOucTrace.cc | ||
XrdOuc/XrdOucCacheData.cc XrdOuc/XrdOucEnv.cc XrdOuc/XrdOucNList.cc XrdOuc/XrdOucStream.cc XrdOuc/XrdOucUtils.cc | ||
XrdOuc/XrdOucCacheDram.cc XrdOuc/XrdOucExport.cc XrdOuc/XrdOucNSWalk.cc XrdOuc/XrdOucString.cc | ||
XrdOuc/XrdOucCacheReal.cc XrdOuc/XrdOucHashVal.cc XrdOuc/XrdOucProg.cc XrdOuc/XrdOucSxeq.cc | ||
|
||
) | ||
|
||
target_link_libraries( | ||
XrdOuc | ||
XrdClient | ||
XrdUtils | ||
pthread ) | ||
|
||
set_target_properties( | ||
XrdOuc | ||
PROPERTIES | ||
VERSION ${XRD_OUC_VERSION} | ||
SOVERSION ${XRD_OUC_SOVERSION} | ||
LINK_INTERFACE_LIBRARIES "" ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Install | ||
#------------------------------------------------------------------------------- | ||
install( | ||
TARGETS XrdOuc | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) | ||
|
||
install( | ||
DIRECTORY XrdOuc/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xrootd/XrdOuc | ||
FILES_MATCHING | ||
PATTERN "*.hh" | ||
PATTERN "*.icc" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
include( XRootDCommon ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Shared library version | ||
#------------------------------------------------------------------------------- | ||
set( XRD_OUC_VERSION 1.0.0 ) | ||
set( XRD_OUC_SOVERSION 1 ) | ||
set( XRD_OUC_PRELOAD_VERSION 0.0.1 ) | ||
set( XRD_OUC_PRELOAD_SOVERSION 0 ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# The XrdSfs library | ||
#------------------------------------------------------------------------------- | ||
add_library( | ||
XrdSfs | ||
SHARED | ||
XrdSfs/XrdSfsCallBack.cc XrdSfs/XrdSfsNative.cc | ||
|
||
) | ||
|
||
target_link_libraries( | ||
XrdSfs | ||
XrdClient | ||
XrdUtils | ||
pthread ) | ||
|
||
set_target_properties( | ||
XrdSfs | ||
PROPERTIES | ||
VERSION ${XRD_OUC_VERSION} | ||
SOVERSION ${XRD_OUC_SOVERSION} | ||
LINK_INTERFACE_LIBRARIES "" ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Install | ||
#------------------------------------------------------------------------------- | ||
install( | ||
TARGETS XrdSfs | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) | ||
|
||
install( | ||
DIRECTORY XrdSfs/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xrootd/XrdSfs | ||
FILES_MATCHING | ||
PATTERN "*.hh" | ||
PATTERN "*.icc" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/******************************************************************************/ | ||
/* */ | ||
/* X r d S f s C a l l B a c k . c c */ | ||
/* */ | ||
/* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */ | ||
/* All Rights Reserved */ | ||
/* Produced by Andrew Hanushevsky for Stanford University under contract */ | ||
/* DE-AC02-76-SFO0515 with the Department of Energy */ | ||
/******************************************************************************/ | ||
|
||
#include "XrdSfs/XrdSfsCallBack.hh" | ||
#include "XrdSfs/XrdSfsInterface.hh" | ||
#include "XProtocol/XProtocol.hh" | ||
|
||
/******************************************************************************/ | ||
/* C r e a t e */ | ||
/******************************************************************************/ | ||
|
||
XrdSfsCallBack *XrdSfsCallBack::Create(XrdOucErrInfo *eInfo) | ||
{ | ||
XrdOucEICB *orgCB; | ||
XrdSfsCallBack *newCB; | ||
unsigned long long orgCBarg; | ||
|
||
// Get the original callback object here. If there is none, then callbacks are | ||
// not allowed for this particular request. | ||
// | ||
if (!(orgCB = eInfo->getErrCB(orgCBarg))) return 0; | ||
|
||
// Create a new callback object that will replace the original one. We will | ||
// get a callback after the client is informed to wait for a callback as we | ||
// can't send a response until after the client is placed in callback mode. | ||
// | ||
newCB = new XrdSfsCallBack(eInfo, orgCB, orgCBarg); | ||
eInfo->setErrCB((XrdOucEICB *)newCB); | ||
return newCB; | ||
} | ||
|
||
/******************************************************************************/ | ||
/* D o n e */ | ||
/******************************************************************************/ | ||
|
||
void XrdSfsCallBack::Done(int &Result, XrdOucErrInfo *eInfo, char const* path) | ||
{ | ||
|
||
// We get invoked twice. The first time is when the initial response is sent to | ||
// the client placing the client in callback mode. The second time is after the | ||
// callback response is sent which allows us to delete this object. | ||
// | ||
if (Final) delete this; | ||
else {Final = 1; cbSetup.Post();} | ||
} | ||
|
||
/******************************************************************************/ | ||
/* Private: R e p l y */ | ||
/******************************************************************************/ | ||
|
||
void XrdSfsCallBack::Reply(int Result, int Ecode, const char *Emsg) | ||
{ | ||
|
||
// Make sure the initial response to the client was sent | ||
// | ||
cbSetup.Wait(); | ||
|
||
// Set the error information in the callback object and effect the original | ||
// callback. We will be called back when the reply is sent (see Done()). | ||
// | ||
setErrInfo(Ecode, (Emsg ? Emsg : "")); | ||
theCB->Done(Result, (XrdOucErrInfo *)this); | ||
} | ||
|
||
/******************************************************************************/ | ||
/* R e p l y _ E r r o r */ | ||
/******************************************************************************/ | ||
|
||
void XrdSfsCallBack::Reply_Error(int Ecode, const char *Emsg) | ||
{ | ||
|
||
// Set error information in the callback object and complete callback. The | ||
// error code mapping is a hack that should be corrected as the callback | ||
// implementation should be responsible for doing this. | ||
// | ||
Ecode = XProtocol::mapError(Ecode); | ||
Reply(SFS_ERROR, Ecode, Emsg); | ||
} | ||
|
||
/******************************************************************************/ | ||
/* R e p l y _ R e d i r e c t */ | ||
/******************************************************************************/ | ||
|
||
void XrdSfsCallBack::Reply_Redirect(const char *Host, int Port) | ||
{ | ||
|
||
// Set error information in the callback object and complete callback | ||
// | ||
Reply(SFS_REDIRECT, Port, Host); | ||
} | ||
|
||
/******************************************************************************/ | ||
/* R e p l y _ O K */ | ||
/******************************************************************************/ | ||
|
||
void XrdSfsCallBack::Reply_OK(const char *Data, int Dlen) | ||
{ | ||
|
||
// Set error information in the callback object and complete callback | ||
// | ||
if (Dlen) Reply(SFS_DATA, Dlen, Data); | ||
else Reply(SFS_OK, 0, 0); | ||
} | ||
|
||
/******************************************************************************/ | ||
/* R e p l y _ R e t r y */ | ||
/******************************************************************************/ | ||
|
||
void XrdSfsCallBack::Reply_Retry(int wSec) | ||
{ | ||
|
||
// Set error information in the callback object and complete callback | ||
// | ||
Reply(SFS_STALL, wSec, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#ifndef _XRDSFSCALLBACK_H_ | ||
#define _XRDSFSCALLBACK_H_ | ||
/******************************************************************************/ | ||
/* */ | ||
/* X r d S f s C a l l B a c k . h h */ | ||
/* */ | ||
/* (c) 2010 by the Board of Trustees of the Leland Stanford, Jr., University */ | ||
/* All Rights Reserved */ | ||
/* Produced by Andrew Hanushevsky for Stanford University under contract */ | ||
/* DE-AC02-76-SFO0515 with the Department of Energy */ | ||
/******************************************************************************/ | ||
|
||
#include "XrdOuc/XrdOucErrInfo.hh" | ||
#include "XrdSys/XrdSysPthread.hh" | ||
|
||
// This class provides an easy-to-use interface to generate callback events. | ||
// | ||
// 1) Create a callback object using Create() | ||
// 2) Return to the caller with return code SFS_STARTED. This will cause the | ||
// client to wait for a callback. Note that you must queue the callback | ||
// object for processing in some other thread as your will be returning. | ||
// 3) After processing is completed, use ONE of the reply methods associated | ||
// with the clallback object to tell the client how to proceed. Once you | ||
// called any of the reply methods, the object subject of the reply is | ||
// automatically deleted as only one callback is allowed per instance. | ||
// | ||
class XrdSfsCallBack : public XrdOucErrInfo, public XrdOucEICB | ||
{ | ||
public: | ||
|
||
// Create() creates a callback object based on callback information present | ||
// in the XrdOucErrInfo object associated with the request. If the | ||
// request does not allow callback's, a null pointer is returned. | ||
// | ||
static XrdSfsCallBack *Create(XrdOucErrInfo *eInfo); | ||
|
||
// The following are reply method to complete the callback. The callback object | ||
// is automatically deleted upon return. | ||
|
||
// Reply_Error() calls back the client indicating that the request failed | ||
// with the given error number and message text. | ||
// | ||
void Reply_Error(int Ecode, const char *Emsg=0); | ||
|
||
// Reply_Redirect() calls back the client indicating that the request should be | ||
// tried again at the indicated host:port. | ||
// | ||
void Reply_Redirect(const char *Host, int Port); | ||
|
||
// Reply_OK() calls back the client indicating that the request was | ||
// completed. The client can also be given optional response | ||
// data (ASCII text up to 2K). | ||
// | ||
void Reply_OK(const char *Data=0, int Dlen=0); | ||
|
||
// Reply_Retry() calls back the client indicating that the request should be | ||
// tried again after waiting for 'sec' seconds. | ||
// | ||
void Reply_Retry(int sec=0); | ||
|
||
// The following two methods are for internal use only but need to be public. | ||
// | ||
void Done(int &Result, XrdOucErrInfo *eInfo, char const* path); | ||
|
||
int Same(unsigned long long arg1, unsigned long long arg2) {return 0;} | ||
|
||
~XrdSfsCallBack() {} | ||
|
||
private: | ||
XrdSfsCallBack(XrdOucErrInfo *eInfo, XrdOucEICB *cbP, | ||
unsigned long long cbArg) | ||
: XrdOucErrInfo(eInfo->getErrUser(), 0, cbArg), | ||
cbSetup(0), theCB(cbP), Final(0) {} | ||
|
||
void Reply(int Result, int Ecode, const char *Emsg); | ||
|
||
XrdSysSemaphore cbSetup; | ||
XrdOucEICB *theCB; | ||
int Final; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
include( XRootDCommon ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Shared library version | ||
#------------------------------------------------------------------------------- | ||
set( XRD_SYS_VERSION 1.0.0 ) | ||
set( XRD_SYS_SOVERSION 1 ) | ||
set( XRD_SYS_PRELOAD_VERSION 0.0.1 ) | ||
set( XRD_SYS_PRELOAD_SOVERSION 0 ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# The XrdSys library | ||
#------------------------------------------------------------------------------- | ||
add_library( | ||
XrdSys | ||
SHARED | ||
XrdSys/XrdSysDir.cc XrdSys/XrdSysFAttr.cc XrdSys/XrdSysPlugin.cc | ||
XrdSys/XrdSysTimer.cc | ||
XrdSys/XrdSysDNS.cc XrdSys/XrdSysLogger.cc XrdSys/XrdSysPriv.cc | ||
XrdSys/XrdSysXSLock.cc | ||
XrdSys/XrdSysError.cc XrdSys/XrdSysPlatform.cc XrdSys/XrdSysPthread.cc | ||
) | ||
|
||
target_link_libraries( | ||
XrdSys | ||
XrdClient | ||
XrdUtils | ||
pthread ) | ||
|
||
set_target_properties( | ||
XrdSys | ||
PROPERTIES | ||
VERSION ${XRD_SYS_VERSION} | ||
SOVERSION ${XRD_SYS_SOVERSION} | ||
LINK_INTERFACE_LIBRARIES "" ) | ||
|
||
#------------------------------------------------------------------------------- | ||
# Install | ||
#------------------------------------------------------------------------------- | ||
install( | ||
TARGETS XrdSys | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) | ||
|
||
install( | ||
DIRECTORY XrdSys/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xrootd/XrdSys | ||
FILES_MATCHING | ||
PATTERN "*.hh" | ||
PATTERN "*.icc" ) |