Avoid remote server timing out if starting android packages.

* Android::StartAndroidPackageForCapture can take a long time, and we
  want to preserve the connection, so we spin up a temporary thread to
  continually Ping().
This commit is contained in:
baldurk
2018-01-26 15:42:07 +00:00
parent 643db8042b
commit b22f93f458
+19 -1
View File
@@ -1218,7 +1218,25 @@ public:
{
const char *host = hostname().c_str();
if(Android::IsHostADB(host))
return Android::StartAndroidPackageForCapture(host, a);
{
// we spin up a thread to Ping() every second, since StartAndroidPackageForCapture can block
// for a long time.
volatile int32_t done = 0;
Threading::ThreadHandle pingThread = Threading::CreateThread([&done, this]() {
bool ok = true;
while(ok && Atomic::CmpExch32(&done, 0, 0) == 0)
ok = Ping();
});
uint32_t ret = Android::StartAndroidPackageForCapture(host, a);
Atomic::Inc32(&done);
Threading::JoinThread(pingThread);
Threading::CloseThread(pingThread);
return ret;
}
std::string app = a && a[0] ? a : "";
std::string workingDir = w && w[0] ? w : "";