VirtualBox

Ignore:
Timestamp:
Nov 12, 2020 10:15:18 AM (4 years ago)
Author:
vboxsync
Message:

Additions/VBoxClient: Big revamp of the internal service handling and termination fixes. A service now runs as part of a worker thread, while the main thread is used for initialization / shutdown and signal handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/x11/VBoxClient/display-svga-x11.cpp

    r86469 r86871  
    733733 * it (guest property) is set.
    734734 */
    735 static bool checkDRMClient()
     735static bool checkDRMClient(void)
    736736{
    737737   uint32_t uGuestPropSvcClientID;
     
    745745}
    746746
    747 static bool startDRMClient()
     747static bool startDRMClient(void)
    748748{
    749749    char* argv[] = {NULL};
     
    755755    int rc = execve(szDRMClientPath, argv, env);
    756756    if (rc == -1)
    757         VBClLogFatalError("execve for % returns the following error %d %s\n", szDRMClientPath, errno, strerror(errno));
     757        VBClLogFatalError("execve for '%s' returns the following error %d: %s\n", szDRMClientPath, errno, strerror(errno));
    758758    /* This is reached only when execve fails. */
    759759    return false;
    760760}
    761761
    762 static bool init()
    763 {
     762/** @copydoc VBCLSERVICE::pfnInit */
     763static int vbclSVGAInit(void)
     764{
     765    /* In 32-bit guests GAs build on our release machines causes an xserver hang.
     766     * So for 32-bit GAs we use our DRM client. */
     767#if ARCH_BITS == 32
     768    /* igore rc */ startDRMClient();
     769    return VERR_NOT_AVAILABLE;
     770#endif
     771
    764772    /* If DRM client is already running don't start this service. */
    765773    if (checkDRMClient())
    766774    {
    767775        VBClLogFatalError("DRM resizing is already running. Exiting this service\n");
    768         return false;
     776        return VERR_NOT_AVAILABLE;
    769777    }
    770778    if (isXwayland())
     
    781789}
    782790
    783 static void cleanup()
     791/** @copydoc VBCLSERVICE::pfnStop */
     792static void vbclSVGAStop(void)
    784793{
    785794    if (mpMonitorPositions)
     
    788797        mpMonitorPositions = NULL;
    789798    }
    790     stopX11MonitorThread();
     799
     800    stopX11MonitorThread(); /** @todo r=andy We ignore rc!? */
     801
    791802    if (x11Context.pRandLibraryHandle)
    792803    {
     
    13311342}
    13321343
    1333 static const char *getName()
    1334 {
    1335     return "Display SVGA X11";
    1336 }
    1337 
    1338 static const char *getPidFilePath()
    1339 {
    1340     return ".vboxclient-display-svga-x11.pid";
    1341 }
    1342 
    1343 static int run(struct VBCLSERVICE **ppInterface, bool fDaemonised)
    1344 {
    1345     RT_NOREF(ppInterface, fDaemonised);
    1346 
    1347     /* In 32-bit guests GAs build on our release machines causes an xserver hang.
    1348      * So for 32-bit GAs we use our DRM client. */
    1349 #if ARCH_BITS == 32
    1350     startDRMClient();
    1351     return VERR_NOT_AVAILABLE;
    1352 #endif
    1353 
    1354     if (!init())
    1355         return VERR_NOT_AVAILABLE;
     1344static int vbclSVGAWorker(bool volatile *pfShutdown)
     1345{
     1346    RT_NOREF(pfShutdown);
    13561347
    13571348    /* Do not acknowledge the first event we query for to pick up old events,
     
    13691360    if (rc == VERR_RESOURCE_BUSY)  /* Someone else has already acquired it. */
    13701361        return VERR_RESOURCE_BUSY;
     1362
     1363    /* Let the main thread know that it can continue spawning services. */
     1364    RTThreadUserSignal(RTThreadSelf());
     1365
    13711366    for (;;)
    13721367    {
     
    14421437            VBClLogFatalError("Failure waiting for event, rc=%Rrc\n", rc);
    14431438    }
    1444     cleanup();
    1445 }
    1446 
    1447 static struct VBCLSERVICE interface =
    1448 {
    1449     getName,
    1450     getPidFilePath,
    1451     VBClServiceDefaultHandler, /* Init */
    1452     run,
    1453     VBClServiceDefaultCleanup
    1454 }, *pInterface = &interface;
    1455 
    1456 struct VBCLSERVICE **VBClDisplaySVGAX11Service()
    1457 {
    1458     return &pInterface;
    1459 }
     1439}
     1440
     1441VBCLSERVICE g_SvcDisplaySVGA =
     1442{
     1443    "dp-svga-x11",                      /* szName */
     1444    "SVGA X11 display",                 /* pszDescription */
     1445    ".vboxclient-display-svga-x11.pid", /* pszPidFilePath */
     1446    NULL,                               /* pszUsage */
     1447    NULL,                               /* pszOptions */
     1448    NULL,                               /* pfnOption */
     1449    vbclSVGAInit,                       /* pfnInit */
     1450    vbclSVGAWorker,                     /* pfnWorker */
     1451    vbclSVGAStop,                       /* pfnStop*/
     1452    NULL                                /* pfnTerm */
     1453};
     1454
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette