VirtualBox

Changeset 25659 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Jan 5, 2010 4:11:33 PM (15 years ago)
Author:
vboxsync
Message:

semevent*-win.cpp: Lock validation corrections.

Location:
trunk/src/VBox/Runtime/r3/win
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/semevent-win.cpp

    r25657 r25659  
    164164
    165165
    166 RTDECL(int)   RTSemEventWaitNoResume(RTSEMEVENT EventSem, unsigned cMillies)
    167 {
    168     PCRTLOCKVALSRCPOS pSrcPos = NULL;
    169 
    170     /*
    171      * Validate input.
    172      */
    173     struct RTSEMEVENTINTERNAL *pThis = EventSem;
    174     AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    175     AssertReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, VERR_INVALID_HANDLE);
    176 
    177     /*
    178      * Wait for condition.
    179      */
    180 #ifdef RTSEMEVENT_STRICT
    181     RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    182     if (pThis->fEverHadSignallers)
    183     {
    184         int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    185                                                         RTTHREADSTATE_EVENT, true);
    186         if (RT_FAILURE(rc9))
    187             return rc9;
    188     }
    189 #else
    190     RTTHREAD hThreadSelf = RTThreadSelf();
    191 #endif
    192     RTThreadBlocking(hThreadSelf, RTTHREADSTATE_EVENT, true);
    193     DWORD rc = WaitForSingleObjectEx(pThis->hev,
    194                                      cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies,
    195                                      TRUE /*fAlertable*/);
    196     RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_EVENT);
     166/** Goto avoidance. */
     167DECL_FORCE_INLINE(int) rtSemEventWaitHandleStatus(struct RTSEMEVENTINTERNAL *pThis, DWORD rc)
     168{
    197169    switch (rc)
    198170    {
     
    217189
    218190
     191RTDECL(int)   RTSemEventWaitNoResume(RTSEMEVENT EventSem, unsigned cMillies)
     192{
     193    PCRTLOCKVALSRCPOS pSrcPos = NULL;
     194
     195    /*
     196     * Validate input.
     197     */
     198    struct RTSEMEVENTINTERNAL *pThis = EventSem;
     199    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     200    AssertReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, VERR_INVALID_HANDLE);
     201
     202    /*
     203     * Wait for condition.
     204     */
     205#ifdef RTSEMEVENT_STRICT
     206    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
     207    if (pThis->fEverHadSignallers)
     208    {
     209        DWORD rc = WaitForSingleObjectEx(pThis->hev,
     210                                         0 /*Timeout*/,
     211                                         TRUE /*fAlertable*/);
     212        if (rc != WAIT_TIMEOUT || cMillies == 0)
     213            return rtSemEventWaitHandleStatus(pThis, rc);
     214        int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
     215                                                        RTTHREADSTATE_EVENT, true);
     216        if (RT_FAILURE(rc9))
     217            return rc9;
     218    }
     219#else
     220    RTTHREAD hThreadSelf = RTThreadSelf();
     221#endif
     222    RTThreadBlocking(hThreadSelf, RTTHREADSTATE_EVENT, true);
     223    DWORD rc = WaitForSingleObjectEx(pThis->hev,
     224                                     cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies,
     225                                     TRUE /*fAlertable*/);
     226    RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_EVENT);
     227    return rtSemEventWaitHandleStatus(pThis, rc);
     228}
     229
     230
    219231RTDECL(void) RTSemEventSetSignaller(RTSEMEVENT hEventSem, RTTHREAD hThread)
    220232{
  • trunk/src/VBox/Runtime/r3/win/semeventmulti-win.cpp

    r25657 r25659  
    187187
    188188
    189 RTDECL(int)  RTSemEventMultiWaitNoResume(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies)
    190 {
    191     PCRTLOCKVALSRCPOS pSrcPos = NULL;
    192 
    193     /*
    194      * Validate input.
    195      */
    196     struct RTSEMEVENTMULTIINTERNAL *pThis = EventMultiSem;
    197     AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
    198     AssertReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, VERR_INVALID_HANDLE);
    199 
    200     /*
    201      * Wait for condition.
    202      */
    203 #ifdef RTSEMEVENT_STRICT
    204     RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
    205     if (pThis->fEverHadSignallers)
    206     {
    207         int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
    208                                                         RTTHREADSTATE_EVENT_MULTI, true);
    209         if (RT_FAILURE(rc9))
    210             return rc9;
    211     }
    212 #else
    213     RTTHREAD hThreadSelf = RTThreadSelf();
    214 #endif
    215     RTThreadBlocking(hThreadSelf, RTTHREADSTATE_EVENT_MULTI, true);
    216     DWORD rc = WaitForSingleObjectEx(pThis->hev,
    217                                      cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies,
    218                                      TRUE /*fAlertable*/);
    219     RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_EVENT_MULTI);
     189/** Goto avoidance. */
     190DECL_FORCE_INLINE(int) rtSemEventWaitHandleStatus(struct RTSEMEVENTMULTIINTERNAL *pThis, DWORD rc)
     191{
    220192    switch (rc)
    221193    {
     
    240212
    241213
     214RTDECL(int)  RTSemEventMultiWaitNoResume(RTSEMEVENTMULTI EventMultiSem, unsigned cMillies)
     215{
     216    PCRTLOCKVALSRCPOS pSrcPos = NULL;
     217
     218    /*
     219     * Validate input.
     220     */
     221    struct RTSEMEVENTMULTIINTERNAL *pThis = EventMultiSem;
     222    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     223    AssertReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, VERR_INVALID_HANDLE);
     224
     225    /*
     226     * Wait for condition.
     227     */
     228#ifdef RTSEMEVENT_STRICT
     229    RTTHREAD hThreadSelf = RTThreadSelfAutoAdopt();
     230    if (pThis->fEverHadSignallers)
     231    {
     232        DWORD rc = WaitForSingleObjectEx(pThis->hev,
     233                                         0 /*Timeout*/,
     234                                         TRUE /*fAlertable*/);
     235        if (rc != WAIT_TIMEOUT || cMillies == 0)
     236            return rtSemEventWaitHandleStatus(pThis, rc);
     237        int rc9 = RTLockValidatorRecSharedCheckBlocking(&pThis->Signallers, hThreadSelf, pSrcPos, false,
     238                                                        RTTHREADSTATE_EVENT_MULTI, true);
     239        if (RT_FAILURE(rc9))
     240            return rc9;
     241    }
     242#else
     243    RTTHREAD hThreadSelf = RTThreadSelf();
     244#endif
     245    RTThreadBlocking(hThreadSelf, RTTHREADSTATE_EVENT_MULTI, true);
     246    DWORD rc = WaitForSingleObjectEx(pThis->hev,
     247                                     cMillies == RT_INDEFINITE_WAIT ? INFINITE : cMillies,
     248                                     TRUE /*fAlertable*/);
     249    RTThreadUnblocked(hThreadSelf, RTTHREADSTATE_EVENT_MULTI);
     250    return rtSemEventWaitHandleStatus(pThis, rc);
     251}
     252
     253
    242254RTDECL(void) RTSemEventMultiSetSignaller(RTSEMEVENTMULTI hEventMultiSem, RTTHREAD hThread)
    243255{
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