summaryrefslogtreecommitdiff
path: root/geoip.c
diff options
context:
space:
mode:
Diffstat (limited to 'geoip.c')
-rw-r--r--geoip.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/geoip.c b/geoip.c
index c4c6cf8..b2121e7 100644
--- a/geoip.c
+++ b/geoip.c
@@ -177,8 +177,10 @@ again:
files[which].remote, host);
ret = write(sock, raw, strlen(raw));
- if (ret <= 0)
+ if (ret <= 0) {
+ close(sock);
return -EIO;
+ }
shutdown(sock, SHUT_WR);
@@ -187,8 +189,11 @@ again:
memset(raw, 0, sizeof(raw));
ret = read(sock, raw, sizeof(raw));
- if (ret <= 0)
+ if (ret <= 0) {
+ close(fd);
+ close(sock);
return -EIO;
+ }
raw[sizeof(raw) - 1] = 0;
@@ -210,10 +215,11 @@ again:
}
if (!found || ptr >= raw + ret || len < 0 || rtotlen == 0 || good == 0) {
+ close(fd);
+ close(sock);
+
if (retry == 0) {
retry = 1;
- close(fd);
- close(sock);
goto again;
}