VirtualBox

Ignore:
Timestamp:
Feb 15, 2023 4:48:37 PM (2 years ago)
Author:
vboxsync
Message:

Additions: X11: Make legacy display resize service to gracefully shutdown, bugref:10359.

File:
1 edited

Legend:

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

    r98474 r98594  
    3232#include <iprt/mem.h>
    3333#include <iprt/string.h>
     34#include <iprt/asm.h>
    3435
    3536#include <X11/Xlib.h>
     
    146147/** Main loop: handle display hot-plug events, property updates (which can
    147148 *  signal VT switches hot-plug in old X servers). */
    148 static void runDisplay(struct DISPLAYSTATE *pState)
     149static void runDisplay(struct DISPLAYSTATE *pState, bool volatile *pfShutdown)
    149150{
    150151    Display *pDisplay = pState->pDisplay;
     
    166167     * against spontaneous termination, especially as it will never get
    167168     * properly tested, so I will go for the second. */
    168     while (true)
     169    while (!ASMAtomicReadBool(pfShutdown))
    169170    {
    170171        XEvent event;
     
    281282static DECLCALLBACK(int) run(bool volatile *pfShutdown)
    282283{
    283     RT_NOREF(pfShutdown); /** @todo Probably very wrong not to check pfShutdown... Especially given no pfnStop implementation. */
    284284    struct DISPLAYSTATE *pSelf = &g_DisplayState;
    285285
    286286    if (!pSelf->mfInit)
    287287        return VERR_WRONG_ORDER;
    288     runDisplay(pSelf);
    289     return VERR_INTERNAL_ERROR;  /* "Should never reach here." */
     288
     289    runDisplay(pSelf, pfShutdown);
     290
     291    return VINF_SUCCESS;
     292}
     293
     294/**
     295 * @interface_method_impl{VBCLSERVICE,pfnStop}
     296 */
     297static DECLCALLBACK(void) stop(void)
     298{
     299    /* Nothing to do here. Implement empty callback, so
     300     * main thread can set pfShutdown=true on process termination. */
    290301}
    291302
     
    300311    init,                               /* pfnInit */
    301312    run,                                /* pfnWorker */
    302     NULL,                               /* pfnStop */
     313    stop,                               /* pfnStop */
    303314    NULL,                               /* pfnTerm */
    304315};
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