avoid rpc_timeout overflow

This commit is contained in:
liucc1997
2024-07-31 11:18:53 +00:00
committed by ob-robot
parent f240eab9bb
commit 91a65f0b3b
2 changed files with 18 additions and 3 deletions

View File

@ -141,6 +141,11 @@ public:
} }
{ {
lib::Thread::RpcGuard guard(addr, pcode); 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))) { if (OB_FAIL(rpc_encode_req(proxy, pool, pcode, args, opts, req, req_sz, false))) {
RPC_LOG(WARN, "rpc encode req fail", K(ret)); RPC_LOG(WARN, "rpc encode req fail", K(ret));
} else if(OB_FAIL(check_blacklist(addr))) { } else if(OB_FAIL(check_blacklist(addr))) {
@ -149,7 +154,7 @@ public:
const pn_pkt_t pkt = { const pn_pkt_t pkt = {
req, req,
req_sz, req_sz,
start_ts + get_proxy_timeout(proxy), start_ts + relative_timeout,
static_cast<int16_t>(set.idx_of_pcode(pcode)), static_cast<int16_t>(set.idx_of_pcode(pcode)),
ObSyncRespCallback::client_cb, ObSyncRespCallback::client_cb,
&cb &cb

View File

@ -73,10 +73,15 @@ int SSHandle<pcodeStruct>::get_more(typename pcodeStruct::Response &result)
} else if(OB_FAIL(ObPocClientStub::check_blacklist(dst_))) { } else if(OB_FAIL(ObPocClientStub::check_blacklist(dst_))) {
RPC_LOG(WARN, "check_blacklist failed", K(ret)); RPC_LOG(WARN, "check_blacklist failed", K(ret));
} else { } 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 = { const pn_pkt_t pkt = {
pnio_req, pnio_req,
pnio_req_sz, pnio_req_sz,
start_ts + proxy_.timeout(), start_ts + relative_timeout,
static_cast<int16_t>(set.idx_of_pcode(pcode_)), static_cast<int16_t>(set.idx_of_pcode(pcode_)),
ObSyncRespCallback::client_cb, ObSyncRespCallback::client_cb,
&cb &cb
@ -218,10 +223,15 @@ int SSHandle<pcodeStruct>::abort()
} else if(OB_FAIL(ObPocClientStub::check_blacklist(dst_))) { } else if(OB_FAIL(ObPocClientStub::check_blacklist(dst_))) {
RPC_LOG(WARN, "check_blacklist failed", K(ret)); RPC_LOG(WARN, "check_blacklist failed", K(ret));
} else { } 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 = { const pn_pkt_t pkt = {
pnio_req, pnio_req,
pnio_req_sz, pnio_req_sz,
start_ts + proxy_.timeout(), start_ts + relative_timeout,
static_cast<int16_t>(set.idx_of_pcode(pcode_)), static_cast<int16_t>(set.idx_of_pcode(pcode_)),
ObSyncRespCallback::client_cb, ObSyncRespCallback::client_cb,
&cb &cb