osTimer
This commit is contained in:
parent
92171e080e
commit
661a170a9b
|
@ -120,7 +120,12 @@ int32_t taosReadFromSocket(TdSocketPtr pSocket, void *buf, int32_t len, int32_t
|
||||||
|
|
||||||
int32_t taosCloseSocketNoCheck1(SocketFd fd) {
|
int32_t taosCloseSocketNoCheck1(SocketFd fd) {
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
return closesocket(fd);
|
int ret = closesocket(fd);
|
||||||
|
if (ret == SOCKET_ERROR) {
|
||||||
|
int errorCode = WSAGetLastError();
|
||||||
|
return terrno = TAOS_SYSTEM_WINSOCKET_ERROR(errorCode);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
#else
|
#else
|
||||||
int32_t code = close(fd);
|
int32_t code = close(fd);
|
||||||
if (-1 == code) {
|
if (-1 == code) {
|
||||||
|
@ -770,10 +775,7 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
||||||
|
|
||||||
TdSocketPtr pSocket = (TdSocketPtr)taosMemoryMalloc(sizeof(TdSocket));
|
TdSocketPtr pSocket = (TdSocketPtr)taosMemoryMalloc(sizeof(TdSocket));
|
||||||
if (pSocket == NULL) {
|
if (pSocket == NULL) {
|
||||||
code = terrno;
|
TAOS_SKIP_ERROR(taosCloseSocketNoCheck1(fd));
|
||||||
(void)taosCloseSocketNoCheck1(fd);
|
|
||||||
terrno = code;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pSocket->refId = 0;
|
pSocket->refId = 0;
|
||||||
|
@ -782,22 +784,18 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
|
||||||
/* set REUSEADDR option, so the portnumber can be re-used */
|
/* set REUSEADDR option, so the portnumber can be re-used */
|
||||||
reuse = 1;
|
reuse = 1;
|
||||||
if (taosSetSockOpt(pSocket, SOL_SOCKET, SO_REUSEADDR, (void *)&reuse, sizeof(reuse)) < 0) {
|
if (taosSetSockOpt(pSocket, SOL_SOCKET, SO_REUSEADDR, (void *)&reuse, sizeof(reuse)) < 0) {
|
||||||
code = terrno;
|
TAOS_SKIP_ERROR(taosCloseSocket(&pSocket));
|
||||||
(void)taosCloseSocket(&pSocket);
|
|
||||||
terrno = code;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bind socket to server address */
|
/* bind socket to server address */
|
||||||
if (-1 == bind(pSocket->fd, (struct sockaddr *)&serverAdd, sizeof(serverAdd))) {
|
if (-1 == bind(pSocket->fd, (struct sockaddr *)&serverAdd, sizeof(serverAdd))) {
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
(void)taosCloseSocket(&pSocket);
|
TAOS_SKIP_ERROR(taosCloseSocket(&pSocket));
|
||||||
terrno = code;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosCloseSocket(&pSocket);
|
TAOS_SKIP_ERROR(taosCloseSocket(&pSocket));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1160,9 +1158,8 @@ int32_t taosCreateSocketWithTimeout(uint32_t timeout) {
|
||||||
#else // Linux like systems
|
#else // Linux like systems
|
||||||
uint32_t conn_timeout_ms = timeout;
|
uint32_t conn_timeout_ms = timeout;
|
||||||
if (-1 == setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) {
|
if (-1 == setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, (char *)&conn_timeout_ms, sizeof(conn_timeout_ms))) {
|
||||||
int32_t code = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
(void)taosCloseSocketNoCheck1(fd);
|
TAOS_SKIP_ERROR(taosCloseSocketNoCheck1(fd));
|
||||||
terrno = code;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -80,7 +80,7 @@ void taos_block_sigalrm(void) {
|
||||||
|
|
||||||
static void taosDeleteTimer(void *tharg) {
|
static void taosDeleteTimer(void *tharg) {
|
||||||
timer_t *pTimer = tharg;
|
timer_t *pTimer = tharg;
|
||||||
(void)timer_delete(*pTimer);
|
TAOS_SKIP_ERROR(timer_delete(*pTimer));
|
||||||
}
|
}
|
||||||
|
|
||||||
static TdThread timerThread;
|
static TdThread timerThread;
|
||||||
|
|
Loading…
Reference in New Issue