From 1f95bdf89bf0ade8109e8d8744505ce3f1b76d55 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Thu, 7 Jan 2021 15:40:23 +0800 Subject: [PATCH] call sf_localize_errno in sf_proto_extract_header --- src/sf_proto.h | 4 +++- src/sf_util.h | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/sf_proto.h b/src/sf_proto.h index 06fa7cf..07073b8 100644 --- a/src/sf_proto.h +++ b/src/sf_proto.h @@ -243,7 +243,6 @@ static inline int sf_send_and_check_response_header(ConnectionInfo *conn, return result; } - if ((result=sf_check_response(conn, response, network_timeout, expect_cmd)) != 0) { @@ -291,6 +290,9 @@ static inline void sf_proto_extract_header(SFCommonProtoHeader *header_proto, header_info->body_len = buff2int(header_proto->body_len); header_info->flags = buff2short(header_proto->flags); header_info->status = buff2short(header_proto->status); + if (header_info->status > 255) { + header_info->status = sf_localize_errno(header_info->status); + } } static inline int sf_active_test(ConnectionInfo *conn, diff --git a/src/sf_util.h b/src/sf_util.h index 765d6a5..42fed5b 100644 --- a/src/sf_util.h +++ b/src/sf_util.h @@ -104,6 +104,20 @@ static inline int sf_unify_errno(const int errnum) } } +static inline int sf_localize_errno(const int errnum) +{ + switch (errnum) { + case SF_ERROR_EINVAL: + return EINVAL; + case SF_ERROR_EAGAIN: + return EAGAIN; + case SF_ERROR_EOVERFLOW: + return EOVERFLOW; + default: + return errnum; + } +} + const char *sf_strerror(const int errnum); #ifdef __cplusplus