Skip to content
Snippets Groups Projects
Commit d8044a96 authored by Steven Murray's avatar Steven Murray
Browse files

Added more file-descriptor closed logs

parent c7acf6c8
No related branches found
No related tags found
No related merge requests found
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Thu Jan 14 15:49:34 CET 2010
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Fri Jan 15 10:40:10 CET 2010
*/
/******************************************************************************
......@@ -148,7 +148,8 @@ AGGREGATOR_SEND_END_OF_SESSION_TO_RTCPD=111, /* "Sending end-of-session to RTCPD
AGGREGATOR_FAILED_TO_PARSE_TPCONFIG=112, /* "Failed to parse TPCONFIG file" */
AGGREGATOR_PARSED_TPCONFIG=113, /* "Parsed TPCONFIG" */
AGGREGATOR_ADDED_TAPE_SESSION_TO_CATLAOGUE=114, /* "Added tape session to catalogue" */
AGGREGATOR_REMOVED_TAPE_SESSION_FROM_CATALOGUE=115 /* "Removed tape session from catalogue" */
AGGREGATOR_REMOVED_TAPE_SESSION_FROM_CATALOGUE=115, /* "Removed tape session from catalogue" */
AGGREGATOR_CLOSED_RTCPD_DISK_TAPE_CONNECTION_DUE_TO_PEER=116 /* "Closed rtcpd disk/tape IO control connection due to rtcpd closing its end" */
}; // enum AggregatorDlfMessages
} // namespace aggregator
} // namespace tape
......
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Thu Jan 14 15:49:34 CET 2010
/* This file was generated by ./AggregatorDlfMessagesCodeGenerator on Fri Jan 15 10:40:10 CET 2010
*/
/******************************************************************************
......@@ -145,4 +145,5 @@ castor::dlf::Message castor::tape::aggregator::AggregatorDaemon::s_dlfMessages[]
{AGGREGATOR_PARSED_TPCONFIG, "Parsed TPCONFIG"},
{AGGREGATOR_ADDED_TAPE_SESSION_TO_CATLAOGUE, "Added tape session to catalogue"},
{AGGREGATOR_REMOVED_TAPE_SESSION_FROM_CATALOGUE, "Removed tape session from catalogue"},
{AGGREGATOR_CLOSED_RTCPD_DISK_TAPE_CONNECTION_DUE_TO_PEER, "Closed rtcpd disk/tape IO control connection due to rtcpd closing its end"},
{-1, ""}};
......@@ -114,3 +114,4 @@
113,AGGREGATOR_PARSED_TPCONFIG,"Parsed TPCONFIG"
114,AGGREGATOR_ADDED_TAPE_SESSION_TO_CATLAOGUE,"Added tape session to catalogue"
115,AGGREGATOR_REMOVED_TAPE_SESSION_FROM_CATALOGUE,"Removed tape session from catalogue"
116,AGGREGATOR_CLOSED_RTCPD_DISK_TAPE_CONNECTION_DUE_TO_PEER,"Closed rtcpd disk/tape IO control connection due to rtcpd closing its end"
......@@ -156,12 +156,12 @@ int castor::tape::aggregator::BridgeProtocolEngine::acceptRtcpdConnection()
net::getPeerHostName(connectedSock.get(), hostName);
castor::dlf::Param params[] = {
castor::dlf::Param("volReqId" , m_jobRequest.volReqId ),
castor::dlf::Param("IP" , castor::dlf::IPAddress(ip)),
castor::dlf::Param("Port" , port ),
castor::dlf::Param("HostName" , hostName ),
castor::dlf::Param("socketFd" , connectedSock.get() ),
castor::dlf::Param("nbDiskTapeConns",
castor::dlf::Param("mountTransactionId", m_jobRequest.volReqId ),
castor::dlf::Param("IP" , castor::dlf::IPAddress(ip)),
castor::dlf::Param("Port" , port ),
castor::dlf::Param("HostName" , hostName ),
castor::dlf::Param("socketFd" , connectedSock.get() ),
castor::dlf::Param("nbDiskTapeConns" ,
m_sockCatalogue.getNbDiskTapeIOControlConns())};
castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM, AGGREGATOR_RTCPD_CALLBACK,
params);
......@@ -249,12 +249,12 @@ void castor::tape::aggregator::BridgeProtocolEngine::processSocks()
case -1: // Select encountered an error
// If the select was interrupted
// If select was interrupted
if(selectErrno == EINTR) {
// Write a log message
castor::dlf::Param params[] = {
castor::dlf::Param("volReqId", m_jobRequest.volReqId)};
castor::dlf::Param("mountTransActionId", m_jobRequest.volReqId)};
castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
AGGREGATOR_SELECT_INTR, params);
......@@ -369,6 +369,13 @@ bool castor::tape::aggregator::BridgeProtocolEngine::processAPendingSocket(
// session
if(peerClosed) {
close(m_sockCatalogue.releaseRtcpdDiskTapeIOControlConn(pendingSock));
castor::dlf::Param params[] = {
castor::dlf::Param("mountTransactionId", m_jobRequest.volReqId),
castor::dlf::Param("socketFd" , pendingSock )};
castor::dlf::dlf_writep(m_cuuid, DLF_LVL_SYSTEM,
AGGREGATOR_CLOSED_RTCPD_DISK_TAPE_CONNECTION_DUE_TO_PEER, params);
return true; // Continue the RTCOPY session
}
}
......
......@@ -33,16 +33,26 @@
//-----------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------
castor::tape::utils::SmartFd::SmartFd() :
m_fd(-1) {
castor::tape::utils::SmartFd::SmartFd() throw():
m_fd(-1), m_closedCallback(NULL) {
}
//-----------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------
castor::tape::utils::SmartFd::SmartFd(const int fd) :
m_fd(fd) {
castor::tape::utils::SmartFd::SmartFd(const int fd) throw():
m_fd(fd), m_closedCallback(NULL) {
}
//-----------------------------------------------------------------------------
// setClosedCallback
//-----------------------------------------------------------------------------
void castor::tape::utils::SmartFd::setClosedCallback(const int fd,
ClosedCallback closedCallback) throw() {
m_closedCallback = closedCallback;
}
......@@ -56,6 +66,15 @@ void castor::tape::utils::SmartFd::reset(const int fd = -1) throw() {
// If this SmartFd still owns a file descriptor, then close it
if(m_fd >= 0) {
close(m_fd);
if(m_closedCallback) {
try {
(*m_closedCallback)(m_fd);
} catch(...) {
// Ignore any exception thrown my the m_closedCallback function
// because this reset function maybe called by the destructor of
// SmartFd
}
}
}
// Take ownership of the new file descriptor
......
......@@ -41,11 +41,22 @@ namespace utils {
public:
/**
* A pointer to a callback function that will called by the Smart
* immediately after the SmartFd has closed the file-descriptor it owns.
*
* Please note that any exception thrown by this function will be ignored
* because this function maybe called by the destructor of SmartFd.
*
* @param closedfd The value of the file descriptor that was closed.
*/
typedef void (*ClosedCallback)(int closedfd);
/**
* Constructor.
*
*/
SmartFd();
SmartFd() throw();
/**
* Constructor.
......@@ -53,7 +64,28 @@ namespace utils {
* @param fd The file descriptor to be owned by the smart file
* descriptor.
*/
SmartFd(const int fd);
SmartFd(const int fd) throw();
/**
* Sets the function to be called back by the SmartFd immediately after
* the SmartFd has closed the file-descriptor it owns.
*
* Setting the callback function to NULL means that no function will be
* called.
*
* Please note any exception thrown by the callback function will be
* ignored because the callback function maybe called by the destructor of
* SmartFd.
*
* @param fd The file descriptor to be owned by the smart file
* descriptor.
* @param closedCallback This function will be called immediately after
* the SmartFd has closed the file-descriptor it owns.
* Please note that any exception thrown by this
* function will be ignored because this function
* maybe called by the destructor of SmartFd.
*/
void setClosedCallback(const int fd, ClosedCallback closedCallback) throw();
/**
* Take ownership of the specified file descriptor, closing the previously
......@@ -105,11 +137,17 @@ namespace utils {
private:
/**
* The owned file descriptor. A negtaive value means this SmartFd does not
* The owned file descriptor. A negative value means this SmartFd does not
* own a file descriptor..
*/
int m_fd;
/**
* The function to be called immediately after the SmartFd has closed its
* file-descriptor. A value of null means no function will be called.
*/
ClosedCallback m_closedCallback;
};
} // namespace utils
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment