提交 5362a173 编写于 作者: dengyihao's avatar dengyihao

add timeout to auth

上级 4e42c1c4
...@@ -89,34 +89,34 @@ int32_t taosGetCurrentAPPName(char* name, int32_t* len) { ...@@ -89,34 +89,34 @@ int32_t taosGetCurrentAPPName(char* name, int32_t* len) {
#endif #endif
#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) // #if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32))
int32_t tsem_timewait(tsem_t* sem, int64_t ms) { // int32_t tsem_timewait(tsem_t* sem, int64_t ms) {
struct timespec ts; // struct timespec ts;
taosClockGetTime(0, &ts); // taosClockGetTime(0, &ts);
ts.tv_nsec += ms * 1000000; // ts.tv_nsec += ms * 1000000;
ts.tv_sec += ts.tv_nsec / 1000000000; // ts.tv_sec += ts.tv_nsec / 1000000000;
ts.tv_nsec %= 1000000000; // ts.tv_nsec %= 1000000000;
int rc; // int rc;
while ((rc = sem_timedwait(sem, &ts)) == -1 && errno == EINTR) continue; // while ((rc = sem_timedwait(sem, &ts)) == -1 && errno == EINTR) continue;
return rc; // return rc;
/* This should have timed out */ // /* This should have timed out */
// ASSERT(errno == ETIMEDOUT); // // ASSERT(errno == ETIMEDOUT);
// ASSERT(rc != 0); // // ASSERT(rc != 0);
// GetSystemTimeAsFileTime(&ft_after); // // GetSystemTimeAsFileTime(&ft_after);
// // We specified a non-zero wait. Time must advance. // // // We specified a non-zero wait. Time must advance.
// if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime) // // if (ft_before.dwLowDateTime == ft_after.dwLowDateTime && ft_before.dwHighDateTime == ft_after.dwHighDateTime)
// { // // {
// printf("nanoseconds: %d, rc: %d, code:0x%x. before filetime: %d, %d; after filetime: %d, %d\n", // // printf("nanoseconds: %d, rc: %d, code:0x%x. before filetime: %d, %d; after filetime: %d, %d\n",
// nanosecs, rc, errno, // // nanosecs, rc, errno,
// (int)ft_before.dwLowDateTime, (int)ft_before.dwHighDateTime, // // (int)ft_before.dwLowDateTime, (int)ft_before.dwHighDateTime,
// (int)ft_after.dwLowDateTime, (int)ft_after.dwHighDateTime); // // (int)ft_after.dwLowDateTime, (int)ft_after.dwHighDateTime);
// printf("time must advance during sem_timedwait."); // // printf("time must advance during sem_timedwait.");
// return 1; // // return 1;
// } // // }
} // }
#endif // #endif
// #if defined(_TD_DARWIN_64) // #if defined(_TD_DARWIN_64)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册