From 50802193c013bf79411111cf393b3aafa5ad2dc5 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Thu, 29 Jan 2015 21:53:08 +0200 Subject: geoip: Fix update failing I have no enough arguments for this fix but it fixes the failing of geoip updating. Seems "shutdown(..)" closes socket too early. So shutdown(...) is removed and added "Connection: close" http header which says http server to close connection after response will be sent. Signed-off-by: Vadim Kochan Signed-off-by: Daniel Borkmann --- geoip.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/geoip.c b/geoip.c index 0d5a4ed..3def442 100644 --- a/geoip.c +++ b/geoip.c @@ -162,7 +162,9 @@ static int geoip_get_database(const char *host, int which) size_t lenl = strlen("Content-Length: "); size_t lent = strlen("HTTP/1.1 200 OK"); size_t lenc = strlen("\r\n\r\n"); - + const char *http_req_fmt = "GET %s%s HTTP/1.1\n" + "Connection: close\n" + "Host: %s\r\n\r\n"; again: found = good = 0; ptr = NULL; @@ -172,7 +174,7 @@ again: if (sock < 0) return -EIO; - slprintf(raw, sizeof(raw), "GET %s%s HTTP/1.1\nHost: %s\r\n\r\n", + slprintf(raw, sizeof(raw), http_req_fmt, retry ? files[which].possible_prefix : "", files[which].remote, host); @@ -182,8 +184,6 @@ again: return -EIO; } - shutdown(sock, SHUT_WR); - slprintf(zfile, sizeof(zfile), "%s.gz", files[which].local); fd = open_or_die_m(zfile, O_WRONLY | O_CREAT | O_TRUNC, DEFFILEMODE); @@ -238,7 +238,7 @@ again: ptr = raw; len = ret; - } while(ret > 0); + } while (ret > 0); printf("\n"); -- cgit v1.2.3-54-g00ecf