VirtualBox

Changeset 14276 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 18, 2008 6:18:54 AM (16 years ago)
Author:
vboxsync
Message:

Additions/common/VBoxGuest: split VBoxGuestHGCMAsyncWaitCallback* into wrappers and a worker function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r14264 r14276  
    841841#ifdef VBOX_WITH_HGCM
    842842
     843# ifndef HGCM_TIMEOUT
    843844/**
    844845 * This is a callback for dealing with async waits.
     
    919920}
    920921
    921 
    922 # ifdef HGCM_TIMEOUT
    923 /**
    924  * This is a callback for dealing with async waits with a timeout.
    925  *
    926  * It operates in a manner similar to VBoxGuestCommonIOCtl_WaitEvent.
    927  * @todo r=bird: merge VBoxGuestHGCMAsyncWaitCallbackTimeout into
    928  *       VBoxGuestHGCMAsyncWaitCallback, either by using a stack argument or
    929  *       (better) create a common worker for them
    930  */
    931 static DECLCALLBACK(void)
    932 VBoxGuestHGCMAsyncWaitCallbackTimeout(VMMDevHGCMRequestHeader *pHdrNonVolatile, void *pvUser, uint32_t u32User)
     922# else /* HGCM_TIMEOUT defined */
     923/** Worker for VBoxGuestHGCMAsyncWaitCallback* */
     924void
     925VBoxGuestHGCMAsyncWaitCallbackWorker(VMMDevHGCMRequestHeader *pHdrNonVolatile, PVBOXGUESTDEVEXT pDevExt,
     926                                     bool fInterruptible, uint32_t u32Timeout)
    933927{
    934928    VMMDevHGCMRequestHeader volatile *pHdr = (VMMDevHGCMRequestHeader volatile *)pHdrNonVolatile;
    935     PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser;
    936     Log(("VBoxGuestHGCMAsyncWaitCallback: requestType=%d\n", pHdr->header.requestType));
    937929
    938930    /*
     
    978970    RTSpinlockReleaseNoInts(pDevExt->WaitSpinlock, &Tmp);
    979971
    980     int rc = RTSemEventMultiWaitNoResume(pWait->Event, u32User);
     972    if (fInterruptible)
     973        rc = RTSemEventMultiWaitNoResume(pWait->Event, u32Timeout);
     974    else
     975        rc = RTSemEventMultiWait(pWait->Event, u32Timeout);
    981976
    982977    /*
     
    993988    VBoxGuestWaitFreeLocked(pDevExt, pWait);
    994989    RTSpinlockReleaseNoInts(pDevExt->WaitSpinlock, &Tmp);
     990}
     991
     992/**
     993 * This is a callback for dealing with async waits.
     994 *
     995 * It operates in a manner similar to VBoxGuestCommonIOCtl_WaitEvent.
     996 */
     997static DECLCALLBACK(void)
     998VBoxGuestHGCMAsyncWaitCallback(VMMDevHGCMRequestHeader *pHdrNonVolatile, void *pvUser, uint32_t u32User)
     999{
     1000    VMMDevHGCMRequestHeader volatile *pHdr = (VMMDevHGCMRequestHeader volatile *)pHdrNonVolatile;
     1001    const bool fInterruptible = (bool)u32User;
     1002    PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser;
     1003    LogFunc(("requestType=%d\n", pHdr->header.requestType));
     1004    VBoxGuestHGCMAsyncWaitCallbackWorker(pHdrNonVolatile, pDevExt, fInterruptible, RT_INDEFINITE_WAIT);
     1005}
     1006
     1007/**
     1008 * This is a callback for dealing with async waits with a timeout.
     1009 *
     1010 * It operates in a manner similar to VBoxGuestCommonIOCtl_WaitEvent.
     1011 */
     1012static DECLCALLBACK(void)
     1013VBoxGuestHGCMAsyncWaitCallbackTimeoutInterruptible(VMMDevHGCMRequestHeader *pHdrNonVolatile,
     1014                                                   void *pvUser, uint32_t u32User)
     1015{
     1016    PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser;
     1017    LogFunc(("requestType=%d\n", pHdr->header.requestType));
     1018    VBoxGuestHGCMAsyncWaitCallbackWorker(pHdrNonVolatile, pDevExt, true, u32user);
     1019}
     1020
     1021/**
     1022 * This is an uninterruptible callback for dealing with async waits with a timeout.
     1023 *
     1024 * It operates in a manner similar to VBoxGuestCommonIOCtl_WaitEvent.
     1025 */
     1026static DECLCALLBACK(void)
     1027VBoxGuestHGCMAsyncWaitCallbackTimeout(VMMDevHGCMRequestHeader *pHdrNonVolatile, void *pvUser,
     1028                                      uint32_t u32User)
     1029{
     1030    PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser;
     1031    LogFunc(("requestType=%d\n", pHdr->header.requestType));
     1032    VBoxGuestHGCMAsyncWaitCallbackWorker(pHdrNonVolatile, pDevExt, false, u32user);
    9951033}
    9961034# endif /* HGCM_TIMEOUT */
     
    12051243     */
    12061244    Log(("VBoxGuestCommonIOCtl: HGCM_CALL: u32Client=%RX32\n", pInfo->u32ClientID));
    1207     int rc = VbglHGCMCall(pInfo, VBoxGuestHGCMAsyncWaitCallbackTimeout, pDevExt, pInfoTimeout->u32Timeout);
     1245    int rc;
     1246    if (pSession->R0Process == NIL_RTR0PROCESS)
     1247        rc = VbglHGCMCall(pInfo, VBoxGuestHGCMAsyncWaitCallbackTimeout, pDevExt, pInfoTimeout->u32Timeout);
     1248    else
     1249        rc = VbglHGCMCall(pInfo, VBoxGuestHGCMAsyncWaitCallbackTimeoutInterruptible, pDevExt,
     1250                          pInfoTimeout->u32Timeout);
    12081251    if (RT_SUCCESS(rc))
    12091252    {
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