Changeset 95201 in vbox for trunk/src/VBox/Frontends/VBoxHeadless
- Timestamp:
- Jun 5, 2022 8:29:53 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 151709
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxHeadless/VBoxHeadless.cpp
r95199 r95201 44 44 #include <iprt/env.h> 45 45 #include <iprt/errcore.h> 46 #include <iprt/thread.h> 46 47 #include <VBoxVideo.h> 47 48 … … 79 80 static IConsole *gConsole = NULL; 80 81 static NativeEventQueue *gEventQ = NULL; 82 /** Inidcates whether gEventQ can safely be used or not. */ 83 static volatile bool g_fEventQueueSafe = false; 81 84 82 85 /* keep this handy for messages */ … … 84 87 static com::Utf8Str g_strVMUUID; 85 88 86 /* flag whether frontend should terminate */89 /** flag whether frontend should terminate */ 87 90 static volatile bool g_fTerminateFE = false; 88 91 … … 412 415 if (pszThread) 413 416 { 414 aSegs[cSegs++].iov_base = (char *)" 417 aSegs[cSegs++].iov_base = (char *)"(on thread "; 415 418 aSegs[cSegs++].iov_base = (char *)pszThread; 416 } 417 aSegs[cSegs++].iov_base = (char *)"\n"; 419 aSegs[cSegs++].iov_base = (char *)")\n"; 420 } 421 else 422 aSegs[cSegs++].iov_base = (char *)"\n"; 418 423 for (int i = 0; i < cSegs; i++) 419 424 aSegs[i].iov_len = strlen((const char *)aSegs[i].iov_base); … … 485 490 if (sigwait(&SigSetWait, &iSignal) == 0) 486 491 { 492 LogRel(("VBoxHeadless: Caught signal: %s\n", strsignal(iSignal))); 493 RTMsgInfo(""); 494 RTMsgInfo("Caught signal: %s", strsignal(iSignal)); 487 495 g_fTerminateFE = true; 488 RTMsgInfo("Caught signal: %s\n", strsignal(iSignal));489 LogRel(("VBoxHeadless: Caught signal: %s\n", strsignal(iSignal)));490 496 } 491 497 492 498 /** @todo this is a little bit racy... */ 493 if (g_fTerminateFE && g EventQ != NULL)499 if (g_fTerminateFE && g_fEventQueueSafe && gEventQ != NULL) 494 500 gEventQ->interruptEventQueueProcessing(); 495 501 } … … 769 775 /* tell the VM to save state/power off */ 770 776 g_fTerminateFE = true; 771 gEventQ->interruptEventQueueProcessing(); 777 if (g_fEventQueueSafe && gEventQ != NULL) 778 gEventQ->interruptEventQueueProcessing(); 772 779 773 780 if (g_hCanQuit != NIL_RTSEMEVENT) … … 795 802 796 803 797 static const char * const ctrl_event_names[] = { 804 static const char * const g_apszCtrlEventNames[] = 805 { 798 806 "CTRL_C_EVENT", 799 807 "CTRL_BREAK_EVENT", … … 811 819 ConsoleCtrlHandler(DWORD dwCtrlType) RT_NOTHROW_DEF 812 820 { 813 const char *signame; 814 char namebuf[48]; 815 int rc; 816 817 if (dwCtrlType < RT_ELEMENTS(ctrl_event_names)) 818 signame = ctrl_event_names[dwCtrlType]; 821 const char *pszSigName; 822 char szNameBuf[48]; 823 if (dwCtrlType < RT_ELEMENTS(g_apszCtrlEventNames)) 824 pszSigName = g_apszCtrlEventNames[dwCtrlType]; 819 825 else 820 826 { 821 827 /* should not happen, but be prepared */ 822 RTStrPrintf( namebuf, sizeof(namebuf),823 "<console control event %lu>", (unsigned long)dwCtrlType);824 signame = namebuf;825 } 826 LogRel(("VBoxHeadless: got %s\n", signame));827 RTMsgInfo("Got %s \n", signame);828 RTStrPrintf(szNameBuf, sizeof(szNameBuf), "<console control event %u>", dwCtrlType); 829 pszSigName = szNameBuf; 830 } 831 832 LogRel(("VBoxHeadless: got %s\n", pszSigName)); 833 RTMsgInfo("Got %s", pszSigName); 828 834 RTMsgInfo(""); 829 835 830 836 /* tell the VM to save state/power off */ 831 837 g_fTerminateFE = true; 832 gEventQ->interruptEventQueueProcessing(); 838 if (g_fEventQueueSafe && gEventQ != NULL) 839 gEventQ->interruptEventQueueProcessing(); 833 840 834 841 /* … … 840 847 LogRel(("VBoxHeadless: waiting for VM termination...\n")); 841 848 842 rc = RTSemEventWait(g_hCanQuit, RT_INDEFINITE_WAIT);849 int rc = RTSemEventWait(g_hCanQuit, RT_INDEFINITE_WAIT); 843 850 if (RT_FAILURE(rc)) 844 851 LogRel(("VBoxHeadless: Failed to wait for VM termination: %Rrc\n", rc)); … … 1298 1305 gConsole = console; 1299 1306 gEventQ = com::NativeEventQueue::getMainEventQueue(); 1307 g_fEventQueueSafe = true; 1300 1308 1301 1309 /* VirtualBoxClient events registration. */ … … 1587 1595 } while (0); 1588 1596 1597 /* No point in trying to post dummy messages to the event queue now. */ 1598 g_fEventQueueSafe = false; 1599 1589 1600 /* VirtualBox callback unregistration. */ 1590 1601 if (vboxListener)
Note:
See TracChangeset
for help on using the changeset viewer.