VirtualBox

Changeset 12791 in vbox


Ignore:
Timestamp:
Sep 29, 2008 12:12:27 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
37136
Message:

SharedClipboard/x11.cpp: Handle failure of the worker thread better and added a r=bird @todo on the subject of the short timeout. We cannot return failure if the thread is still running because that will lead to a SIGSEGV after dlclose.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedClipboard/x11.cpp

    r11382 r12791  
    798798    rc = RTThreadCreate(&g_ctx.thread, vboxClipboardThread, 0, 0, RTTHREADTYPE_IO,
    799799                        RTTHREADFLAGS_WAITABLE, "SHCLIP");
    800     if (RT_FAILURE(rc))
    801     {
    802         LogRel(("vboxClipboardInit: failed to create the clipboard thread.\n"));
    803         RTSemEventDestroy(g_ctx.waitForData);
    804         RTSemMutexDestroy(g_ctx.asyncMutex);
    805         AssertRCReturn(rc, rc);
    806     }
    807     return RTThreadUserWait(g_ctx.thread, 1000);
     800    AssertRC(rc);
     801    if (RT_SUCCESS(rc))
     802    {
     803        /*
     804         * Wait for the thread to initialize.
     805         *
     806         * We must *NOT* return failure on a timeout because then the code will be
     807         * unloaded and we'll be SIGSEGV'ing in the thread.
     808         */
     809        /** @todo r=bird: This isn't very reliable, waiting for just one second and
     810         *        not signalling on failure. *grumble* */
     811        int rcThread = VERR_WRONG_ORDER;
     812        rc = RTThreadUserWait(g_ctx.thread, 1000);
     813        if (RT_SUCCESS(rc))
     814        {
     815            /* paranoia: check that the thread is actually running */
     816            rc = RTThreadWait(g_ctx.thread, 0, &rcThread);
     817            Assert(rc == VERR_TIMEOUT);
     818            if (RT_FAILURE(rc))
     819                return VINF_SUCCESS;
     820            LogRel(("vboxClipboardInit: thread died unexpectedly, rcThread=%Rrc, rcWait=%Rrc\n", rcThread, rc));
     821        }
     822        else
     823        {
     824            LogRel(("vboxClipboardInit: thread failed to start in a timely manner, rc=%Rrc\n", rc));
     825            rc = RTThreadWait(g_ctx.thread, 30000, &rcThread);
     826            if (RT_FAILURE(rc))
     827            {
     828                LogRel(("vboxClipboardInit: thread still running! (rcThread=%Rrc, rcWait=%Rrc)\n", rcThread, rc));
     829                return VINF_SUCCESS;
     830            }
     831            LogRel(("vboxClipboardInit: rcThread=%Rrc, rcWait=%Rrc\n", rcThread, rc));
     832            rc = RT_FAILURE(rcThread) ? rcThread : VERR_INTERNAL_ERROR;
     833        }
     834    }
     835    else
     836        LogRel(("vboxClipboardInit: failed to create the clipboard thread. rc=%Rrc\n", rc));
     837    RTSemEventDestroy(g_ctx.waitForData);
     838    RTSemMutexDestroy(g_ctx.asyncMutex);
     839    return rc;
    808840}
    809841
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