Line 1... |
Line 1... |
// $Id: RlinkServer.cpp 662 2015-04-05 08:02:54Z mueller $
|
// $Id: RlinkServer.cpp 686 2015-06-04 21:08:08Z mueller $
|
//
|
//
|
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
// Copyright 2013-2015 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
//
|
//
|
// This program is free software; you may redistribute and/or modify it under
|
// This program is free software; you may redistribute and/or modify it under
|
// the terms of the GNU General Public License as published by the Free
|
// the terms of the GNU General Public License as published by the Free
|
Line 11... |
Line 11... |
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for complete details.
|
// for complete details.
|
//
|
//
|
// Revision History:
|
// Revision History:
|
// Date Rev Version Comment
|
// Date Rev Version Comment
|
|
// 2015-06-05 686 1.2.1 BUGFIX: CallAttnHandler(): fix race in hnext
|
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), use UnStop()
|
// 2015-04-04 662 1.2 BUGFIX: fix race in Stop(), use UnStop()
|
// 2015-01-10 632 2.2 Exec() without emsg now void, will throw
|
// 2015-01-10 632 2.2 Exec() without emsg now void, will throw
|
// 2014-12-30 625 2.1 adopt to Rlink V4 attn logic
|
// 2014-12-30 625 2.1 adopt to Rlink V4 attn logic
|
// 2014-12-21 617 2.0.1 use kStat_M_RbTout for rbus timeout
|
// 2014-12-21 617 2.0.1 use kStat_M_RbTout for rbus timeout
|
// 2014-12-11 611 2.0 re-organize for rlink v4
|
// 2014-12-11 611 2.0 re-organize for rlink v4
|
Line 24... |
Line 25... |
// 2013-01-12 474 0.5 First draft
|
// 2013-01-12 474 0.5 First draft
|
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
|
|
/*!
|
/*!
|
\file
|
\file
|
\version $Id: RlinkServer.cpp 662 2015-04-05 08:02:54Z mueller $
|
\version $Id: RlinkServer.cpp 686 2015-06-04 21:08:08Z mueller $
|
\brief Implemenation of RlinkServer.
|
\brief Implemenation of RlinkServer.
|
*/
|
*/
|
|
|
#include "boost/thread/locks.hpp"
|
#include "boost/thread/locks.hpp"
|
#include "boost/bind.hpp"
|
#include "boost/bind.hpp"
|
Line 433... |
Line 434... |
//! FIXME_docs
|
//! FIXME_docs
|
|
|
void RlinkServer::CallAttnHandler()
|
void RlinkServer::CallAttnHandler()
|
{
|
{
|
fStats.Inc(kStatNAttnHdl);
|
fStats.Inc(kStatNAttnHdl);
|
|
if (fTraceLevel>0) {
|
|
RlogMsg lmsg(LogFile());
|
|
lmsg << "-I attnhdl-beg: patt=" << RosPrintBvi(fAttnPatt,8);
|
|
}
|
|
|
// if notifier pending, transfer it to current attn pattern
|
// if notifier pending, transfer it to current attn pattern
|
if (fAttnNotiPatt) {
|
if (fAttnNotiPatt) {
|
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
fStats.Inc(kStatNAttnNoti);
|
fStats.Inc(kStatNAttnNoti);
|
|
if (fTraceLevel>0) {
|
|
RlogMsg lmsg(LogFile());
|
|
lmsg << "-I attnhdl-add: patt=" << RosPrintBvi(fAttnPatt,8)
|
|
<< " noti=" << RosPrintBvi(fAttnNotiPatt,8);
|
|
}
|
fAttnPatt |= fAttnNotiPatt;
|
fAttnPatt |= fAttnNotiPatt;
|
fAttnNotiPatt = 0;
|
fAttnNotiPatt = 0;
|
}
|
}
|
|
|
// do stats for pending attentions
|
// do stats for pending attentions
|
Line 456... |
Line 466... |
uint16_t hmatch = fAttnPatt & fAttnDsc[i].fId.fMask;
|
uint16_t hmatch = fAttnPatt & fAttnDsc[i].fId.fMask;
|
if (hmatch) {
|
if (hmatch) {
|
AttnArgs args(fAttnPatt, fAttnDsc[i].fId.fMask);
|
AttnArgs args(fAttnPatt, fAttnDsc[i].fId.fMask);
|
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
boost::lock_guard<RlinkConnect> lock(*fspConn);
|
|
|
|
if (fTraceLevel>0) {
|
|
RlogMsg lmsg(LogFile());
|
|
lmsg << "-I attnhdl-bef: patt=" << RosPrintBvi(fAttnPatt,8)
|
|
<< " hmat=" << RosPrintBvi(hmatch,8);
|
|
}
|
|
|
// FIXME_code: return code not used, yet
|
// FIXME_code: return code not used, yet
|
fAttnDsc[i].fHandler(args);
|
fAttnDsc[i].fHandler(args);
|
if (!args.fHarvestDone)
|
if (!args.fHarvestDone)
|
Rexception("RlinkServer::CallAttnHandler()",
|
Rexception("RlinkServer::CallAttnHandler()",
|
"Handler didn't set fHarvestDone");
|
"Handler didn't set fHarvestDone");
|
|
|
uint16_t hnew = args.fAttnHarvest & ~fAttnDsc[i].fId.fMask;
|
uint16_t hnew = args.fAttnHarvest & ~fAttnDsc[i].fId.fMask;
|
hnext |= hnew;
|
hnext |= hnew;
|
|
hnext &= ~hmatch; // FIXME_code: this is a patch
|
|
// works for single lam handlers only
|
|
// ok for now, but will not work in general !!
|
hdone |= hmatch;
|
hdone |= hmatch;
|
|
|
|
if (fTraceLevel>0) {
|
|
RlogMsg lmsg(LogFile());
|
|
lmsg << "-I attnhdl-aft: patt=" << RosPrintBvi(fAttnPatt,8)
|
|
<< " done=" << RosPrintBvi(hdone,8)
|
|
<< " next=" << RosPrintBvi(hnext,8);
|
|
}
|
|
|
}
|
}
|
}
|
}
|
fAttnPatt &= ~hdone; // clear handled bits
|
fAttnPatt &= ~hdone; // clear handled bits
|
|
|
// if there are any unhandled attenions, do default handling which will
|
// if there are any unhandled attenions, do default handling which will
|