aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/aws-c-io/source/retry_strategy.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-05-11 12:12:06 +0300
committerthegeorg <thegeorg@yandex-team.ru>2022-05-11 12:12:06 +0300
commit62f93da087b2fec0f89979fd11ac4d754ca36253 (patch)
tree67bf8ceb55e2d079f3575f9a7373584ad407d2a5 /contrib/restricted/aws/aws-c-io/source/retry_strategy.c
parent8d55620139d4309265409767f873ba83fe046418 (diff)
downloadydb-62f93da087b2fec0f89979fd11ac4d754ca36253.tar.gz
Update aws-c-common and aws-c-io
* Update `contrib/restricted/aws/aws-c-io` to 0.11.0 * Backport cJSON symbol renaming logic from aws-sdk-cpp upstream ref:396829235a01ed34888651ee38ebd76c95510d6b
Diffstat (limited to 'contrib/restricted/aws/aws-c-io/source/retry_strategy.c')
-rw-r--r--contrib/restricted/aws/aws-c-io/source/retry_strategy.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/contrib/restricted/aws/aws-c-io/source/retry_strategy.c b/contrib/restricted/aws/aws-c-io/source/retry_strategy.c
index 69d444482b..ff1288d142 100644
--- a/contrib/restricted/aws/aws-c-io/source/retry_strategy.c
+++ b/contrib/restricted/aws/aws-c-io/source/retry_strategy.c
@@ -9,10 +9,12 @@ void aws_retry_strategy_acquire(struct aws_retry_strategy *retry_strategy) {
}
void aws_retry_strategy_release(struct aws_retry_strategy *retry_strategy) {
- size_t ref_count = aws_atomic_fetch_sub_explicit(&retry_strategy->ref_count, 1, aws_memory_order_seq_cst);
+ if (retry_strategy) {
+ size_t ref_count = aws_atomic_fetch_sub_explicit(&retry_strategy->ref_count, 1, aws_memory_order_seq_cst);
- if (ref_count == 1) {
- retry_strategy->vtable->destroy(retry_strategy);
+ if (ref_count == 1) {
+ retry_strategy->vtable->destroy(retry_strategy);
+ }
}
}
@@ -39,7 +41,7 @@ int aws_retry_strategy_schedule_retry(
return token->retry_strategy->vtable->schedule_retry(token, error_type, retry_ready, user_data);
}
-int aws_retry_strategy_token_record_success(struct aws_retry_token *token) {
+int aws_retry_token_record_success(struct aws_retry_token *token) {
AWS_PRECONDITION(token);
AWS_PRECONDITION(token->retry_strategy);
AWS_PRECONDITION(token->retry_strategy->vtable->record_success);
@@ -47,11 +49,19 @@ int aws_retry_strategy_token_record_success(struct aws_retry_token *token) {
return token->retry_strategy->vtable->record_success(token);
}
-void aws_retry_strategy_release_retry_token(struct aws_retry_token *token) {
+void aws_retry_token_acquire(struct aws_retry_token *token) {
+ aws_atomic_fetch_add_explicit(&token->ref_count, 1u, aws_memory_order_relaxed);
+}
+
+void aws_retry_token_release(struct aws_retry_token *token) {
if (token) {
AWS_PRECONDITION(token->retry_strategy);
AWS_PRECONDITION(token->retry_strategy->vtable->release_token);
- token->retry_strategy->vtable->release_token(token);
+ size_t prev_count = aws_atomic_fetch_sub_explicit(&token->ref_count, 1u, aws_memory_order_seq_cst);
+
+ if (prev_count == 1u) {
+ token->retry_strategy->vtable->release_token(token);
+ }
}
}