Wait for initial remote probe before connecting to server. Closes #3445

This commit is contained in:
baldurk
2024-10-21 14:05:31 +01:00
parent 8e5ab5dd41
commit e6d0d57f80
4 changed files with 35 additions and 4 deletions
+8
View File
@@ -240,6 +240,9 @@ MainWindow::MainWindow(ICaptureContext &ctx) : QMainWindow(NULL), ui(new Ui::Mai
// do a remoteProbe immediately to populate the device list on startup.
remoteProbe();
// allow any early-init replay host switches now that we've populated the device list
m_RemoteInitialProbeReady.release();
// do several small sleeps so we can respond quicker when we need to shut down
for(int i = 0; i < 50; i++)
{
@@ -1932,6 +1935,11 @@ void MainWindow::setRemoteHost(int hostIdx)
if(!PromptCloseCapture())
return;
// we only want to block once before the initial remoteProbe has happened. After that once we can
// acquire once, we re-release so the next one can happen
m_RemoteInitialProbeReady.acquire();
m_RemoteInitialProbeReady.release();
rdcarray<RemoteHost> hosts = m_Ctx.Config().GetRemoteHosts();
RemoteHost host;
+1
View File
@@ -250,6 +250,7 @@ private:
QTimer m_MessageTick;
QSemaphore m_RemoteProbeSemaphore;
QSemaphore m_RemoteInitialProbeReady;
LambdaThread *m_RemoteProbe;
// m_ProbeRemoteHosts is covered by a lock. On the UI thread we copy it from the config regularly,
+23 -4
View File
@@ -1099,7 +1099,9 @@ struct AndroidController : public IDeviceProtocolHandler
{
SCOPED_LOCK(lock);
ret = devices[GetDeviceID(URL)].name;
auto it = devices.find(GetDeviceID(URL));
if(it != devices.end())
ret = it->second.name;
}
return ret;
@@ -1125,7 +1127,16 @@ struct AndroidController : public IDeviceProtocolHandler
Invoke([this, &result, URL]() {
rdcstr deviceID = GetDeviceID(URL);
Device &dev = devices[deviceID];
auto it = devices.find(deviceID);
if(it == devices.end())
{
SET_ERROR_RESULT(result, ResultCode::InternalError,
"Android device %s is not a valid device ID, can't launch server",
Android::GetFriendlyName(deviceID).c_str());
return;
}
Device &dev = it->second;
if(!dev.active)
{
@@ -1254,7 +1265,9 @@ struct AndroidController : public IDeviceProtocolHandler
{
SCOPED_LOCK(lock);
portbase = devices[deviceID].portbase;
auto it = devices.find(deviceID);
if(it != devices.end())
portbase = it->second.portbase;
}
if(portbase == 0)
@@ -1275,7 +1288,13 @@ struct AndroidController : public IDeviceProtocolHandler
{
SCOPED_LOCK(lock);
portbase = devices[deviceID].portbase;
auto it = devices.find(deviceID);
if(it == devices.end())
{
SAFE_DELETE(sock);
return NULL;
}
portbase = it->second.portbase;
}
return new AndroidRemoteServer(sock, deviceID, portbase);
+3
View File
@@ -1257,6 +1257,9 @@ RENDERDOC_CreateRemoteServerConnection(const rdcstr &URL, IRemoteServer **rend)
else
*rend = new RemoteServer(sock, deviceID);
if(*rend == NULL)
return RDResult(ResultCode::NetworkIOFailed);
return RDResult(ResultCode::Succeeded);
}