From 659be5a134b525c5127eda4794aac55b3e2d6f6c Mon Sep 17 00:00:00 2001 From: Raul Silvera Date: Wed, 4 Mar 2015 11:51:11 -0800 Subject: [PATCH] Manually resolve well-known service names --- src/core/iomgr/resolve_address_posix.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/iomgr/resolve_address_posix.c b/src/core/iomgr/resolve_address_posix.c index 989b968ae27..85085dc37d1 100644 --- a/src/core/iomgr/resolve_address_posix.c +++ b/src/core/iomgr/resolve_address_posix.c @@ -101,6 +101,21 @@ grpc_resolved_addresses *grpc_blocking_resolve_address( hints.ai_flags = AI_PASSIVE; /* for wildcard IP address */ s = getaddrinfo(host, port, &hints, &result); + if (s != 0) { + /* Retry if well-known service name is recognized */ + char *svc[][2] = { + {"http", "80"}, + {"https", "443"} + }; + int i; + for (i = 0; i < (int)(sizeof(svc) / sizeof(svc[0])); i++) { + if (!strcmp(port, svc[i][0])) { + s = getaddrinfo(host, svc[i][1], &hints, &result); + break; + } + } + } + if (s != 0) { gpr_log(GPR_ERROR, "getaddrinfo: %s", gai_strerror(s)); goto done;