DRTVWR-476, VOICE-88, SL-13025: Use a new port every SLVoice launch.

The observed failure is that SLVoice, on relaunch, produces an error that
bind() returned EADDRINUSE and terminates. Using a different port every time
we relaunch avoids that collision.
master
Nat Goodspeed 2020-05-27 12:36:59 -04:00
parent 095630411c
commit 1f4fbc8d11
1 changed files with 16 additions and 1 deletions

View File

@ -806,6 +806,21 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
LLProcess::Params params;
params.executable = exe_path;
// VOICE-88: Cycle through [portbase..portbase+portrange) on
// successive tries because attempting to relaunch (after manually
// disabling and then re-enabling voice) with the same port can
// cause SLVoice's bind() call to fail with EADDRINUSE. We expect
// that eventually the OS will time out previous ports, which is
// why we cycle instead of incrementing indefinitely.
U32 portbase = gSavedSettings.getU32("VivoxVoicePort");
static U32 portoffset = 0;
static const U32 portrange = 100;
std::string host(gSavedSettings.getString("VivoxVoiceHost"));
U32 port = portbase + portoffset;
portoffset = (portoffset + 1) % portrange;
params.args.add("-i");
params.args.add(STRINGIZE(host << ':' << port));
std::string loglevel = gSavedSettings.getString("VivoxDebugLevel");
if (loglevel.empty())
{
@ -862,7 +877,7 @@ bool LLVivoxVoiceClient::startAndLaunchDaemon()
sGatewayPtr = LLProcess::create(params);
mDaemonHost = LLHost(gSavedSettings.getString("VivoxVoiceHost").c_str(), gSavedSettings.getU32("VivoxVoicePort"));
mDaemonHost = LLHost(host.c_str(), port);
}
else
{