From 800ea5c29fac579fc6660175075d3333a2d9786c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Mon, 30 Jun 2025 16:16:31 +0200
Subject: [PATCH 07/13] utils: Add helper to close connection and notify

Closing doesn't notify that it was closed, so lets add a helper that
does so, that we then can uses to rely on the closed property being up
to date.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/merge_requests/321>
---
 src/grd-utils.c | 7 +++++++
 src/grd-utils.h | 2 ++
 2 files changed, 9 insertions(+)

diff -urp gnome-remote-desktop-46.5.orig/src/grd-utils.c gnome-remote-desktop-46.5/src/grd-utils.c
--- gnome-remote-desktop-46.5.orig/src/grd-utils.c	2026-02-10 19:22:55.746236126 -0600
+++ gnome-remote-desktop-46.5/src/grd-utils.c	2026-02-10 19:25:58.861629048 -0600
@@ -340,3 +340,10 @@ grd_test_fd (int         fd,
 
   return TRUE;
 }
+
+void
+grd_close_connection_and_notify (GSocketConnection *connection)
+{
+  g_io_stream_close (G_IO_STREAM (connection), NULL, NULL);
+  g_object_notify (G_OBJECT (connection), "closed");
+}
diff -urp gnome-remote-desktop-46.5.orig/src/grd-utils.h gnome-remote-desktop-46.5/src/grd-utils.h
--- gnome-remote-desktop-46.5.orig/src/grd-utils.h	2026-02-10 19:25:58.232964329 -0600
+++ gnome-remote-desktop-46.5/src/grd-utils.h	2026-02-10 19:27:09.752448022 -0600
@@ -75,6 +75,8 @@ gboolean grd_test_fd (int         fd,
                       GFileTest  *test_results,
                       GError    **error);
 
+void grd_close_connection_and_notify (GSocketConnection *connection);
+
 static inline int64_t
 us (int64_t us)
 {
