From 326a684ce14f8aadb1b1fd8ffb5056084dd0c3ca Mon Sep 17 00:00:00 2001 From: dhy308 Date: Sat, 25 Feb 2023 10:59:45 +0800 Subject: [PATCH] Improve getaddress performance when no network. Issue: I68YHB Test: Build & Boot Devices Signed-off-by: dhy308 --- porting/linux/user/src/network/lookup_name.c | 3 ++- porting/linux/user/src/network/resolvconf.c | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/porting/linux/user/src/network/lookup_name.c b/porting/linux/user/src/network/lookup_name.c index 3f00d7c6..98084e22 100644 --- a/porting/linux/user/src/network/lookup_name.c +++ b/porting/linux/user/src/network/lookup_name.c @@ -193,7 +193,8 @@ static int name_from_dns_search(struct address buf[static MAXADDRS], char canon[ size_t l, dots; char *p, *z; - if (__get_resolv_conf(&conf, search, sizeof search) < 0) return -1; + int res = __get_resolv_conf(&conf, search, sizeof search); + if (res < 0) return res; /* Count dots, suppress search when >=ndots or name ends in * a dot, which is an explicit request for global scope. */ diff --git a/porting/linux/user/src/network/resolvconf.c b/porting/linux/user/src/network/resolvconf.c index 73de25fa..34669d4a 100644 --- a/porting/linux/user/src/network/resolvconf.c +++ b/porting/linux/user/src/network/resolvconf.c @@ -40,12 +40,10 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz) dlclose(handle); if (ret < 0) { DNS_CONFIG_PRINT("__get_resolv_conf OHOS_GET_CONFIG_FUNC_NAME err %d\n", ret); - goto etc_resolv_conf; + return EAI_NONAME; } int32_t timeout_second = config.timeout_ms / 1000; -#endif -#if OHOS_DNS_PROXY_BY_NETSYS netsys_conf: if (timeout_second > 0) { if (timeout_second >= 60) { -- GitLab