From a635b075ef468eb11bf33fcc5444fe81a796c90a Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 9 Dec 2011 16:30:13 +0000 Subject: [PATCH] - VBOX: Add the ability for the wrapper to know if vboxmanage has hung or is stuck in a loop. If so, terminate the process and return an error to the calling function. samples/vboxwrapper/ vbox.cpp svn path=/trunk/boinc/; revision=24767 --- checkin_notes | 8 ++++++++ samples/vboxwrapper/vbox.cpp | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/checkin_notes b/checkin_notes index 3908fbdd06..a3ef07abce 100644 --- a/checkin_notes +++ b/checkin_notes @@ -8919,3 +8919,11 @@ Rom 9 Dec 2011 samples/vboxwrapper/ vbox.cpp + +Rom 9 Dec 2011 + - VBOX: Add the ability for the wrapper to know if vboxmanage has hung or is stuck + in a loop. If so, terminate the process and return an error to the calling + function. + + samples/vboxwrapper/ + vbox.cpp diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 2ff06fd728..a0698277a3 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -116,6 +116,7 @@ int VBOX_VM::vbm_popen(string& arguments, string& output, const char* item) { void* pBuf = NULL; DWORD dwCount = 0; unsigned long ulExitCode = 0; + unsigned long ulExitTimeout = 0; memset(&si, 0, sizeof(si)); memset(&pi, 0, sizeof(pi)); @@ -178,7 +179,20 @@ int VBOX_VM::vbm_popen(string& arguments, string& output, const char* item) { } if (ulExitCode != STILL_ACTIVE) break; - Sleep(100); + + // Timeout? + if (ulExitTimeout >= 60000) { + fprintf( + stderr, + "%s Process Timeout!.\n", + boinc_msg_prefix(buf, sizeof(buf)) + ); + + TerminateProcess(pi.hProcess, EXIT_FAILURE); + } + + Sleep(250); + ulExitTimeout += 250; } CLEANUP: