blob: 3479986d7fe4547e5c2daaf51a50d8941a874fad (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#pragma once
#include <Poco/Net/StreamSocket.h>
#include <Poco/Timespan.h>
namespace DB
{
/// Temporarily overrides socket send/receive timeouts and reset them back into destructor (or manually by calling reset method)
/// If "limit_max_timeout" is true, timeouts could be only decreased (maxed by previous value).
struct TimeoutSetter
{
TimeoutSetter(Poco::Net::StreamSocket & socket_,
Poco::Timespan send_timeout_,
Poco::Timespan receive_timeout_,
bool limit_max_timeout = false);
TimeoutSetter(Poco::Net::StreamSocket & socket_, Poco::Timespan timeout_, bool limit_max_timeout = false);
~TimeoutSetter();
/// Reset timeouts back.
void reset();
Poco::Net::StreamSocket & socket;
Poco::Timespan send_timeout;
Poco::Timespan receive_timeout;
Poco::Timespan old_send_timeout;
Poco::Timespan old_receive_timeout;
bool was_reset = false;
};
}
|