speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH] Prevent deletion of wrong client from fd_settings during speak()


From: Christopher Brannon
Subject: [PATCH] Prevent deletion of wrong client from fd_settings during speak().
Date: Sun, 1 Aug 2010 15:09:48 -0500

The code is supposed to delete the client associated with
current_message when it has no outstanding messages.
However, several statements referred to the "message" variable when
they should refer to current_message instead.
Also, the function client_has_messages() does not account for the
message that was just retrieved from the queue, so we also need to
check that current_message->settings.uid != message->settings.uid.
---
 src/server/speaking.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/server/speaking.c b/src/server/speaking.c
index 09ed02b..20d0977 100644
--- a/src/server/speaking.c
+++ b/src/server/speaking.c
@@ -213,8 +213,14 @@ speak(void* data)
                /* Check if the client who emited this message is disconnected
                   by now and this was his last message. If so, delete it's 
settings
                   from fdset */
-               if (get_client_settings_by_uid(message->settings.uid)->active 
== 0){
-                   if (!client_has_messages(message->settings.uid)){
+               if 
(get_client_settings_by_uid(current_message->settings.uid)->active == 0){
+                 if (!client_has_messages(current_message->settings.uid)
+                     && (current_message->settings.uid != 
message->settings.uid)){
+                       /* client_has_messages does not account for message,
+                          which was just retrieved from the queue.
+                          We also have to compare the uids of message
+                          and current_message to be sure that there are
+                          no outstanding messages. */
                        MSG(4, "Removing client settings for uid %d", 
current_message->settings.uid);
                        
remove_client_settings_by_uid(current_message->settings.uid);
                    }
-- 
1.7.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]