iso-tester: Fix using shutdown(SHUT_RDWR)
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 18 Aug 2022 21:46:14 +0000 (14:46 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/iso-tester.c

index e4950ea..5727f30 100644 (file)
@@ -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,