X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fgetaddrinfo.c;h=656b9e197175240d8d379a9f85ef6b2903546236;hb=570ad4976cc3040d6879a89522d7116e440f7c72;hp=a815e3334147025de2dae8a26353f49cf358ec79;hpb=4c7509d1e7e847b0d81af123f630756df0b265b4;p=pazpar2-moved-to-github.git diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c index a815e33..656b9e1 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 @@ -69,7 +69,7 @@ static void perform_getaddrinfo(struct work *w) { struct addrinfo hints, *res; char host[512], *cp; - char *port = 0; + char *port = "210"; int error; hints.ai_flags = 0; @@ -81,14 +81,27 @@ static void perform_getaddrinfo(struct work *w) hints.ai_canonname = NULL; hints.ai_next = NULL; - strncpy(host, w->hostport, sizeof(host)-1); + if (!strncmp(w->hostport, "http://", 7)) + { + port = "80"; + strncpy(host, w->hostport + 7, sizeof(host)-1); + } + else if (!strncmp(w->hostport, "https://", 8)) + { + port = "443"; + strncpy(host, w->hostport + 8, sizeof(host)-1); + } + else + { + strncpy(host, w->hostport, sizeof(host)-1); + } host[sizeof(host)-1] = 0; if ((cp = strrchr(host, ':'))) { *cp = '\0'; port = cp + 1; } - error = getaddrinfo(host, port ? port : "210", &hints, &res); + error = getaddrinfo(host, port, &hints, &res); if (error) { yaz_log(YLOG_WARN, "Failed to resolve %s: %s", @@ -177,7 +190,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;