From f84774e3ecd947f82a724bf3c354b817a8cb4431 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 22 Oct 2018 10:00:45 -0700 Subject: [PATCH] PVA server earlier check of monitor window Check window size before attemting poll() as apparently "spurious" send() is possible. --- src/server/responseHandlers.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/server/responseHandlers.cpp b/src/server/responseHandlers.cpp index 53edc639..81412be6 100644 --- a/src/server/responseHandlers.cpp +++ b/src/server/responseHandlers.cpp @@ -2097,7 +2097,17 @@ void ServerMonitorRequesterImpl::send(ByteBuffer* buffer, TransportSendControl* // TODO asCheck ? - MonitorElement::Ref element(monitor); + bool busy = false; + if(_pipeline) { + Lock guard(_mutex); + busy = _window_open==0; + } + + MonitorElement::Ref element; + if(!busy) { + MonitorElement::Ref E(monitor); + E.swap(element); + } if (element) { control->startMessage((int8)CMD_MONITOR, sizeof(int32)/sizeof(int8) + 1); @@ -2119,11 +2129,10 @@ void ServerMonitorRequesterImpl::send(ByteBuffer* buffer, TransportSendControl* Lock guard(_mutex); if(!_pipeline) { } else if(_window_open==0) { - if(_pipeline) { - // Our logic has a problem, but try to continue. - message("Monitor Logic Error: send outside of window", epics::pvData::warningMessage); - LOG(logLevelError, "Monitor Logic Error: send outside of window %zu", _window_closed.size()); - } + // This really shouldn't happen as the above ensures that _window_open *was* non-zero, + // and only we (the sender) will decrement. + message("Monitor Logic Error: send outside of window", epics::pvData::warningMessage); + LOG(logLevelError, "Monitor Logic Error: send outside of window %zu", _window_closed.size()); } else { _window_closed.push_back(element.letGo());