From aa4f66c5782d38615d6f6177ea27526ceb23a7c3 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Thu, 11 Mar 2021 15:16:43 +0800 Subject: [PATCH] add macro server_expect_body_length etc. --- src/sf_proto.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/sf_proto.h b/src/sf_proto.h index d447111..6fc5e81 100644 --- a/src/sf_proto.h +++ b/src/sf_proto.h @@ -249,7 +249,7 @@ static inline void sf_log_network_error_ex1(SFResponseInfo *response, #define sf_log_network_error_for_delete(response, \ conn, result, enoent_log_level) \ - sf_log_network_error_ex(response, conn, result, \ + sf_log_network_error_ex(response, conn, result, \ (result == SF_RETRIABLE_ERROR_CHANNEL_INVALID) ? \ LOG_DEBUG : ((result == ENOENT) ? enoent_log_level : LOG_ERR)) @@ -309,6 +309,23 @@ static inline int sf_server_check_body_length( body_length, max_body_length); } +#define server_expect_body_length(task, expect_body_len) \ + sf_server_expect_body_length(&RESPONSE, REQUEST.header.body_len, \ + expect_body_len) + +#define server_check_min_body_length(task, min_body_length) \ + sf_server_check_min_body_length(&RESPONSE, REQUEST.header.body_len, \ + min_body_length) + +#define server_check_max_body_length(task, max_body_length) \ + sf_server_check_max_body_length(&RESPONSE, REQUEST.header.body_len, \ + max_body_length) + +#define server_check_body_length(task, min_body_length, max_body_length) \ + sf_server_check_body_length(&RESPONSE, REQUEST.header.body_len, \ + min_body_length, max_body_length) + + int sf_check_response(ConnectionInfo *conn, SFResponseInfo *response, const int network_timeout, const unsigned char expect_cmd); @@ -415,6 +432,7 @@ int sf_proto_get_leader(ConnectionInfo *conn, const int network_timeout, SFClientServerEntry *leader); + #define SF_CLIENT_RELEASE_CONNECTION(cm, conn, result) \ do { \ if (SF_FORCE_CLOSE_CONNECTION_ERROR(result)) { \ @@ -424,7 +442,6 @@ int sf_proto_get_leader(ConnectionInfo *conn, } \ } while (0) - #ifdef __cplusplus } #endif