X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fgetaddrinfo.c;h=2222562afc5032ad3b2ee21d52d554952d210c6b;hb=ff0f1523c1436f4b2f0b334a53e0fbaba1b9ae84;hp=1b09ad34e5e98006c51a94ae7758af43a120710d;hpb=30b568091548ef97e199380a904f4fbcc5199156;p=pazpar2-moved-to-github.git diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c index 1b09ad3..2222562 100644 --- a/src/getaddrinfo.c +++ b/src/getaddrinfo.c @@ -1,5 +1,5 @@ /* This file is part of Pazpar2. - Copyright (C) 2006-2013 Index Data + Copyright (C) Index Data Pazpar2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -65,11 +65,10 @@ struct work { static int log_level = YLOG_LOG; -void perform_getaddrinfo(struct work *w) +static void perform_getaddrinfo(struct work *w) { struct addrinfo hints, *res; char host[512], *cp; - char portbuf[512]; // very big ports char *port = 0; int error; @@ -87,8 +86,7 @@ void perform_getaddrinfo(struct work *w) if ((cp = strrchr(host, ':'))) { *cp = '\0'; - port = portbuf; - strncpy(port, cp + 1, sizeof(port)); + port = cp + 1; } error = getaddrinfo(host, port ? port : "210", &hints, &res); if (error) @@ -98,13 +96,14 @@ void perform_getaddrinfo(struct work *w) } else { + char n_host[512]; if (getnameinfo((struct sockaddr *) res->ai_addr, res->ai_addrlen, - host, sizeof(host)-1, + n_host, sizeof(n_host)-1, 0, 0, NI_NUMERICHOST) == 0) { - w->ipport = xmalloc(strlen(host) + (port ? strlen(port) : 0) + 2); - strcpy(w->ipport, host); + w->ipport = xmalloc(strlen(n_host) + (port ? strlen(port) : 0) + 2); + strcpy(w->ipport, n_host); if (port) { strcat(w->ipport, ":"); @@ -178,7 +177,7 @@ static void getaddrinfo_start(iochan_man_t iochan_man) int host_getaddrinfo(struct host *host, iochan_man_t iochan_man) { struct work *w = xmalloc(sizeof(*w)); - int use_thread = 0; /* =0 to disable threading entirely */ + int use_thread = 1; /* =0 to disable threading entirely */ w->hostport = host->tproxy ? host->tproxy : host->proxy; w->ipport = 0;