add macro SF_NET_RETRY_CHECK_AND_SLEEP

connection_manager
YuQing 2020-09-12 15:42:22 +08:00
parent f18626b229
commit cabb6a897c
2 changed files with 15 additions and 1 deletions

View File

@ -101,6 +101,19 @@ static inline const char *sf_get_read_rule_caption(
!((SF_IS_RETRIABLE_ERROR(result) && ((retry_times > 0 && \ !((SF_IS_RETRIABLE_ERROR(result) && ((retry_times > 0 && \
counter <= retry_times) || (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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -35,7 +35,8 @@
#define SF_RETRIABLE_ERROR_NO_SERVER 9901 //no server available #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_MASTER 9902 //i am not master
#define SF_RETRIABLE_ERROR_NOT_ACTIVE 9903 //i am not active #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) \ #define SF_IS_RETRIABLE_ERROR(code) \
((code >= SF_RETRIABLE_ERROR_MIN && code <= SF_RETRIABLE_ERROR_MAX) || \ ((code >= SF_RETRIABLE_ERROR_MIN && code <= SF_RETRIABLE_ERROR_MAX) || \