public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] iso-tester: Fix using shutdown(SHUT_RDWR)
Date: Fri, 19 Aug 2022 11:46:05 -0700	[thread overview]
Message-ID: <20220819184605.19225-1-luiz.dentz@gmail.com> (raw)

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

shutdown(SHUT_RDWR) results in socket being HUP immeditaly instead of
waiting for Disconnect Complete event so instead just use SHUT_WR to
start the disconnect procedure without causing the socket to HUP.
---
 tools/iso-tester.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index e4950ead7c69..5727f3055222 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -1185,18 +1185,18 @@ static gboolean iso_disconnected(GIOChannel *io, GIOCondition cond,
 
 static void iso_shutdown(struct test_data *data, GIOChannel *io)
 {
-	int sk, cl;
+	int sk;
 
 	sk = g_io_channel_unix_get_fd(io);
-	cl = dup(sk);
 
 	data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_disconnected, data);
 
-	/* Shutdown clone fd so the original fd don't HUP immediately and
-	 * properly wait for socket to be closed.
+	/* Shutdown using SHUT_WR as SHUT_RDWR cause the socket to HUP
+	 * immediately instead of waiting for Disconnect Complete event.
 	 */
-	shutdown(cl, SHUT_RDWR);
-	close(cl);
+	shutdown(sk, SHUT_WR);
+
+	tester_print("Disconnecting...");
 }
 
 static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
-- 
2.37.2


             reply	other threads:[~2022-08-19 18:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 18:46 Luiz Augusto von Dentz [this message]
2022-08-19 18:55 ` [BlueZ] iso-tester: Fix using shutdown(SHUT_RDWR) bluez.test.bot
2022-08-19 20:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth

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=20220819184605.19225-1-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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