skip always dns resolve when ip already exist

This commit is contained in:
fenggui321 2017-11-28 18:19:42 +08:00 committed by Dengfeng Liu
parent 13b5677154
commit 9706596099
2 changed files with 46 additions and 43 deletions

View File

@ -21,3 +21,5 @@ Thank you to all contributors:
[wenchangshou2](https://github.com/wenchangshou2)
[Lzxiangxmut](https://github.com/Lzxiangxmut)
[fenggui321](https://github.com/fenggui321)

9
src/centralserver.c Normal file → Executable file
View File

@ -462,6 +462,7 @@ _connect_auth_server(int level) {
*/
auth_server = config->auth_servers;
hostname = auth_server->authserv_hostname;
if (NULL == auth_server->last_ip){
debug(LOG_DEBUG, "Level %d: Resolving auth server [%s]", level, hostname);
h_addr = wd_gethostbyname(hostname);
if (!h_addr) {
@ -504,7 +505,9 @@ _connect_auth_server(int level) {
*/
free(ip);
}
free(h_addr);
}
}
/*
* Connect to it
*/
@ -513,9 +516,8 @@ _connect_auth_server(int level) {
their_addr.sin_port = port;
their_addr.sin_family = AF_INET;
their_addr.sin_addr = *h_addr;
inet_aton(auth_server->last_ip, &their_addr.sin_addr);
memset(&(their_addr.sin_zero), '\0', sizeof(their_addr.sin_zero));
free(h_addr);
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
debug(LOG_ERR, "Level %d: Failed to create a new SOCK_STREAM socket: %s", strerror(errno));
@ -537,7 +539,6 @@ _connect_auth_server(int level) {
mark_auth_server_bad(auth_server);
return _connect_auth_server(level); /* Yay recursion! */
}
}
}
// 0, failure; 1, success