unify errno for crossing platform
parent
0825cfc5fe
commit
c0128c0f15
|
|
@ -53,17 +53,23 @@
|
|||
#define SF_RETRIABLE_ERROR_NO_CHANNEL 9914
|
||||
#define SF_RETRIABLE_ERROR_CHANNEL_INVALID 9915 //client should re-setup channel
|
||||
|
||||
//std errno wrapper for crossing platform
|
||||
#define SF_ERROR_EINVAL 8811
|
||||
#define SF_ERROR_EAGAIN 8835
|
||||
#define SF_ERROR_EOVERFLOW 8884
|
||||
|
||||
#define SF_FORCE_CLOSE_CONNECTION_ERROR_MIN SF_RETRIABLE_ERROR_NOT_MASTER
|
||||
#define SF_FORCE_CLOSE_CONNECTION_ERROR_MAX SF_RETRIABLE_ERROR_MAX
|
||||
|
||||
#define SF_IS_RETRIABLE_ERROR(code) \
|
||||
((code >= SF_RETRIABLE_ERROR_MIN && code <= SF_RETRIABLE_ERROR_MAX) || \
|
||||
(code == EAGAIN) || is_network_error(code))
|
||||
(code == SF_ERROR_EAGAIN) || is_network_error(code))
|
||||
|
||||
#define SF_FORCE_CLOSE_CONNECTION_ERROR(code) \
|
||||
((code >= SF_FORCE_CLOSE_CONNECTION_ERROR_MIN && \
|
||||
code <= SF_FORCE_CLOSE_CONNECTION_ERROR_MAX) || \
|
||||
(result == EINVAL) || (result == EOVERFLOW) || \
|
||||
(result == SF_ERROR_EINVAL) || \
|
||||
(result == SF_ERROR_EOVERFLOW) || \
|
||||
(result != 0 && is_network_error(code)))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -183,6 +183,12 @@ const char *sf_strerror(const int errnum)
|
|||
return "idempotency channel not exist";
|
||||
case SF_RETRIABLE_ERROR_CHANNEL_INVALID:
|
||||
return "idempotency channel is invalid";
|
||||
case SF_ERROR_EINVAL:
|
||||
return STRERROR(EINVAL);
|
||||
case SF_ERROR_EAGAIN:
|
||||
return STRERROR(EAGAIN);
|
||||
case SF_ERROR_EOVERFLOW:
|
||||
return STRERROR(EOVERFLOW);
|
||||
default:
|
||||
return STRERROR(errnum);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "fastcommon/logger.h"
|
||||
#include "fastcommon/sched_thread.h"
|
||||
#include "sf_define.h"
|
||||
#include "sf_types.h"
|
||||
|
||||
#ifdef DEBUG_FLAG /*only for format check*/
|
||||
|
|
@ -89,6 +90,20 @@ static inline void sf_setup_schedule(struct log_context *pContext,
|
|||
scheduleArray->count = scheduleEntry - scheduleArray->entries;
|
||||
}
|
||||
|
||||
static inline int sf_unify_errno(const int errnum)
|
||||
{
|
||||
switch (errnum) {
|
||||
case EINVAL:
|
||||
return SF_ERROR_EINVAL;
|
||||
case EAGAIN:
|
||||
return SF_ERROR_EAGAIN;
|
||||
case EOVERFLOW:
|
||||
return SF_ERROR_EOVERFLOW;
|
||||
default:
|
||||
return errnum;
|
||||
}
|
||||
}
|
||||
|
||||
const char *sf_strerror(const int errnum);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Reference in New Issue