VirtualBox

Changeset 47695 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 13, 2013 2:40:20 PM (11 years ago)
Author:
vboxsync
Message:

Additions/GuestCtrl: Use a separate filter mask + value for message filtering.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r47620 r47695  
    138138 * @return  IPRT status code.
    139139 * @param   uClientId       The client ID returned by VbglR3GuestCtrlConnect().
    140  * @param   uFilterAdd      Context ID filter mask to add.
    141  * @param   uFilterRemove   Context ID filter mask to remove.
    142  */
    143 VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId,
    144                                             uint32_t uFilterAdd, uint32_t uFilterRemove)
     140 * @param   uValue          The value to filter messages for.
     141 * @param   uMaskAdd        Filter mask to add.
     142 * @param   uMaskRemove     Filter mask to remove.
     143 */
     144VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterSet(uint32_t uClientId, uint32_t uValue,
     145                                            uint32_t uMaskAdd, uint32_t uMaskRemove)
    145146{
    146147    HGCMMsgCmdFilterSet Msg;
     
    149150    Msg.hdr.u32ClientID = uClientId;
    150151    Msg.hdr.u32Function = GUEST_MSG_FILTER_SET; /* Tell the host we want to set a filter. */
    151     Msg.hdr.cParms      = 3;
    152 
    153     VbglHGCMParmUInt32Set(&Msg.add, uFilterAdd);
    154     VbglHGCMParmUInt32Set(&Msg.remove, uFilterRemove);
     152    Msg.hdr.cParms      = 4;
     153
     154    VbglHGCMParmUInt32Set(&Msg.value, uValue);
     155    VbglHGCMParmUInt32Set(&Msg.mask_add, uMaskAdd);
     156    VbglHGCMParmUInt32Set(&Msg.mask_remove, uMaskRemove);
    155157    VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
    156158
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r47622 r47695  
    14421442    /* The process thread is not interested in receiving any commands;
    14431443     * tell the host service. */
    1444     rc = VbglR3GuestCtrlMsgFilterSet(pProcess->uClientID, 0 /* Skip all */, 0);
     1444    rc = VbglR3GuestCtrlMsgFilterSet(pProcess->uClientID, 0 /* Skip all */,
     1445                                     0 /* Filter mask to add */, 0 /* Filter mask to remove */);
    14451446    if (RT_FAILURE(rc))
    14461447    {
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r47622 r47695  
    911911
    912912/**
    913  * Thread main routine for a forked guest session. This
    914  * thread runs in the main executable to control the forked
     913 * Thread main routine for a forked guest session process.
     914 * This thread runs in the main executable to control the forked
    915915 * session process.
    916916 *
     
    936936        /* The session thread is not interested in receiving any commands;
    937937         * tell the host service. */
    938         rc = VbglR3GuestCtrlMsgFilterSet(uClientID, 0 /* Skip all */, 0);
     938        rc = VbglR3GuestCtrlMsgFilterSet(uClientID, 0 /* Skip all */,
     939                                         0 /* Filter mask to add */, 0 /* Filter mask to remove */);
    939940        if (RT_FAILURE(rc))
    940941        {
    941942            VBoxServiceError("Unable to set message filter, rc=%Rrc\n", rc);
    942943            /* Non-critical. */
     944            rc = VINF_SUCCESS;
    943945        }
    944946    }
    945947    else
    946     {
    947948        VBoxServiceError("Error connecting to guest control service, rc=%Rrc\n", rc);
    948         return rc;
    949     }
    950 
    951     /* Let caller know that we're done initializing. */
    952     rc = RTThreadUserSignal(RTThreadSelf());
     949
     950    if (RT_FAILURE(rc))
     951        pThread->fShutdown = true;
     952
     953    /* Let caller know that we're done initializing, regardless of the result. */
     954    int rc2 = RTThreadUserSignal(RTThreadSelf());
     955    AssertRC(rc2);
     956
    953957    if (RT_FAILURE(rc))
    954958        return rc;
     
    10691073    Assert(uSessionStatus != GUEST_SESSION_NOTIFYTYPE_UNDEFINED);
    10701074    VBGLR3GUESTCTRLCMDCTX ctx = { uClientID, VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSessionID) };
    1071     int rc2 = VbglR3GuestCtrlSessionNotify(&ctx,
    1072                                            uSessionStatus, uSessionRc);
     1075    rc2 = VbglR3GuestCtrlSessionNotify(&ctx,
     1076                                       uSessionStatus, uSessionRc);
    10731077    if (RT_FAILURE(rc2))
    10741078        VBoxServiceError("Reporting session ID=%RU32 final status failed with rc=%Rrc\n",
     
    11001104         * session we don't want to handle. */
    11011105        uint32_t uFilterAdd =
    1102             VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(pSession->StartupInfo.uSessionID);
    1103         uFilterAdd |= 0x7FFFFFF; /* We only want to filter for session IDs. */
    1104 
    1105         rc = VbglR3GuestCtrlMsgFilterSet(uClientID, uFilterAdd, 0 /* Filter remove */);
     1106            VBOX_GUESTCTRL_FILTER_BY_SESSION(pSession->StartupInfo.uSessionID);
     1107        rc = VbglR3GuestCtrlMsgFilterSet(uClientID,
     1108                                         VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(pSession->StartupInfo.uSessionID),
     1109                                        uFilterAdd, 0 /* Filter remove */);
    11061110        VBoxServiceVerbose(3, "Setting message filterAdd=0x%x returned %Rrc\n",
    11071111                           uFilterAdd, rc);
     
    19301934    int rc = GstCntlSessionThreadWait(pThread,
    19311935                                      5 * 60 * 1000 /* 5 minutes timeout */, uFlags);
    1932     /** @todo Kill session process if still around? */
    19331936
    19341937    /* Remove session from list and destroy object. */
    19351938    RTListNodeRemove(&pThread->Node);
     1939
    19361940    RTMemFree(pThread);
     1941    pThread = NULL;
    19371942
    19381943    return rc;
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r47621 r47695  
    287287    int CopyTo(VBOXHGCMSVCPARM paDstParms[], uint32_t cDstParms) const
    288288    {
    289         LogFlowFunc(("pHostCmd=%p, mMsgType=%RU32, mParmCount=%RU32, mContextID=%RU32\n",
    290                      this, mMsgType, mParmCount, mContextID));
     289        LogFlowFunc(("pHostCmd=%p, mMsgType=%RU32, mParmCount=%RU32, mContextID=%RU32 (Session %RU32)\n",
     290                     this, mMsgType, mParmCount, mContextID, VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(mContextID)));
    291291
    292292        int rc = VINF_SUCCESS;
     
    478478        : mSvcHelpers(NULL),
    479479          mID(0),
    480           mFlags(0), mContextFilter(0),
     480          mFlags(0),
     481          mFilterMask(0), mFilterValue(0),
    481482          mHostCmdRc(VINF_SUCCESS), mHostCmdTries(0),
    482483          mHostCmdTS(0),
     
    487488        : mSvcHelpers(pSvcHelpers),
    488489          mID(uClientID),
    489           mFlags(0), mContextFilter(0),
     490          mFlags(0),
     491          mFilterMask(0), mFilterValue(0),
    490492          mHostCmdRc(VINF_SUCCESS), mHostCmdTries(0),
    491493          mHostCmdTS(0),
     
    571573        if (mFlags & CLIENTSTATE_FLAG_CONTEXTFILTER)
    572574        {
    573             fWant =
    574                 (pHostCmd->mContextID & mContextFilter) == pHostCmd->mContextID;
     575            fWant = (pHostCmd->mContextID & mFilterMask) == mFilterValue;
    575576        }
    576577        else /* Client is interested in all commands. */
    577578            fWant = true;
    578579
    579         LogFlowFunc(("[Client %RU32] mFlags=0x%x, mContextID=%RU32 (session %RU32), mContextFilter=0x%x, fWant=%RTbool\n",
     580        LogFlowFunc(("[Client %RU32] mFlags=0x%x, mContextID=%RU32 (session %RU32), mFilterMask=0x%x, mFilterValue=%RU32, fWant=%RTbool\n",
    580581                     mID, mFlags, pHostCmd->mContextID,
    581582                     VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCmd->mContextID),
    582                      mContextFilter, fWant));
     583                     mFilterMask, mFilterValue, fWant));
    583584
    584585        return fWant;
     
    831832    /** Client flags. @sa CLIENTSTATE_FLAG_ flags. */
    832833    uint32_t mFlags;
    833     /** The context ID filter, based on the flags set. */
    834     uint32_t mContextFilter;
     834    /** The context ID filter mask, if any. */
     835    uint32_t mFilterMask;
     836    /** The context ID filter value, if any. */
     837    uint32_t mFilterValue;
    835838    /** Host command list to process. */
    836839    HostCmdList mHostCmdList;
     
    11521155        return VERR_NOT_FOUND; /* Should never happen. */
    11531156
    1154     if (cParms != 3)
     1157    if (cParms != 4)
    11551158        return VERR_INVALID_PARAMETER;
    11561159
    1157     uint32_t uMaskAdd, uMaskRemove;
    1158     int rc = paParms[0].getUInt32(&uMaskAdd);
     1160    uint32_t uValue, uMaskAdd, uMaskRemove;
     1161    int rc = paParms[0].getUInt32(&uValue);
    11591162    if (RT_SUCCESS(rc))
    1160         rc = paParms[1].getUInt32(&uMaskRemove);
     1163        rc = paParms[1].getUInt32(&uMaskAdd);
     1164    if (RT_SUCCESS(rc))
     1165        rc = paParms[2].getUInt32(&uMaskRemove);
     1166    /** @todo paParm[3] (flags) not used yet. */
    11611167    if (RT_SUCCESS(rc))
    11621168    {
     
    11651171        clientState.mFlags |= CLIENTSTATE_FLAG_CONTEXTFILTER;
    11661172        if (uMaskAdd)
    1167             clientState.mContextFilter |= uMaskAdd;
     1173            clientState.mFilterMask |= uMaskAdd;
    11681174        if (uMaskRemove)
    1169             clientState.mContextFilter &= ~uMaskRemove;
    1170 
    1171         LogFlowFunc(("[Client %RU32] Setting message filter=0x%x set (flags=0x%x, maskAdd=0x%x, maskRemove=0x%x)\n",
    1172                      u32ClientID, clientState.mContextFilter, clientState.mFlags,
    1173                      uMaskAdd, uMaskRemove));
     1175            clientState.mFilterMask &= ~uMaskRemove;
     1176
     1177        clientState.mFilterValue = uValue;
     1178
     1179        LogFlowFunc(("[Client %RU32] Setting message filterMask=0x%x, filterVal=%RU32 set (flags=0x%x, maskAdd=0x%x, maskRemove=0x%x)\n",
     1180                     u32ClientID, clientState.mFilterMask, clientState.mFilterValue,
     1181                     clientState.mFlags, uMaskAdd, uMaskRemove));
    11741182    }
    11751183
     
    11961204
    11971205    clientState.mFlags &= ~CLIENTSTATE_FLAG_CONTEXTFILTER;
    1198     clientState.mContextFilter = 0;
     1206    clientState.mFilterMask = 0;
     1207    clientState.mFilterValue = 0;
    11991208
    12001209    LogFlowFunc(("[Client %RU32} Unset message filter\n", u32ClientID));
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