[gnome-remote-desktop/gnome-42] rdp/nw-auto: Turn assertion into normal conditional statement



commit 2c1eadaa59e5eb0342e63e38c1166ed9bfe3f18a
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Tue Jun 7 17:47:21 2022 +0200

    rdp/nw-auto: Turn assertion into normal conditional statement
    
    For unknown reasons, the initial state of the bandwidth measure stop
    event is set to TRUE on some systems, although the opposite should be
    the case, leading to an assertion hit.
    
    So, turn for now the assertion into a normal condition.
    In addition to that, always reset the event before hitting the new
    condition to avoid further unnecessary wakeups.
    
    Closes: https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/issues/102

 src/grd-rdp-network-autodetection.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/src/grd-rdp-network-autodetection.c b/src/grd-rdp-network-autodetection.c
index edf11af4..f8ff9129 100644
--- a/src/grd-rdp-network-autodetection.c
+++ b/src/grd-rdp-network-autodetection.c
@@ -303,14 +303,17 @@ void
 grd_rdp_network_autodetection_bw_measure_stop (GrdRdpNetworkAutodetection *network_autodetection)
 {
   rdpAutoDetect *rdp_autodetect = network_autodetection->rdp_autodetect;
+  g_autoptr (GMutexLocker) locker = NULL;
 
-  g_mutex_lock (&network_autodetection->bw_measure_mutex);
-  g_assert (network_autodetection->bw_measure_state == BW_MEASURE_STATE_PENDING_STOP ||
-            network_autodetection->bw_measure_state == BW_MEASURE_STATE_QUEUED_STOP);
-
+  locker = g_mutex_locker_new (&network_autodetection->bw_measure_mutex);
   ResetEvent (network_autodetection->bw_measure_stop_event);
+
+  if (network_autodetection->bw_measure_state != BW_MEASURE_STATE_PENDING_STOP &&
+      network_autodetection->bw_measure_state != BW_MEASURE_STATE_QUEUED_STOP)
+    return;
+
   network_autodetection->bw_measure_state = BW_MEASURE_STATE_PENDING_RESULTS;
-  g_mutex_unlock (&network_autodetection->bw_measure_mutex);
+  g_clear_pointer (&locker, g_mutex_locker_free);
 
   rdp_autodetect->BandwidthMeasureStop (network_autodetection->rdp_context,
                                         BW_MEASURE_SEQUENCE_NUMBER);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]