From de116c9e5a4c7964dc55a1a9e20fd078914c384d Mon Sep 17 00:00:00 2001 From: zimoch Date: Thu, 9 Aug 2012 08:37:08 +0000 Subject: [PATCH] Dummy-read stale input instead of flushing it in order to make it available for I/O Intr records. --- src/AsynDriverInterface.cc | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/AsynDriverInterface.cc b/src/AsynDriverInterface.cc index 449da26..7b44df1 100644 --- a/src/AsynDriverInterface.cc +++ b/src/AsynDriverInterface.cc @@ -617,19 +617,26 @@ writeHandler() clientName()); asynStatus status; size_t written = 0; - pasynUser->timeout = writeTimeout; - // discard any early input or early events - status = pasynOctet->flush(pvtOctet, pasynUser); + // discard any early input, but forward it to potential async records + // thus do not use pasynOctet->flush() + pasynUser->timeout = 0; + do { + char buffer [256]; + size_t received = sizeof(buffer); + int eomReason = 0; + status = pasynOctet->read(pvtOctet, pasynUser, + buffer, received, &received, &eomReason); +#ifndef NO_TEMPORARY + if (received) debug("AsynDriverInterface::writeHandler(%s): flushing %d bytes: \"%s\"\n", + clientName(), received, StreamBuffer(buffer, received).expand()()); +#endif + } while (status != asynTimeout); + + // discard any early events receivedEvent = 0; - - if (status != asynSuccess) - { - error("%s: pasynOctet->flush() failed: %s\n", - clientName(), pasynUser->errorMessage); - writeCallback(StreamIoFault); - return; - } + + pasynUser->timeout = writeTimeout; // has stream already added a terminator or should // asyn do so? @@ -739,7 +746,7 @@ readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms, long _expectedLength, bool async) { debug("AsynDriverInterface::readRequest(%s, %ld msec reply, " - "%ld msec read, expect %ld bytes, asyn=%s)\n", + "%ld msec read, expect %ld bytes, async=%s)\n", clientName(), replyTimeout_ms, readTimeout_ms, _expectedLength, async?"yes":"no"); @@ -978,6 +985,9 @@ readHandler() // reply timeout if (ioAction == AsyncRead) { + debug("AsynDriverInterface::readHandler(%s): " + "no async input, retry in in %g seconds\n", + clientName(), replyTimeout); // start next poll after timer expires if (replyTimeout != 0.0) startTimer(replyTimeout); // continues with: @@ -1255,6 +1265,9 @@ timerExpired() int autoconnect, connected; switch (ioAction) { + case None: + // Timeout of async poll crossed with parasitic input + return; case ReceiveEvent: // timeout while waiting for event ioAction = None;