Add true getaddrinfo errors, but add inconsistency. - geomyidae - A small C-based gopherd. HTML git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit a8e69abfa2b38ef12bad79516bf02da7701d549c DIR parent bc06de10b6d279ef57ad0ba294610447bd2988fc HTML Author: Christoph Lohmann <20h@r-36.net> Date: Thu, 30 Aug 2018 19:07:11 +0200 Add true getaddrinfo errors, but add inconsistency. We should all move to Plan 9. Diffstat: M main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- DIR diff --git a/main.c b/main.c @@ -290,16 +290,22 @@ initsignals(void) signal(SIGPIPE, SIG_IGN); } +/* + * TODO: Move Linux and BSD to Plan 9 socket and bind handling, so we do not + * need the inconsistent return and exit on getaddrinfo. + */ int getlistenfd(struct addrinfo *hints, char *bindip, char *port) { char addstr[INET6_ADDRSTRLEN]; struct addrinfo *ai, *rp; void *sinaddr; - int on, listfd; + int on, listfd, aierr; - if (getaddrinfo(bindip, port, hints, &ai) || ai == NULL) - return -1; + if ((aierr = getaddrinfo(bindip, port, hints, &ai)) || ai == NULL) { + fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(aierr)); + exit(1); + } listfd = -1; on = 1;