VirtualBox

Changeset 26363 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Feb 9, 2010 1:26:17 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
57456
Message:

thread-posix.cpp: RTThreadPoke is optional, don't assert if the signal is in use. Build fix for IN_GUEST change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r26361 r26363  
    6868/** The pthread key in which we store the pointer to our own PRTTHREAD structure. */
    6969static pthread_key_t    g_SelfKey;
     70#ifdef RTTHREAD_POSIX_POKE_SIG
     71/** Set if we can poke a thread, clear if we cannot. */
     72static bool             g_fCanPokeThread;
     73#endif
    7074
    7175
     
    9094#ifdef RTTHREAD_POSIX_POKE_SIG
    9195    /*
    92      * Register the dummy signal handler for RTThreadPoke.
    93      * (Assert may explode here, but at least we'll notice.)
    94      */
    95     struct sigaction SigAct;
    96     memset(&SigAct, '\0', sizeof(SigAct));
    97     SigAct.sa_handler = rtThreadPosixPokeSignal;
    98     sigfillset(&SigAct.sa_mask);
    99     SigAct.sa_flags = 0;
    100 
     96     * Try register the dummy signal handler for RTThreadPoke.
     97     */
     98    g_fCanPokeThread = false;
    10199    struct sigaction SigActOld;
    102     if (!sigaction(RTTHREAD_POSIX_POKE_SIG, &SigAct, &SigActOld))
    103         Assert(SigActOld.sa_handler == SIG_DFL);
     100    if (!sigaction(RTTHREAD_POSIX_POKE_SIG, NULL, &SigActOld))
     101    {
     102        if (   SigActOld.sa_handler == SIG_DFL
     103            || SigActOld.sa_handler == rtThreadPosixPokeSignal)
     104        {
     105            struct sigaction SigAct;
     106            memset(&SigAct, '\0', sizeof(SigAct));
     107            SigAct.sa_handler = rtThreadPosixPokeSignal;
     108            sigfillset(&SigAct.sa_mask);
     109            SigAct.sa_flags = 0;
     110
     111            /* ASSUMES no sigaction race... (lazy bird) */
     112            if (!sigaction(RTTHREAD_POSIX_POKE_SIG, &SigAct, NULL))
     113                g_fCanPokeThread = true;
     114            else
     115            {
     116                AssertMsgFailed(("rc=%Rrc errno=%d\n", RTErrConvertFromErrno(errno), errno));
     117                pthread_key_delete(g_SelfKey);
     118                g_SelfKey = 0;
     119            }
     120        }
     121    }
    104122    else
    105     {
    106         rc = RTErrConvertFromErrno(errno);
    107         AssertMsgFailed(("rc=%Rrc errno=%d\n", rc, errno));
    108         pthread_key_delete(g_SelfKey);
    109         g_SelfKey = 0;
    110     }
     123        AssertMsgFailed(("rc=%Rrc errno=%d\n", RTErrConvertFromErrno(errno), errno));
    111124#endif /* RTTHREAD_POSIX_POKE_SIG */
    112125    return rc;
     
    164177    sigaddset(&SigSet, SIGALRM);
    165178    sigprocmask(SIG_BLOCK, &SigSet, NULL);
    166     siginterrupt(RTTHREAD_POSIX_POKE_SIG, 1);
     179#ifdef RTTHREAD_POSIX_POKE_SIG
     180    if (g_fCanPokeThread)
     181        siginterrupt(RTTHREAD_POSIX_POKE_SIG, 1);
     182#endif
    167183
    168184    int rc = pthread_setspecific(g_SelfKey, pThread);
     
    197213    sigaddset(&SigSet, SIGALRM);
    198214    sigprocmask(SIG_BLOCK, &SigSet, NULL);
    199     siginterrupt(RTTHREAD_POSIX_POKE_SIG, 1);
     215#ifdef RTTHREAD_POSIX_POKE_SIG
     216    if (g_fCanPokeThread)
     217        siginterrupt(RTTHREAD_POSIX_POKE_SIG, 1);
     218#endif
    200219
    201220    int rc = pthread_setspecific(g_SelfKey, pThread);
     
    349368    PRTTHREADINT pThread = rtThreadGet(hThread);
    350369    AssertReturn(pThread, VERR_INVALID_HANDLE);
    351 
    352     int rc = pthread_kill((pthread_t)(uintptr_t)pThread->Core.Key, RTTHREAD_POSIX_POKE_SIG);
     370    int rc;
     371    if (g_fCanPokeThread)
     372    {
     373        rc = pthread_kill((pthread_t)(uintptr_t)pThread->Core.Key, RTTHREAD_POSIX_POKE_SIG);
     374        rc = RTErrConvertFromErrno(rc);
     375    }
     376    else
     377        rc = VERR_NOT_SUPPORTED;
    353378
    354379    rtThreadRelease(pThread);
    355     return RTErrConvertFromErrno(rc);
    356 }
    357 #endif
    358 
     380    return rc;
     381}
     382#endif
     383
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