From 5de9754e3079e18c855b0b713102b6b65b81af10 Mon Sep 17 00:00:00 2001
From: Rider Linden <rider@lindenlab.com>
Date: Fri, 8 Mar 2019 17:34:49 -0800
Subject: [PATCH] SL-10702: When attempting a new voice connection, ensure that
 the voicePump mail drop does not have any outstanding events.

---
 indra/llcommon/llevents.h      | 10 ++++++----
 indra/newview/llvoicevivox.cpp |  5 +++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h
index 5d60c638101..d850cb4fcc5 100644
--- a/indra/llcommon/llevents.h
+++ b/indra/llcommon/llevents.h
@@ -582,11 +582,12 @@ class LL_COMMON_API LLEventPump: public LLEventTrackable
     /// Generate a distinct name for a listener -- see listen()
     static std::string inventName(const std::string& pfx="listener");
 
-private:
-    friend class LLEventPumps;
     /// flush queued events
     virtual void flush() {}
 
+private:
+    friend class LLEventPumps;
+
     virtual void reset();
 
 
@@ -675,8 +676,10 @@ class LL_COMMON_API LLEventMailDrop : public LLEventStream
     virtual ~LLEventMailDrop() {}
     
     /// Post an event to all listeners
-    virtual bool post(const LLSD& event);
+    virtual bool post(const LLSD& event) override;
     
+    /// Remove any history stored in the mail drop.
+    virtual void flush() override { mEventHistory.clear(); LLEventStream::flush(); };
 protected:
     virtual LLBoundListener listen_impl(const std::string& name, const LLEventListener&,
                                         const NameList& after,
@@ -703,7 +706,6 @@ class LL_COMMON_API LLEventQueue: public LLEventPump
     /// Post an event to all listeners
     virtual bool post(const LLSD& event);
 
-private:
     /// flush queued events
     virtual void flush();
 
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index cf40058c34a..0d3f65502ad 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -1460,6 +1460,11 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
 
     LLSD timeoutResult(LLSDMap("session", "timeout"));
 
+    // We are about to start a whole new session.  Anything that MIGHT still be in our 
+    // maildrop is going to be stale and cause us much wailing and gnashing of teeth.  
+    // Just flush it all out and start new.
+    voicePump.flush();
+
     // It appears that I need to wait for BOTH the SessionGroup.AddSession response and the SessionStateChangeEvent with state 4
     // before continuing from this state.  They can happen in either order, and if I don't wait for both, things can get stuck.
     // For now, the SessionGroup.AddSession response handler sets mSessionHandle and the SessionStateChangeEvent handler transitions to stateSessionJoined.
-- 
GitLab