From 91a65f0b3bddc7ad82b9f3ef1fb016dc5bd23f06 Mon Sep 17 00:00:00 2001 From: liucc1997 <1192520566@qq.com> Date: Wed, 31 Jul 2024 11:18:53 +0000 Subject: [PATCH] avoid rpc_timeout overflow --- deps/oblib/src/rpc/obrpc/ob_poc_rpc_proxy.h | 7 ++++++- deps/oblib/src/rpc/obrpc/ob_rpc_proxy.ipp | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/deps/oblib/src/rpc/obrpc/ob_poc_rpc_proxy.h b/deps/oblib/src/rpc/obrpc/ob_poc_rpc_proxy.h index 54aaca2bb3..19bb033105 100644 --- a/deps/oblib/src/rpc/obrpc/ob_poc_rpc_proxy.h +++ b/deps/oblib/src/rpc/obrpc/ob_poc_rpc_proxy.h @@ -141,6 +141,11 @@ public: } { lib::Thread::RpcGuard guard(addr, pcode); + int64_t relative_timeout = get_proxy_timeout(proxy); + if (relative_timeout > INT64_MAX/2) { + RPC_LOG_RET(WARN, OB_INVALID_ARGUMENT, "rpc timeout is too large", K(relative_timeout), K(pcode)); + relative_timeout = INT64_MAX/2; + } if (OB_FAIL(rpc_encode_req(proxy, pool, pcode, args, opts, req, req_sz, false))) { RPC_LOG(WARN, "rpc encode req fail", K(ret)); } else if(OB_FAIL(check_blacklist(addr))) { @@ -149,7 +154,7 @@ public: const pn_pkt_t pkt = { req, req_sz, - start_ts + get_proxy_timeout(proxy), + start_ts + relative_timeout, static_cast(set.idx_of_pcode(pcode)), ObSyncRespCallback::client_cb, &cb diff --git a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.ipp b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.ipp index c35b2a489b..c28221675c 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.ipp +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_proxy.ipp @@ -73,10 +73,15 @@ int SSHandle::get_more(typename pcodeStruct::Response &result) } else if(OB_FAIL(ObPocClientStub::check_blacklist(dst_))) { RPC_LOG(WARN, "check_blacklist failed", K(ret)); } else { + int64_t relative_timeout = proxy_.timeout(); + if (relative_timeout > INT64_MAX/2) { + RPC_LOG_RET(WARN, OB_INVALID_ARGUMENT, "rpc timeout is too large", K(relative_timeout), K(pcode_)); + relative_timeout = INT64_MAX/2; + } const pn_pkt_t pkt = { pnio_req, pnio_req_sz, - start_ts + proxy_.timeout(), + start_ts + relative_timeout, static_cast(set.idx_of_pcode(pcode_)), ObSyncRespCallback::client_cb, &cb @@ -218,10 +223,15 @@ int SSHandle::abort() } else if(OB_FAIL(ObPocClientStub::check_blacklist(dst_))) { RPC_LOG(WARN, "check_blacklist failed", K(ret)); } else { + int64_t relative_timeout = proxy_.timeout(); + if (relative_timeout > INT64_MAX/2) { + RPC_LOG_RET(WARN, OB_INVALID_ARGUMENT, "rpc timeout is too large", K(relative_timeout), K(pcode_)); + relative_timeout = INT64_MAX/2; + } const pn_pkt_t pkt = { pnio_req, pnio_req_sz, - start_ts + proxy_.timeout(), + start_ts + relative_timeout, static_cast(set.idx_of_pcode(pcode_)), ObSyncRespCallback::client_cb, &cb