VirtualBox

Changeset 86693 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Oct 23, 2020 3:29:07 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
141075
Message:

Shared Clipboard/X11: A bit of cleanup for threading start/stop code. bugref:9848

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-x11.cpp

    r86684 r86693  
    848848    if (pCtx->fGrabClipboardOnStart)
    849849        clipQueryX11FormatsCallback(pCtx);
     850
     851    /* We're now ready to run, tell parent. */
     852    int rc2 = RTThreadUserSignal(hThreadSelf);
     853    AssertRC(rc2);
    850854
    851855    while (XtAppGetExitFlag(pCtx->appContext) == FALSE)
     
    11341138int ShClX11ThreadStart(PSHCLX11CTX pCtx, bool fGrab)
    11351139{
    1136     int rc = VINF_SUCCESS;
     1140    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    11371141
    11381142    /*
     
    11421146        return VINF_SUCCESS;
    11431147
    1144     rc = clipInit(pCtx);
     1148    int rc = clipInit(pCtx);
    11451149    if (RT_SUCCESS(rc))
    11461150    {
    11471151        clipResetX11Formats(pCtx);
    11481152        pCtx->fGrabClipboardOnStart = fGrab;
    1149     }
     1153
    11501154#ifndef TESTCASE
    1151     if (RT_SUCCESS(rc))
    1152     {
    11531155        LogRel2(("Shared Clipboard: Starting X11 event thread ...\n"));
    11541156
    11551157        rc = RTThreadCreate(&pCtx->Thread, clipEventThread, pCtx, 0,
    11561158                            RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "SHCLX11");
     1159        if (RT_SUCCESS(rc))
     1160            rc = RTThreadUserWait(pCtx->Thread, RT_MS_30SEC /* msTimeout */);
     1161
    11571162        if (RT_FAILURE(rc))
    11581163        {
     
    11601165            clipUninit(pCtx);
    11611166        }
    1162     }
    1163 #endif
     1167        else
     1168            LogRel2(("Shared Clipboard: X11 event thread started\n"));
     1169#endif
     1170    }
     1171
    11641172    return rc;
    11651173}
     
    11781186int ShClX11ThreadStop(PSHCLX11CTX pCtx)
    11791187{
    1180     int rc, rcThread;
    1181     unsigned count = 0;
    11821188    /*
    11831189     * Immediately return if we are not connected to the X server.
     
    11861192        return VINF_SUCCESS;
    11871193
    1188     LogRel(("Shared Clipboard: Stopping X11 event thread ...\n"));
     1194    LogRel2(("Shared Clipboard: Stopping X11 event thread ...\n"));
    11891195
    11901196    /* Write to the "stop" pipe. */
    11911197    clipQueueToEventThread(pCtx, clipStopEventThreadWorker, (XtPointer)pCtx);
    11921198
     1199    int rc;
     1200
    11931201#ifndef TESTCASE
    1194     do
    1195     {
    1196         rc = RTThreadWait(pCtx->Thread, 1000, &rcThread);
    1197         ++count;
    1198         Assert(RT_SUCCESS(rc) || ((VERR_TIMEOUT == rc) && (count != 5)));
    1199     } while ((VERR_TIMEOUT == rc) && (count < 300));
     1202    LogRel2(("Shared Clipboard: Waiting for X11 event thread to stop ...\n"));
     1203
     1204    int rcThread;
     1205    rc = RTThreadWait(pCtx->Thread, RT_MS_30SEC /* msTimeout */, &rcThread);
     1206    if (RT_SUCCESS(rc))
     1207        rc = rcThread;
     1208
     1209    if (RT_FAILURE(rc))
     1210        LogRel(("Shared Clipboard: Stopping X11 event thread failed with %Rrc\n", rc));
    12001211#else
    12011212    rc = VINF_SUCCESS;
    1202     rcThread = VINF_SUCCESS;
    1203     RT_NOREF_PV(count);
    1204 #endif
    1205     if (RT_SUCCESS(rc))
    1206     {
    1207         AssertRC(rcThread);
    1208     }
    1209     else
    1210         LogRel(("Shared Clipboard: Stopping X11 event thread failed with %Rrc\n", rc));
     1213#endif
     1214
     1215    LogRel2(("Shared Clipboard: X11 event thread stopped\n"));
    12111216
    12121217    clipUninit(pCtx);
    1213 
    1214     RT_NOREF_PV(rcThread);
    12151218    return rc;
    12161219}
Note: See TracChangeset for help on using the changeset viewer.

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