log error info when getIpaddrByName fail

pull/328/head
YuQing 2019-09-12 10:08:26 +08:00
parent 102c444ef2
commit 2df00f8900
2 changed files with 5 additions and 3 deletions

View File

@ -13,6 +13,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -108,8 +109,8 @@ static int copy_tracker_servers(TrackerServerGroup *pTrackerGroup, \
{ {
logError("file: "__FILE__", line: %d, " \ logError("file: "__FILE__", line: %d, " \
"conf file \"%s\", " \ "conf file \"%s\", " \
"host \"%s\" is invalid", \ "host \"%s\" is invalid, error info: %s", \
__LINE__, filename, szHost); __LINE__, filename, szHost, hstrerror(h_errno));
return EINVAL; return EINVAL;
} }
destServer.port = atoi(pSeperator+1); destServer.port = atoi(pSeperator+1);

View File

@ -12,6 +12,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <netdb.h>
#include <sys/types.h> #include <sys/types.h>
#include "fastcommon/sockopt.h" #include "fastcommon/sockopt.h"
#include "fastcommon/logger.h" #include "fastcommon/logger.h"
@ -122,7 +123,7 @@ int main(int argc, char *argv[])
== INADDR_NONE) == INADDR_NONE)
{ {
printf("resolve ip address of tracker server: %s " \ printf("resolve ip address of tracker server: %s " \
"fail!\n", tracker_server); "fail!, error info: %s\n", tracker_server, hstrerror(h_errno));
return 2; return 2;
} }