Merge pull request #12215 from taosdata/fix/invaldFqdn

fix(rpc): fix invalide fqdn
This commit is contained in:
Yihao Deng 2022-05-07 19:11:55 +08:00 committed by GitHub
commit ba7bd35a39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -850,7 +850,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
}
}
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
tError("failed to bind, reason: %s", terrstr());
terrno = TAOS_SYSTEM_ERROR(errno);
tError("invalid ip/port, reason: %s", terrstr());
goto End;
}
if (false == addHandleToAcceptloop(srv)) {

View File

@ -669,7 +669,7 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
if (taosSetSockOpt(pSocket, SOL_SOCKET, SO_REUSEADDR, (void *)&reuse, sizeof(reuse)) < 0) {
// printf("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
taosCloseSocket(&pSocket);
return NULL;
return false;
}
/* bind socket to server address */
if (bind(pSocket->fd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {
@ -677,6 +677,11 @@ bool taosValidIpAndPort(uint32_t ip, uint16_t port) {
taosCloseSocket(&pSocket);
return false;
}
if (listen(pSocket->fd, 1024) < 0) {
// printf("listen tcp server socket failed, 0x%x:%hu(%s)", ip, port, strerror(errno));
taosCloseSocket(&pSocket);
return false;
}
taosCloseSocket(&pSocket);
return true;
}