提交 4e42c1c4 编写于 作者: dengyihao's avatar dengyihao

add timeout to auth

上级 f2e9c64d
...@@ -118,13 +118,13 @@ int32_t tsem_timewait(tsem_t* sem, int64_t ms) { ...@@ -118,13 +118,13 @@ int32_t tsem_timewait(tsem_t* sem, int64_t ms) {
#endif #endif
#if defined(_TD_DARWIN_64) // #if defined(_TD_DARWIN_64)
int tsem_timewait(tsem_t* psem, int64_t milis) { // int tsem_timewait(tsem_t* psem, int64_t milis) {
if (psem == NULL || *psem == NULL) return -1; // if (psem == NULL || *psem == NULL) return -1;
dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(milis * USEC_PER_SEC)); // dispatch_time_t time = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(milis * USEC_PER_SEC));
dispatch_semaphore_wait(*psem, time); // dispatch_semaphore_wait(*psem, time);
return 0; // return 0;
} // }
#endif // #endif
\ No newline at end of file \ No newline at end of file
...@@ -576,11 +576,19 @@ void rpcSendRecvWithTimeout(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pMsg, SRp ...@@ -576,11 +576,19 @@ void rpcSendRecvWithTimeout(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pMsg, SRp
int64_t rid = 0; int64_t rid = 0;
rpcSendRequest(shandle, pEpSet, pMsg, &rid); rpcSendRequest(shandle, pEpSet, pMsg, &rid);
tsem_timewait(&sem, 3 * 1000); #if defined (LINUX)
rpcCancelRequest(rid); if (tsem_timewait(&sem, 3 * 1000) == 0) {
// do nothing
} else {
rpcCancelRequest(rid);
pRsp->code = -1;
}
#else
tsem_wait(&sem);
#endif
tsem_destroy(&sem); tsem_destroy(&sem);
pRsp->code = -1;
return; return;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册