aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/c-ares
diff options
context:
space:
mode:
authormax42 <max42@yandex-team.ru>2022-02-10 16:47:51 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:51 +0300
commit9988f7c537b40605e1a0aaae2977d5f540425b83 (patch)
treea4f3497f66e2dcd82d0f7ae7573acd1320d1bc78 /contrib/libs/c-ares
parent0a579de32b745908473b2cea7c5cd5540bc801f0 (diff)
downloadydb-9988f7c537b40605e1a0aaae2977d5f540425b83.tar.gz
Restoring authorship annotation for <max42@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/c-ares')
-rw-r--r--contrib/libs/c-ares/ares.h10
-rw-r--r--contrib/libs/c-ares/ares_init.c54
-rw-r--r--contrib/libs/c-ares/ares_private.h6
-rw-r--r--contrib/libs/c-ares/ares_process.c42
-rw-r--r--contrib/libs/c-ares/test/ares-test-init.cc52
5 files changed, 82 insertions, 82 deletions
diff --git a/contrib/libs/c-ares/ares.h b/contrib/libs/c-ares/ares.h
index 3f8a6954d0..48ebd95f6f 100644
--- a/contrib/libs/c-ares/ares.h
+++ b/contrib/libs/c-ares/ares.h
@@ -168,8 +168,8 @@ extern "C" {
#define ARES_OPT_EDNSPSZ (1 << 15)
#define ARES_OPT_NOROTATE (1 << 16)
#define ARES_OPT_RESOLVCONF (1 << 17)
-#define ARES_OPT_MAXTIMEOUTMS (1 << 18)
-#define ARES_OPT_JITTER (1 << 19)
+#define ARES_OPT_MAXTIMEOUTMS (1 << 18)
+#define ARES_OPT_JITTER (1 << 19)
/* Nameinfo flag values */
#define ARES_NI_NOFQDN (1 << 0)
@@ -262,9 +262,9 @@ struct apattern;
struct ares_options {
int flags;
int timeout; /* in seconds or milliseconds, depending on options */
- int maxtimeout; /* in milliseconds */
- int jitter; /* in .001 */
- unsigned int jitter_rand_seed;
+ int maxtimeout; /* in milliseconds */
+ int jitter; /* in .001 */
+ unsigned int jitter_rand_seed;
int tries;
int ndots;
unsigned short udp_port;
diff --git a/contrib/libs/c-ares/ares_init.c b/contrib/libs/c-ares/ares_init.c
index e06265c6a2..29863f96e4 100644
--- a/contrib/libs/c-ares/ares_init.c
+++ b/contrib/libs/c-ares/ares_init.c
@@ -145,9 +145,9 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
*/
channel->flags = -1;
channel->timeout = -1;
- channel->maxtimeout = -1;
- channel->jitter = -1;
- channel->jitter_rand_state = -1;
+ channel->maxtimeout = -1;
+ channel->jitter = -1;
+ channel->jitter_rand_state = -1;
channel->tries = -1;
channel->ndots = -1;
channel->rotate = -1;
@@ -353,8 +353,8 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
(*optmask) = (ARES_OPT_FLAGS|ARES_OPT_TRIES|ARES_OPT_NDOTS|
ARES_OPT_UDP_PORT|ARES_OPT_TCP_PORT|ARES_OPT_SOCK_STATE_CB|
ARES_OPT_SERVERS|ARES_OPT_DOMAINS|ARES_OPT_LOOKUPS|
- ARES_OPT_SORTLIST|ARES_OPT_TIMEOUTMS|ARES_OPT_MAXTIMEOUTMS|
- ARES_OPT_JITTER);
+ ARES_OPT_SORTLIST|ARES_OPT_TIMEOUTMS|ARES_OPT_MAXTIMEOUTMS|
+ ARES_OPT_JITTER);
(*optmask) |= (channel->rotate ? ARES_OPT_ROTATE : ARES_OPT_NOROTATE);
if (channel->resolvconf_path)
@@ -366,9 +366,9 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
/* We return full millisecond resolution but that's only because we don't
set the ARES_OPT_TIMEOUT anymore, only the new ARES_OPT_TIMEOUTMS */
options->timeout = channel->timeout;
- options->maxtimeout = channel->maxtimeout;
- options->jitter = channel->jitter;
- options->jitter_rand_seed = channel->jitter_rand_state;
+ options->maxtimeout = channel->maxtimeout;
+ options->jitter = channel->jitter;
+ options->jitter_rand_seed = channel->jitter_rand_state;
options->tries = channel->tries;
options->ndots = channel->ndots;
options->udp_port = ntohs(aresx_sitous(channel->udp_port));
@@ -458,13 +458,13 @@ static int init_by_options(ares_channel channel,
channel->timeout = options->timeout;
else if ((optmask & ARES_OPT_TIMEOUT) && channel->timeout == -1)
channel->timeout = options->timeout * 1000;
- if ((optmask & ARES_OPT_MAXTIMEOUTMS) && channel->maxtimeout == -1)
- channel->maxtimeout = options->maxtimeout;
- if ((optmask & ARES_OPT_JITTER) && channel->jitter == -1)
- {
- channel->jitter = options->jitter;
- channel->jitter_rand_state = options->jitter_rand_seed;
- }
+ if ((optmask & ARES_OPT_MAXTIMEOUTMS) && channel->maxtimeout == -1)
+ channel->maxtimeout = options->maxtimeout;
+ if ((optmask & ARES_OPT_JITTER) && channel->jitter == -1)
+ {
+ channel->jitter = options->jitter;
+ channel->jitter_rand_state = options->jitter_rand_seed;
+ }
if ((optmask & ARES_OPT_TRIES) && channel->tries == -1)
channel->tries = options->tries;
if ((optmask & ARES_OPT_NDOTS) && channel->ndots == -1)
@@ -2337,24 +2337,24 @@ static int set_options(ares_channel channel, const char *str)
val = try_option(p, q, "retrans:");
if (val && channel->timeout == -1)
channel->timeout = aresx_sltosi(strtol(val, NULL, 10));
- val = try_option(p, q, "timeout:");
- if (val && channel->timeout == -1)
- channel->timeout = aresx_sltosi(strtol(val, NULL, 10)) * 1000;
- val = try_option(p, q, "maxtimeout:");
- if (val && channel->maxtimeout == -1)
- channel->maxtimeout = aresx_sltosi(strtol(val, NULL, 10)) * 1000;
+ val = try_option(p, q, "timeout:");
+ if (val && channel->timeout == -1)
+ channel->timeout = aresx_sltosi(strtol(val, NULL, 10)) * 1000;
+ val = try_option(p, q, "maxtimeout:");
+ if (val && channel->maxtimeout == -1)
+ channel->maxtimeout = aresx_sltosi(strtol(val, NULL, 10)) * 1000;
val = try_option(p, q, "retry:");
if (val && channel->tries == -1)
channel->tries = aresx_sltosi(strtol(val, NULL, 10));
- val = try_option(p, q, "attempts:");
- if (val && channel->tries == -1)
- channel->tries = aresx_sltosi(strtol(val, NULL, 10));
+ val = try_option(p, q, "attempts:");
+ if (val && channel->tries == -1)
+ channel->tries = aresx_sltosi(strtol(val, NULL, 10));
val = try_option(p, q, "rotate");
if (val && channel->rotate == -1)
channel->rotate = 1;
- val = try_option(p, q, "jitter:");
- if (val && channel->jitter == -1)
- channel->jitter = aresx_sltosi(strtol(val, NULL, 10));
+ val = try_option(p, q, "jitter:");
+ if (val && channel->jitter == -1)
+ channel->jitter = aresx_sltosi(strtol(val, NULL, 10));
p = q;
while (ISSPACE(*p))
p++;
diff --git a/contrib/libs/c-ares/ares_private.h b/contrib/libs/c-ares/ares_private.h
index 3312ed1932..a7624d9710 100644
--- a/contrib/libs/c-ares/ares_private.h
+++ b/contrib/libs/c-ares/ares_private.h
@@ -267,9 +267,9 @@ struct ares_channeldata {
/* Configuration data */
int flags;
int timeout; /* in milliseconds */
- int maxtimeout; /* in milliseconds */
- int jitter; /* in .001 */
- unsigned int jitter_rand_state;
+ int maxtimeout; /* in milliseconds */
+ int jitter; /* in .001 */
+ unsigned int jitter_rand_state;
int tries;
int ndots;
int rotate; /* if true, all servers specified are used */
diff --git a/contrib/libs/c-ares/ares_process.c b/contrib/libs/c-ares/ares_process.c
index 25095d0f05..403ba57ffc 100644
--- a/contrib/libs/c-ares/ares_process.c
+++ b/contrib/libs/c-ares/ares_process.c
@@ -898,27 +898,27 @@ void ares__send_query(ares_channel channel, struct query *query,
}
}
- if (channel->maxtimeout != -1 && timeplus > channel->maxtimeout)
- timeplus = channel->maxtimeout;
-
- if (channel->jitter != -1)
- {
- int r;
- #ifdef WIN32
- /* Windows does not have rand_r function, so we use regular rand().
- * It is thread-unsafe, but it is better than nothing.
- */
- r = rand();
- #else
- r = rand_r(&channel->jitter_rand_state);
- #endif
- long long delta = (long long)(r - (RAND_MAX >> 1)) * timeplus * channel->jitter;
- delta /= RAND_MAX;
- /* Recall that jitter is expressed in .001 */
- delta /= 1000;
- timeplus += delta;
- }
-
+ if (channel->maxtimeout != -1 && timeplus > channel->maxtimeout)
+ timeplus = channel->maxtimeout;
+
+ if (channel->jitter != -1)
+ {
+ int r;
+ #ifdef WIN32
+ /* Windows does not have rand_r function, so we use regular rand().
+ * It is thread-unsafe, but it is better than nothing.
+ */
+ r = rand();
+ #else
+ r = rand_r(&channel->jitter_rand_state);
+ #endif
+ long long delta = (long long)(r - (RAND_MAX >> 1)) * timeplus * channel->jitter;
+ delta /= RAND_MAX;
+ /* Recall that jitter is expressed in .001 */
+ delta /= 1000;
+ timeplus += delta;
+ }
+
query->timeout = *now;
timeadd(&query->timeout, timeplus);
/* Keep track of queries bucketed by timeout, so we can process
diff --git a/contrib/libs/c-ares/test/ares-test-init.cc b/contrib/libs/c-ares/test/ares-test-init.cc
index 842b0e15ac..cd03fad61f 100644
--- a/contrib/libs/c-ares/test/ares-test-init.cc
+++ b/contrib/libs/c-ares/test/ares-test-init.cc
@@ -242,32 +242,32 @@ TEST_F(LibraryTest, EnvInit) {
ares_destroy(channel);
}
-TEST_F(LibraryTest, EnvInitYt) {
- ares_channel channel = nullptr;
- EnvValue v1("LOCALDOMAIN", "this.is.local");
- EnvValue v2("RES_OPTIONS", "options debug timeout:5 attempts:6");
- EXPECT_EQ(ARES_SUCCESS, ares_init(&channel));
- struct ares_options opts;
- int optmask = 0;
- ares_save_options(channel, &opts, &optmask);
- EXPECT_EQ(5000, opts.timeout);
- EXPECT_EQ(6, opts.tries);
- ares_destroy(channel);
-}
-
-TEST_F(LibraryTest, EnvInitYtTimeouts) {
- ares_channel channel = nullptr;
- EnvValue v1("LOCALDOMAIN", "this.is.local");
- EnvValue v2("RES_OPTIONS", "options debug jitter:42 maxtimeout:10");
- EXPECT_EQ(ARES_SUCCESS, ares_init(&channel));
- struct ares_options opts;
- int optmask = 0;
- ares_save_options(channel, &opts, &optmask);
- EXPECT_EQ(42, opts.jitter);
- EXPECT_EQ(10000, opts.maxtimeout);
- ares_destroy(channel);
-}
-
+TEST_F(LibraryTest, EnvInitYt) {
+ ares_channel channel = nullptr;
+ EnvValue v1("LOCALDOMAIN", "this.is.local");
+ EnvValue v2("RES_OPTIONS", "options debug timeout:5 attempts:6");
+ EXPECT_EQ(ARES_SUCCESS, ares_init(&channel));
+ struct ares_options opts;
+ int optmask = 0;
+ ares_save_options(channel, &opts, &optmask);
+ EXPECT_EQ(5000, opts.timeout);
+ EXPECT_EQ(6, opts.tries);
+ ares_destroy(channel);
+}
+
+TEST_F(LibraryTest, EnvInitYtTimeouts) {
+ ares_channel channel = nullptr;
+ EnvValue v1("LOCALDOMAIN", "this.is.local");
+ EnvValue v2("RES_OPTIONS", "options debug jitter:42 maxtimeout:10");
+ EXPECT_EQ(ARES_SUCCESS, ares_init(&channel));
+ struct ares_options opts;
+ int optmask = 0;
+ ares_save_options(channel, &opts, &optmask);
+ EXPECT_EQ(42, opts.jitter);
+ EXPECT_EQ(10000, opts.maxtimeout);
+ ares_destroy(channel);
+}
+
TEST_F(LibraryTest, EnvInitAllocFail) {
ares_channel channel;
EnvValue v1("LOCALDOMAIN", "this.is.local");