From cabb6a897c4aceef9cc2884cd2cc2f0466a8b1a1 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sat, 12 Sep 2020 15:42:22 +0800 Subject: [PATCH] add macro SF_NET_RETRY_CHECK_AND_SLEEP --- src/sf_configs.h | 13 +++++++++++++ src/sf_define.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/sf_configs.h b/src/sf_configs.h index b3569f6..9d18b52 100644 --- a/src/sf_configs.h +++ b/src/sf_configs.h @@ -101,6 +101,19 @@ static inline const char *sf_get_read_rule_caption( !((SF_IS_RETRIABLE_ERROR(result) && ((retry_times > 0 && \ counter <= retry_times) || (retry_times < 0)))) +#define SF_NET_RETRY_CHECK_AND_SLEEP(net_retry_ctx, \ + retry_times, counter, result) \ + if (SF_NET_RETRY_FINISHED(retry_times, counter, result)) { \ + break; \ + } \ + do { \ + sf_calc_next_retry_interval(&net_retry_ctx); \ + if (net_retry_ctx.interval_ms > 0) { \ + fc_sleep_ms(net_retry_ctx.interval_ms); \ + } \ + } while (0) + + #ifdef __cplusplus } #endif diff --git a/src/sf_define.h b/src/sf_define.h index 48debca..9c68265 100644 --- a/src/sf_define.h +++ b/src/sf_define.h @@ -35,7 +35,8 @@ #define SF_RETRIABLE_ERROR_NO_SERVER 9901 //no server available #define SF_RETRIABLE_ERROR_NOT_MASTER 9902 //i am not master #define SF_RETRIABLE_ERROR_NOT_ACTIVE 9903 //i am not active -#define SF_RETRIABLE_ERROR_CHANNEL_INVALID 9904 //client should re-setup channel +#define SF_RETRIABLE_ERROR_NO_CHANNEL 9904 +#define SF_RETRIABLE_ERROR_CHANNEL_INVALID 9905 //client should re-setup channel #define SF_IS_RETRIABLE_ERROR(code) \ ((code >= SF_RETRIABLE_ERROR_MIN && code <= SF_RETRIABLE_ERROR_MAX) || \