VirtualBox

Changeset 21102 in vbox


Ignore:
Timestamp:
Jun 30, 2009 7:38:12 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
49365
Message:

VBoxGuest (common): poll() update.

Location:
trunk/src/VBox/Additions/common/VBoxGuest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c

    r21095 r21102  
    669669
    670670/**
     671 * Asynchronous notification activation method.
     672 *
     673 * @returns 0 on success, negative errno on failure.
     674 *
     675 * @param   fd          The file descriptor.
     676 * @param   pFile       The file structure.
     677 * @param   fOn         On/off indicator.
     678 */
     679static int vboxguestFAsync(int fd, struct file *pFile, int fOn)
     680{
     681    return fasync_helper(fd, pFile, fOn, &g_pFAsyncQueue);
     682}
     683
     684
     685/**
    671686 * Poll function.
    672687 *
     
    678693 * @param   pFile       The file structure.
    679694 * @param   pPt         The poll table.
     695 *
     696 * @remarks This is probably not really used, X11 is said to use the fasync
     697 *          interface instead.
    680698 */
    681699static unsigned int vboxguestPoll(struct file *pFile, poll_table *pPt)
     
    686704                                  ? POLLIN | POLLRDNORM
    687705                                  : 0;
    688 #if 1 /** @todo this isn't quite right... but it's what we used to do. */
    689     pSession->u32MousePosChangedSeq = u32CurSeq;
    690 #endif
    691706    poll_wait(pFile, &g_PollEventQueue, pPt);
    692707    return fMask;
    693 }
    694 
    695 
    696 /**
    697  * Asynchronous notification activation method.
    698  *
    699  * @returns 0 on success, negative errno on failure.
    700  *
    701  * @param   fd          The file descriptor.
    702  * @param   pFile       The file structure.
    703  * @param   fOn         On/off indicator.
    704  */
    705 static int vboxguestFAsync(int fd, struct file *pFile, int fOn)
    706 {
    707     return fasync_helper(fd, pFile, fOn, &g_pFAsyncQueue);
    708708}
    709709
     
    718718 * @param   cbRead      The max number of bytes to read.
    719719 * @param   poff        The current file position.
     720 *
     721 * @remarks This is probably not really used as X11 lets the driver do its own
     722 *          event reading. The poll condition is therefore also cleared when we
     723 *          see VMMDevReq_GetMouseStatus in VBoxGuestCommonIOCtl_VMMRequest.
    720724 */
    721725static ssize_t vboxguestRead(struct file *pFile, char *pbBuf, size_t cbRead, loff_t *poff)
    722726{
     727    PVBOXGUESTSESSION   pSession  = (PVBOXGUESTSESSION)pFile->private_data;
     728    uint32_t            u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
     729
    723730    if (*poff != 0)
    724731        return -EINVAL;
    725732
    726     if (cbRead > 0)
    727     {
    728         /* Indicate that we're up to speed. */
    729         PVBOXGUESTSESSION   pSession    = (PVBOXGUESTSESSION)pFile->private_data;
    730         uint32_t            u32CurSeq   = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
     733    /*
     734     * Fake a single byte read if we're not up to date with the current mouse position.
     735     */
     736    if (    pSession->u32MousePosChangedSeq != u32CurSeq
     737        &&  cbRead > 0)
     738    {
    731739        pSession->u32MousePosChangedSeq = u32CurSeq;
    732 
    733740        pbBuf[0] = 0;
    734741        return 1;
    735742    }
    736 
    737 #if 1 /** @todo This is wrong, see man 2 read. Does it server any purpose? */
    738     return -EINVAL;
    739 #else
    740743    return 0;
    741 #endif
    742744}
    743745
  • trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp

    r21095 r21102  
    747747
    748748
    749 static int VBoxGuestCommonIOCtl_VMMRequest(PVBOXGUESTDEVEXT pDevExt, VMMDevRequestHeader *pReqHdr,
    750                                            size_t cbData, size_t *pcbDataReturned)
     749static int VBoxGuestCommonIOCtl_VMMRequest(PVBOXGUESTDEVEXT pDevExt, PVBOXGUESTSESSION pSession,
     750                                           VMMDevRequestHeader *pReqHdr, size_t cbData, size_t *pcbDataReturned)
    751751{
    752752    Log(("VBoxGuestCommonIOCtl: VMMREQUEST type %d\n", pReqHdr->requestType));
     
    755755     * Validate the header and request size.
    756756     */
    757     const uint32_t cbReq = pReqHdr->size;
    758     const uint32_t cbMinSize = vmmdevGetRequestSize(pReqHdr->requestType);
     757    const VMMDevRequestType enmType   = pReqHdr->requestType;
     758    const uint32_t          cbReq     = pReqHdr->size;
     759    const uint32_t          cbMinSize = vmmdevGetRequestSize(enmType);
    759760    if (cbReq < cbMinSize)
    760761    {
    761762        Log(("VBoxGuestCommonIOCtl: VMMREQUEST: invalid hdr size %#x, expected >= %#x; type=%#x!!\n",
    762              cbReq, cbMinSize, pReqHdr->requestType));
     763             cbReq, cbMinSize, enmType));
    763764        return VERR_INVALID_PARAMETER;
    764765    }
     
    766767    {
    767768        Log(("VBoxGuestCommonIOCtl: VMMREQUEST: invalid size %#x, expected >= %#x (hdr); type=%#x!!\n",
    768              cbData, cbReq, pReqHdr->requestType));
     769             cbData, cbReq, enmType));
    769770        return VERR_INVALID_PARAMETER;
    770771    }
     
    778779     */
    779780    VMMDevRequestHeader *pReqCopy;
    780     int rc = VbglGRAlloc(&pReqCopy, cbReq, pReqHdr->requestType);
     781    int rc = VbglGRAlloc(&pReqCopy, cbReq, enmType);
    781782    if (RT_FAILURE(rc))
    782783    {
     
    785786        return rc;
    786787    }
    787 
    788788    memcpy(pReqCopy, pReqHdr, cbReq);
     789
     790    if (enmType == VMMDevReq_GetMouseStatus) /* clear poll condition. */
     791        pSession->u32MousePosChangedSeq = ASMAtomicUoReadU32(&pDevExt->u32MousePosChangedSeq);
     792
    789793    rc = VbglGRPerform(pReqCopy);
    790794    if (    RT_SUCCESS(rc)
     
    12691273    {
    12701274        CHECKRET_MIN_SIZE("VMMREQUEST", sizeof(VMMDevRequestHeader));
    1271         rc = VBoxGuestCommonIOCtl_VMMRequest(pDevExt, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned);
     1275        rc = VBoxGuestCommonIOCtl_VMMRequest(pDevExt, pSession, (VMMDevRequestHeader *)pvData, cbData, pcbDataReturned);
    12721276    }
    12731277#ifdef VBOX_WITH_HGCM
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