add function is_network_error

pull/37/head
YuQing 2020-02-09 17:17:37 +08:00
parent 798244cc1b
commit d6b0f1b0c4
2 changed files with 25 additions and 1 deletions

View File

@ -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 test file src/tests/test_pthread_lock.c
* add uniq_skiplist.[hc] * add uniq_skiplist.[hc]
* add function split_string_ex * add function split_string_ex
* fast_mblock.[hc]: add init_args for init_func * fast_mblock.[hc]: add init_args for init_func
* struct fast_task_info add field: nio_stage * struct fast_task_info add field: nio_stage
* add function fc_memrchr * add function fc_memrchr
* add function is_network_error
Version 1.43 2019-12-25 Version 1.43 2019-12-25
* replace function call system to getExecResult, * replace function call system to getExecResult,

View File

@ -579,6 +579,29 @@ static inline void tcp_dont_try_again_when_interrupt()
tcp_set_try_again_when_interrupt(false); 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 #ifdef __cplusplus
} }
#endif #endif