2018-03-28 14:07:28 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Poco/Net/StreamSocket.h>
|
2018-09-28 14:53:20 +00:00
|
|
|
#include <Poco/Timespan.h>
|
2018-03-28 14:07:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2018-09-28 14:53:20 +00:00
|
|
|
/// Temporarily overrides socket send/receive timeouts and reset them back into destructor
|
2018-04-04 19:44:28 +00:00
|
|
|
/// If "limit_max_timeout" is true, timeouts could be only decreased (maxed by previous value).
|
2018-03-28 14:07:28 +00:00
|
|
|
struct TimeoutSetter
|
|
|
|
{
|
2018-09-28 14:53:20 +00:00
|
|
|
TimeoutSetter(Poco::Net::StreamSocket & socket_,
|
|
|
|
const Poco::Timespan & send_timeout_,
|
|
|
|
const Poco::Timespan & receive_timeout_,
|
|
|
|
bool limit_max_timeout = false);
|
2018-03-28 14:07:28 +00:00
|
|
|
|
2018-09-28 14:53:20 +00:00
|
|
|
TimeoutSetter(Poco::Net::StreamSocket & socket_, const Poco::Timespan & timeout_, bool limit_max_timeout = false);
|
2018-03-28 14:07:28 +00:00
|
|
|
|
2018-09-28 14:53:20 +00:00
|
|
|
~TimeoutSetter();
|
2018-03-28 14:07:28 +00:00
|
|
|
|
|
|
|
Poco::Net::StreamSocket & socket;
|
|
|
|
|
|
|
|
Poco::Timespan send_timeout;
|
2018-09-28 14:53:20 +00:00
|
|
|
Poco::Timespan receive_timeout;
|
2018-03-28 14:07:28 +00:00
|
|
|
|
|
|
|
Poco::Timespan old_send_timeout;
|
|
|
|
Poco::Timespan old_receive_timeout;
|
|
|
|
};
|
|
|
|
}
|