From: Vadim Kochan <vadi...@gmail.com> 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 <vadi...@gmail.com> --- geoip.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/geoip.c b/geoip.c index 0d5a4ed..7f4f718 100644 --- a/geoip.c +++ b/geoip.c @@ -162,6 +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"); + char *http_req_fmt = "GET %s%s HTTP/1.1\n" + "Connection: close\n" + "Host: %s\r\n\r\n"; again: found = good = 0; @@ -172,7 +175,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 +185,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 +239,7 @@ again: ptr = raw; len = ret; - } while(ret > 0); + } while (ret > 0); printf("\n"); -- 2.1.3 -- You received this message because you are subscribed to the Google Groups "netsniff-ng" group. To unsubscribe from this group and stop receiving emails from it, send an email to netsniff-ng+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.