diff --git a/HISTORY b/HISTORY index 9f45707..e63341e 100644 --- a/HISTORY +++ b/HISTORY @@ -1,11 +1,12 @@ -Version 1.44 2020-02-08 +Version 1.44 2020-02-09 * add test file src/tests/test_pthread_lock.c * add uniq_skiplist.[hc] * add function split_string_ex * fast_mblock.[hc]: add init_args for init_func * struct fast_task_info add field: nio_stage * add function fc_memrchr + * add function is_network_error Version 1.43 2019-12-25 * replace function call system to getExecResult, diff --git a/src/sockopt.h b/src/sockopt.h index bb303e1..b4ed73c 100644 --- a/src/sockopt.h +++ b/src/sockopt.h @@ -579,6 +579,29 @@ static inline void tcp_dont_try_again_when_interrupt() tcp_set_try_again_when_interrupt(false); } +static inline bool is_network_error(const int err_no) +{ + switch (err_no) + { + case EPIPE: + case ENETDOWN: + case ENETUNREACH: + case ENETRESET: + case ECONNABORTED: + case ECONNRESET: + case ENOTCONN: + case ESHUTDOWN: + case ETIMEDOUT: + case ECONNREFUSED: + case EHOSTDOWN: + case EHOSTUNREACH: + case ENOTSOCK: + return true; + default: + return false; + } +} + #ifdef __cplusplus } #endif