[gnome-remote-desktop] clipboard-rdp: Fix race in debug message



commit 53a3e19ef23eb73200e7a64568490d02fc891561
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Sat Aug 6 06:45:14 2022 +0200

    clipboard-rdp: Fix race in debug message
    
    Lock Clipboard Data PDUs can be sent at any point in time after the
    clipboard capabilities and temporary directory have been exchanged in
    the clipboard initialization sequence ([MS-RDPECLIP] 2.2.4.1).
    With mstsc as RDP client, the PDU is sent before the
    FormatListResponse.
    So, in the locking stage, it is not yet known, that File Content
    Requests are successful.
    To avoid blocking in the main and CLIPRDR thread, a simple boolean
    value, indicating whether requests are allowed or not, is used to
    determine that state.
    
    While extremely unlikely, but still possible, it may happen, that a
    debug message is printed to the output, while the associated File
    Contents Request is successful.
    
    Fix this annoyance by retrieving the state first and then use the local
    copied state to determine, whether that debug message should be shown
    or not.

 src/grd-clipboard-rdp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/grd-clipboard-rdp.c b/src/grd-clipboard-rdp.c
index 498e0003..f9927812 100644
--- a/src/grd-clipboard-rdp.c
+++ b/src/grd-clipboard-rdp.c
@@ -2140,15 +2140,15 @@ cliprdr_client_file_contents_request (CliprdrServerContext                *clipr
                                          NULL, (gpointer *) &entry))
         return send_file_contents_response_failure (cliprdr_context, stream_id);
 
-      if (!entry->requests_allowed)
+      delegate = entry->delegate;
+      has_file_list = entry->has_file_list;
+      requests_allowed = entry->requests_allowed;
+
+      if (!requests_allowed)
         {
           g_debug ("[RDP.CLIPRDR] ClipDataEntry with id %u is not eligible of "
                    "requesting file contents.", clip_data_id);
         }
-
-      delegate = entry->delegate;
-      has_file_list = entry->has_file_list;
-      requests_allowed = entry->requests_allowed;
     }
 
   if (!requests_allowed || !has_file_list)


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