Skip to content

Commit 69470d1

Browse files
authored
Merge pull request #47 from ClickHouse/backport_artpaul_pr_112
Cherry-pick artpaul/clickhouse-cpp#112
2 parents 41dd02a + 4f8e8bf commit 69470d1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

clickhouse/client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Client::Impl::Impl(const ClientOptions& opts)
173173
{
174174
// TODO: throw on big-endianness of platform
175175

176-
for (int i = 0; ; ) {
176+
for (unsigned int i = 0; ; ) {
177177
try {
178178
ResetConnection();
179179
break;
@@ -731,7 +731,7 @@ bool Client::Impl::ReceiveHello() {
731731
}
732732

733733
void Client::Impl::RetryGuard(std::function<void()> func) {
734-
for (int i = 0; i <= options_.send_retries; ++i) {
734+
for (unsigned int i = 0; ; ++i) {
735735
try {
736736
func();
737737
return;
@@ -745,7 +745,7 @@ void Client::Impl::RetryGuard(std::function<void()> func) {
745745
ok = false;
746746
}
747747

748-
if (!ok) {
748+
if (!ok && i == options_.send_retries) {
749749
throw;
750750
}
751751
}

clickhouse/client.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct ClientOptions {
4040
/// Hostname of the server.
4141
DECLARE_FIELD(host, std::string, SetHost, std::string());
4242
/// Service port.
43-
DECLARE_FIELD(port, int, SetPort, 9000);
43+
DECLARE_FIELD(port, unsigned int, SetPort, 9000);
4444

4545
/// Default database.
4646
DECLARE_FIELD(default_database, std::string, SetDefaultDatabase, "default");
@@ -57,7 +57,7 @@ struct ClientOptions {
5757
/// Ping server every time before execute any query.
5858
DECLARE_FIELD(ping_before_query, bool, SetPingBeforeQuery, false);
5959
/// Count of retry to send request to server.
60-
DECLARE_FIELD(send_retries, int, SetSendRetries, 1);
60+
DECLARE_FIELD(send_retries, unsigned int, SetSendRetries, 1);
6161
/// Amount of time to wait before next retry.
6262
DECLARE_FIELD(retry_timeout, std::chrono::seconds, SetRetryTimeout, std::chrono::seconds(5));
6363

@@ -68,7 +68,7 @@ struct ClientOptions {
6868
DECLARE_FIELD(tcp_keepalive, bool, TcpKeepAlive, false);
6969
DECLARE_FIELD(tcp_keepalive_idle, std::chrono::seconds, SetTcpKeepAliveIdle, std::chrono::seconds(60));
7070
DECLARE_FIELD(tcp_keepalive_intvl, std::chrono::seconds, SetTcpKeepAliveInterval, std::chrono::seconds(5));
71-
DECLARE_FIELD(tcp_keepalive_cnt, int, SetTcpKeepAliveCount, 3);
71+
DECLARE_FIELD(tcp_keepalive_cnt, unsigned int, SetTcpKeepAliveCount, 3);
7272

7373
#undef DECLARE_FIELD
7474
};

0 commit comments

Comments
 (0)