Commit a1fbe1d8 authored by Pavel Vainerman's avatar Pavel Vainerman

(ModbusTCPSession): исправил ошибку с "зависанием соединения"

(uniset-log): исправил ошибку с "загрузкой процессора" в случае закрытия "канала"
parent ac610fd2
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
Name: libuniset2 Name: libuniset2
Version: 2.1 Version: 2.1
Release: alt22 Release: alt23
Summary: UniSet - library for building distributed industrial control systems Summary: UniSet - library for building distributed industrial control systems
...@@ -456,6 +456,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname ...@@ -456,6 +456,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# .. # ..
%changelog %changelog
* Mon Sep 07 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt23
- (ModbusPersistentSlave): fixed bug in end connection processing
- (uniset-log): fixed bug in end connection processing
* Sun Sep 06 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt22 * Sun Sep 06 2015 Pavel Vainerman <pv@altlinux.ru> 2.1-alt22
- refactoring (use shared_ptr), change pollfactor realisation.. - refactoring (use shared_ptr), change pollfactor realisation..
......
...@@ -84,8 +84,16 @@ void ModbusTCPSession::run() ...@@ -84,8 +84,16 @@ void ModbusTCPSession::run()
ModbusRTU::mbErrCode res = erTimeOut; ModbusRTU::mbErrCode res = erTimeOut;
cancelled = false; cancelled = false;
char pbuf[3];
while( !cancelled && isPending(Socket::pendingInput, timeout) ) while( !cancelled && isPending(Socket::pendingInput, timeout) )
{ {
ssize_t n = peek( pbuf, sizeof(pbuf) );
// кажется сервер закрыл канал
if( n == 0 )
break;
res = receive(addr, timeout); res = receive(addr, timeout);
if( res == erSessionClosed ) if( res == erSessionClosed )
......
...@@ -299,7 +299,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ ...@@ -299,7 +299,7 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
while( tcp->isPending(ost::Socket::pendingInput, inTimeout) ) while( tcp->isPending(ost::Socket::pendingInput, inTimeout) )
{ {
int n = tcp->peek( buf, sizeof(buf) - 1 ); ssize_t n = tcp->peek( buf, sizeof(buf) - 1 );
if( n > 0 ) if( n > 0 )
{ {
...@@ -308,6 +308,8 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ ...@@ -308,6 +308,8 @@ void LogReader::readlogs( const std::string& _addr, ost::tpport_t _port, LogServ
log << buf; log << buf;
} }
else if( n == 0 && readcount <=0 )
break;
if( rcount > 0 && readcount > 0 ) if( rcount > 0 && readcount > 0 )
rcount--; rcount--;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment