Skip to content

Commit

Permalink
[IOEvents] Improve tracing.
Browse files Browse the repository at this point in the history
  • Loading branch information
abh3 committed Dec 16, 2021
1 parent 77df0f9 commit 1201f0c
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/XrdSys/XrdSysIOEvents.cc
Expand Up @@ -38,10 +38,26 @@
#include "XrdSys/XrdSysPlatform.hh"
#include "XrdSys/XrdSysPthread.hh"

/******************************************************************************/
/* L o c a l D a t a */
/******************************************************************************/

namespace
{
// Status code to name array corresponding to:
// enum Status {isClear = 0, isCBMode, isDead};
//
const char *statName[] = {"isClear", "isCBMode", "isDead"};
}

/******************************************************************************/
/* L o c a l D e f i n e s */
/******************************************************************************/

#define STATUS statName[(int)chStat]

#define STATUSOF(x) statName[(int)(x->chStat)]

#define SINGLETON(dlvar, theitem)\
theitem ->dlvar .next == theitem

Expand Down Expand Up @@ -69,7 +85,7 @@

#define DO_TRACE(x,fd,y) \
{PollerInit::traceMTX.Lock(); \
cerr <<"IOE fd " <<fd <<' ' <<#x <<": " <<y <<endl; \
cerr <<"IOE fd "<<fd<<' '<<#x <<": "<<y<<'\n'<<flush; \
PollerInit::traceMTX.UnLock();}

#define TRACING PollerInit::doTrace
Expand Down Expand Up @@ -285,6 +301,10 @@ void XrdSys::IOEvents::Channel::Delete()
Poller *myPoller;
bool isLocked = true;

// Do some tracing
//
IF_TRACE(Delete,chFD,"status="<<STATUS);

// Lock ourselves during the delete process. If the channel is disassociated
// or the real poller is set to the error poller then this channel is clean
// and can be deleted (i.e. the channel ran through Detach()).
Expand Down Expand Up @@ -312,6 +332,7 @@ void XrdSys::IOEvents::Channel::Delete()
chMutex.UnLock();
} else {
XrdSysSemaphore cbDone(0);
IF_TRACE(Delete,chFD,"waiting for callback");
chStat = isDead;
chCBA = (void *)&cbDone;
chMutex.UnLock();
Expand All @@ -320,6 +341,7 @@ void XrdSys::IOEvents::Channel::Delete()
}
// It is now safe to release the storage
//
IF_TRACE(Delete,chFD,"chan="<<hex<<(void *)this<<dec);
delete this;
}

Expand Down Expand Up @@ -860,7 +882,7 @@ int XrdSys::IOEvents::Poller::GetRequest()
do {rlen = read(reqFD, pipeBuff, pipeBlen);}
while(rlen < 0 && errno == EINTR);
if (rlen <= 0)
{cerr <<"Poll: " <<XrdSysE2T(errno) <<" reading from request pipe" <<endl;
{cerr <<"Poll: "<<XrdSysE2T(errno)<<" reading from request pipe\n"<<flush;
return 0;
}

Expand Down Expand Up @@ -1066,6 +1088,11 @@ bool XrdSys::IOEvents::Poller::TmoAdd(XrdSys::IOEvents::Channel *cP, int tmoSet)
Channel *ncP;
bool setRTO, setWTO;

// Do some tracing
//
IF_TRACE(TmoAdd,cP->chFD,"chan="<<hex<<(void*)cP<<dec
<<" inTOQ="<<BOOLNAME(cP->inTOQ)<<" status="<<STATUSOF(cP));

// Remove element from timeout queue if it is there
//
if (cP->inTOQ)
Expand Down Expand Up @@ -1125,6 +1152,11 @@ bool XrdSys::IOEvents::Poller::TmoAdd(XrdSys::IOEvents::Channel *cP, int tmoSet)
void XrdSys::IOEvents::Poller::TmoDel(XrdSys::IOEvents::Channel *cP)
{

// Do some tracing
//
IF_TRACE(TmoDel,cP->chFD,"chan="<<hex<<(void*)cP<<dec
<<" inTOQ="<<BOOLNAME(cP->inTOQ)<<" status="<<STATUSOF(cP));

// Get the timeout queue lock and remove the channel from the queue
//
toMutex.Lock();
Expand Down

0 comments on commit 1201f0c

Please sign in to comment.