summaryrefslogtreecommitdiff
path: root/usr.sbin/rebound
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2015-10-15 22:21:29 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2015-10-15 22:21:29 +0000
commit3ce02db96f22b0ee9e74a08d9621c1dde92150c5 (patch)
tree1caedb53e6524507ca6f90a451d55c0485c64b85 /usr.sbin/rebound
parent91878f7266698c6c2df068f456835d8ccfedc69d (diff)
it is perhaps better style to not call close() on -1, even if harmless
Diffstat (limited to 'usr.sbin/rebound')
-rw-r--r--usr.sbin/rebound/rebound.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/usr.sbin/rebound/rebound.c b/usr.sbin/rebound/rebound.c
index 04fdf96e256..ebc98ec9336 100644
--- a/usr.sbin/rebound/rebound.c
+++ b/usr.sbin/rebound/rebound.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rebound.c,v 1.13 2015/10/15 22:17:43 tedu Exp $ */
+/* $OpenBSD: rebound.c,v 1.14 2015/10/15 22:21:28 tedu Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
@@ -201,7 +201,8 @@ newrequest(int ud, struct sockaddr *remoteaddr)
return req;
fail:
free(hit);
- close(req->s);
+ if (req->s != -1)
+ close(req->s);
free(req);
return NULL;
}
@@ -241,8 +242,10 @@ freerequest(struct request *req)
struct dnscache *ent;
TAILQ_REMOVE(&reqfifo, req, fifo);
- close(req->client);
- close(req->s);
+ if (req->client != -1)
+ close(req->client);
+ if (req->s != -1)
+ close(req->s);
if ((ent = req->cacheent) && !ent->resp) {
free(ent->req);
free(ent);
@@ -288,9 +291,12 @@ newtcprequest(int ld, struct sockaddr *remoteaddr)
req->ts.tv_sec += 30;
return req;
+
fail:
- close(req->s);
- close(req->client);
+ if (req->s != -1)
+ close(req->s);
+ if (req->client != -1)
+ close(req->client);
free(req);
return NULL;
}