diff mbox series

bridge-utils:close socket before exit

Message ID 20220803082051.1704227-1-sunsuwan3@huawei.com (mailing list archive)
State Rejected
Delegated to: Stephen Hemminger
Headers show
Series bridge-utils:close socket before exit | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

sunsuwan Aug. 3, 2022, 8:20 a.m. UTC
brctl should close socket before exit.

Signed-off-by: sunsuwan <sunsuwan3@huawei.com>

---
 brctl/brctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Stephen Hemminger Aug. 3, 2022, 3:25 p.m. UTC | #1
On Wed, 3 Aug 2022 16:20:51 +0800
sunsuwan <sunsuwan3@huawei.com> wrote:

> brctl should close socket before exit.
> 
> Signed-off-by: sunsuwan <sunsuwan3@huawei.com>

Why bother? The file descriptor is closed automatically on process exit.

At this point bridge-utils is in long term hibernation mode.
It has been replaced by bridge command in iproute2.

Don't want to do any changes or releases unless there is a very high priority
bug that must be fixed.
diff mbox series

Patch

diff --git a/brctl/brctl.c b/brctl/brctl.c
index 8855234..dd6c347 100644
--- a/brctl/brctl.c
+++ b/brctl/brctl.c
@@ -37,7 +37,7 @@  static void help()
 int main(int argc, char *const* argv)
 {
 	const struct command *cmd;
-	int f;
+	int f, ret;
 	static const struct option options[] = {
 		{ .name = "help", .val = 'h' },
 		{ .name = "version", .val = 'V' },
@@ -70,16 +70,20 @@  int main(int argc, char *const* argv)
 	argv += optind;
 	if ((cmd = command_lookup(*argv)) == NULL) {
 		fprintf(stderr, "never heard of command [%s]\n", *argv);
+		br_shutdown();
 		goto help;
 	}
 	
 	if (argc < cmd->nargs + 1) {
 		printf("Incorrect number of arguments for command\n");
 		printf("Usage: brctl %s %s\n", cmd->name, cmd->help);
+		br_shutdown();
 		return 1;
 	}
 
-	return cmd->func(argc, argv);
+	ret = cmd->func(argc, argv);
+	br_shutdown();
+	return ret;
 
 help:
 	help();