Improve re-connection handling in unexpectedly disconnecting IP ports.
This commit is contained in:
@ -502,6 +502,26 @@ connectToAsynPort()
|
|||||||
clientName(), pasynUser->errorMessage);
|
clientName(), pasynUser->errorMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
// Is it really connected?
|
||||||
|
if (connected && !pasynGpib)
|
||||||
|
{
|
||||||
|
size_t received;
|
||||||
|
int eomReason;
|
||||||
|
char buffer[8];
|
||||||
|
|
||||||
|
pasynUser->timeout = 0.0;
|
||||||
|
status = pasynOctet->read(pvtOctet, pasynUser,
|
||||||
|
buffer, 0, &received, &eomReason);
|
||||||
|
debug("AsynDriverInterface::connectToAsynPort(%s): "
|
||||||
|
"read(..., 0, ...) [timeout=%f seconds] = %s\n",
|
||||||
|
clientName(), pasynUser->timeout,
|
||||||
|
asynStatusStr[status]);
|
||||||
|
pasynManager->isConnected(pasynUser, &connected);
|
||||||
|
debug("AsynDriverInterface::connectToAsynPort(%s): "
|
||||||
|
"device was %sconnected!\n",
|
||||||
|
clientName(),connected?"":"dis");
|
||||||
|
}
|
||||||
|
|
||||||
debug("AsynDriverInterface::connectToAsynPort(%s) is %s connected\n",
|
debug("AsynDriverInterface::connectToAsynPort(%s) is %s connected\n",
|
||||||
clientName(), connected ? "already" : "not yet");
|
clientName(), connected ? "already" : "not yet");
|
||||||
if (!connected)
|
if (!connected)
|
||||||
@ -622,6 +642,24 @@ writeHandler()
|
|||||||
}
|
}
|
||||||
status = pasynOctet->write(pvtOctet, pasynUser,
|
status = pasynOctet->write(pvtOctet, pasynUser,
|
||||||
outputBuffer, outputSize, &written);
|
outputBuffer, outputSize, &written);
|
||||||
|
debug("AsynDriverInterface::writeHandler(%s): "
|
||||||
|
"write(..., outputSize=%d, written=%d) [timeout=%f seconds] = %s\n",
|
||||||
|
clientName(), outputSize, written, pasynUser->timeout,
|
||||||
|
asynStatusStr[status]);
|
||||||
|
|
||||||
|
// Up to asyn 4.17 I can't see when the server has disconnected. Why?
|
||||||
|
int connected;
|
||||||
|
pasynManager->isConnected(pasynUser, &connected);
|
||||||
|
debug("AsynDriverInterface::writeHandler(%s): "
|
||||||
|
"device is %sconnected\n",
|
||||||
|
clientName(),connected?"":"dis");
|
||||||
|
if (!connected) {
|
||||||
|
error("%s: connection closed in write\n",
|
||||||
|
clientName());
|
||||||
|
writeCallback(StreamIoFault);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (oldeoslen >= 0) // restore asyn terminator
|
if (oldeoslen >= 0) // restore asyn terminator
|
||||||
{
|
{
|
||||||
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
pasynOctet->setOutputEos(pvtOctet, pasynUser,
|
||||||
@ -812,6 +850,7 @@ readHandler()
|
|||||||
int eomReason;
|
int eomReason;
|
||||||
asynStatus status;
|
asynStatus status;
|
||||||
long readMore;
|
long readMore;
|
||||||
|
int connected;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@ -828,6 +867,16 @@ readHandler()
|
|||||||
clientName(), bytesToRead, pasynUser->timeout,
|
clientName(), bytesToRead, pasynUser->timeout,
|
||||||
asynStatusStr[status]);
|
asynStatusStr[status]);
|
||||||
}
|
}
|
||||||
|
pasynManager->isConnected(pasynUser, &connected);
|
||||||
|
debug("AsynDriverInterface::readHandler(%s): "
|
||||||
|
"device is %sconnected\n",
|
||||||
|
clientName(),connected?"":"dis");
|
||||||
|
if (!connected) {
|
||||||
|
error("%s: connection closed in read\n",
|
||||||
|
clientName());
|
||||||
|
readCallback(StreamIoFault);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// pasynOctet->read() has already cut off terminator.
|
// pasynOctet->read() has already cut off terminator.
|
||||||
|
|
||||||
if (status == asynTimeout &&
|
if (status == asynTimeout &&
|
||||||
@ -959,18 +1008,18 @@ readHandler()
|
|||||||
case asynDisconnected:
|
case asynDisconnected:
|
||||||
error("%s: asynDisconnected in read: %s\n",
|
error("%s: asynDisconnected in read: %s\n",
|
||||||
clientName(), pasynUser->errorMessage);
|
clientName(), pasynUser->errorMessage);
|
||||||
writeCallback(StreamIoFault);
|
readCallback(StreamIoFault);
|
||||||
return;
|
return;
|
||||||
case asynDisabled:
|
case asynDisabled:
|
||||||
error("%s: asynDisconnected in read: %s\n",
|
error("%s: asynDisconnected in read: %s\n",
|
||||||
clientName(), pasynUser->errorMessage);
|
clientName(), pasynUser->errorMessage);
|
||||||
writeCallback(StreamIoFault);
|
readCallback(StreamIoFault);
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
error("%s: unknown asyn error in read: %s\n",
|
error("%s: unknown asyn error in read: %s\n",
|
||||||
clientName(), pasynUser->errorMessage);
|
clientName(), pasynUser->errorMessage);
|
||||||
writeCallback(StreamIoFault);
|
readCallback(StreamIoFault);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!readMore) break;
|
if (!readMore) break;
|
||||||
|
@ -825,10 +825,16 @@ lockCallback(StreamIoStatus status)
|
|||||||
}
|
}
|
||||||
flags &= ~LockPending;
|
flags &= ~LockPending;
|
||||||
flags |= BusOwner;
|
flags |= BusOwner;
|
||||||
if (status != StreamIoSuccess)
|
switch (status)
|
||||||
{
|
{
|
||||||
|
case StreamIoSuccess:
|
||||||
|
break;
|
||||||
|
case StreamIoTimeout:
|
||||||
finishProtocol(LockTimeout);
|
finishProtocol(LockTimeout);
|
||||||
return;
|
return;
|
||||||
|
default:
|
||||||
|
finishProtocol(Fault);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
flags |= WritePending;
|
flags |= WritePending;
|
||||||
if (!busWriteRequest(outputLine(), outputLine.length(), writeTimeout))
|
if (!busWriteRequest(outputLine(), outputLine.length(), writeTimeout))
|
||||||
|
Reference in New Issue
Block a user