Important update:

- Detect serial port disconnect/close
This commit is contained in:
Charl Wentzel
2017-11-27 18:48:41 +02:00
parent d123b6ceeb
commit 4ed36809b8

View File

@@ -1130,12 +1130,30 @@ bool CSelectableCore::Read( THandle * Handle )
ioctl( Handle->FD, FIONREAD, &BytesWaiting ); ioctl( Handle->FD, FIONREAD, &BytesWaiting );
// EOF from server // EOF from server
if (!BytesWaiting) if (BytesWaiting < 1)
{ {
// Close Handle // Close Handle
Close( Handle ); Close( Handle );
// Destroy Remote Client // Destroy Client
if (Handle->Type == ctRemoteClient) {
RemoveHandle( Handle );
}
return false;
}
}
else if (Handle->Type == ctPort)
{
// Check if anything to read
ioctl( Handle->FD, FIONREAD, &BytesWaiting );
// EOF from port
if (BytesWaiting < 1)
{
// Close Handle
Close( Handle );
// Destroy Port
if (Handle->Type == ctRemoteClient) { if (Handle->Type == ctRemoteClient) {
RemoveHandle( Handle ); RemoveHandle( Handle );
} }