Commit 59b109f4 authored by Pavel Vainerman's avatar Pavel Vainerman

(MBTCPMaster): попытка убрать лишний вызов setKeepAliveParams()

parent c16ac65e
......@@ -14,7 +14,7 @@
Name: libuniset2
Version: 2.4
Release: alt6
Release: alt7
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
......@@ -484,6 +484,9 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Fri Aug 19 2016 Pavel Vainerman <pv@altlinux.ru> 2.4-alt7
- minor fixes
* Tue Aug 09 2016 Pavel Vainerman <pv@altlinux.ru> 2.4-alt6
- build new version (optimization, refactoring)
......
......@@ -38,7 +38,7 @@ class UTCPStream:
// return true if OK
bool setKeepAliveParams( timeout_t timeout_sec = 5, int conn_keepcnt = 1, int keepintvl = 2 );
bool isSetLinger();
bool isSetLinger() const;
void forceDisconnect(); // disconnect() без ожидания (с отключением SO_LINGER)
/*!
......@@ -58,7 +58,8 @@ class UTCPStream:
ssize_t writeData( const void* buf, size_t len, timeout_t t = 0 );
ssize_t readData( void* buf, size_t len, char separator = 0, timeout_t t = 0 );
int getSocket();
int getSocket() const;
timeout_t getTimeout() const;
protected:
......
......@@ -565,7 +565,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
// ДЛЯ ТОГО ЧТОБЫ НЕ ЖДАТЬ ПРОДОЛЖЕНИЯ БЕЗКОНЕЧНО СБРАСЫВАЕМ TIMEOUT
setChannelTimeout(10); // 10 msec
// setChannelTimeout(10); // 10 msec
// Получаем остальную часть сообщения
size_t rlen = getNextData((unsigned char*)(rbuf.data), rbuf.dlen);
......
......@@ -56,11 +56,16 @@ size_t ModbusTCPMaster::getNextData( unsigned char* buf, size_t len )
// -------------------------------------------------------------------------
void ModbusTCPMaster::setChannelTimeout( timeout_t msec )
{
if( tcp )
{
tcp->setTimeout(msec);
tcp->setKeepAliveParams((msec > 1000 ? msec / 1000 : 1));
}
if( !tcp )
return;
timeout_t old = tcp->getTimeout();
if( old == msec )
return;
tcp->setTimeout(msec);
tcp->setKeepAliveParams((msec > 1000 ? msec / 1000 : 1));
}
// -------------------------------------------------------------------------
mbErrCode ModbusTCPMaster::sendData( unsigned char* buf, size_t len )
......
......@@ -42,7 +42,7 @@ bool UTCPStream::setKeepAliveParams(timeout_t timeout_sec, int keepcnt, int keep
return UTCPCore::setKeepAliveParams(so, timeout_sec, keepcnt, keepintvl);
}
// -------------------------------------------------------------------------
bool UTCPStream::isSetLinger()
bool UTCPStream::isSetLinger() const
{
return Socket::flags.linger;
}
......@@ -70,11 +70,16 @@ ssize_t UTCPStream::readData(void* buf, size_t len, char separator, timeout_t t)
return TCPStream::readData(buf, len, separator, t);
}
// -------------------------------------------------------------------------
int UTCPStream::getSocket()
int UTCPStream::getSocket() const
{
return TCPStream::so;
}
// -------------------------------------------------------------------------
timeout_t UTCPStream::getTimeout() const
{
return TCPStream::timeout;
}
// -------------------------------------------------------------------------
void UTCPStream::create( const std::string& hname, int port, bool throwflag, timeout_t t )
{
family = ost::Socket::IPV4;
......
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