Kouhei Sutou
null+****@clear*****
Mon Nov 5 22:26:28 JST 2012
Kouhei Sutou 2012-11-05 22:26:28 +0900 (Mon, 05 Nov 2012) New Revision: 10c9cd0b5a8aa50fb474e0e5669553ccc2aa51e7 https://github.com/groonga/groonga/commit/10c9cd0b5a8aa50fb474e0e5669553ccc2aa51e7 Log: Ignore getaddrinfo() error It is not critical. It just check whether the hostname can be resolved for detecting the default hostanme. Modified files: src/groonga.c Modified: src/groonga.c (+17 -19) =================================================================== --- src/groonga.c 2012-11-05 22:23:01 +0900 (d811200) +++ src/groonga.c 2012-11-05 22:26:28 +0900 (5627134) @@ -1779,26 +1779,24 @@ static void init_default_hostname(void) { static char hostname[HOST_NAME_MAX + 1]; + int error_code; + struct addrinfo hints, *result; + hostname[HOST_NAME_MAX] = '\0'; - if (gethostname(hostname, HOST_NAME_MAX)) { - fprintf(stderr, "gethostname failed: %s\n", strerror(errno)); - } else { - int error_code; - struct addrinfo hints, *result; - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_addr = NULL; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - error_code = getaddrinfo(hostname, NULL, &hints, &result); - if (error_code) { - fprintf(stderr, "getaddrinfo failed: %s\n", gai_strerror(error_code)); - } else { - freeaddrinfo(result); - default_hostname = hostname; - } - } + if (gethostname(hostname, HOST_NAME_MAX) == -1) + return; + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_addr = NULL; + hints.ai_canonname = NULL; + hints.ai_next = NULL; + if (getaddrinfo(hostname, NULL, &hints, &result) != 0) + return; + freeaddrinfo(result); + + default_hostname = hostname; } static void -------------- next part -------------- HTML����������������������������...다운로드