From: Matt Tierney <tierney@cs.nyu.edu>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: netdev@vger.kernel.org, Matt Tierney <tierney@cs.nyu.edu>
Subject: [PATCH iproute2] ss: Close file descriptors in tcp_show_netlink.
Date: Wed, 15 Feb 2012 18:20:38 -0500 [thread overview]
Message-ID: <1329348038-12646-1-git-send-email-tierney@cs.nyu.edu> (raw)
ss: Close file descriptors in tcp_show_netlink.
Signed-off-by: Matt Tierney <tierney@cs.nyu.edu>
---
misc/ss.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/misc/ss.c b/misc/ss.c
index eb42fd6..2caac4a 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1563,6 +1563,7 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
}
if (status == 0) {
fprintf(stderr, "EOF on netlink\n");
+ close(fd);
return 0;
}
@@ -1578,8 +1579,10 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
h->nlmsg_seq != 123456)
goto skip_it;
- if (h->nlmsg_type == NLMSG_DONE)
+ if (h->nlmsg_type == NLMSG_DONE) {
+ close(fd);
return 0;
+ }
if (h->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
if (h->nlmsg_len < NLMSG_LENGTH(sizeof(struct nlmsgerr))) {
@@ -1588,6 +1591,7 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
errno = -err->error;
perror("TCPDIAG answers");
}
+ close(fd);
return 0;
}
if (!dump_fp) {
@@ -1596,8 +1600,10 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)
continue;
}
err = tcp_show_sock(h, NULL);
- if (err < 0)
+ if (err < 0) {
+ close(fd);
return err;
+ }
}
skip_it:
@@ -1612,6 +1618,7 @@ skip_it:
exit(1);
}
}
+ close(fd);
return 0;
}
--
1.7.5.4
reply other threads:[~2012-02-15 23:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329348038-12646-1-git-send-email-tierney@cs.nyu.edu \
--to=tierney@cs.nyu.edu \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).