VirtualBox

Changeset 93167 in vbox for trunk/src


Ignore:
Timestamp:
Jan 10, 2022 5:45:55 PM (3 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Relaxed guest session locks a bit by using read locks instead of write locks where doable, as the internal event (de)registration has its own critical section and doesn't need to be protected by the object's write lock. Added some missing docs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r93166 r93167  
    666666 *                              was returned. Optional.
    667667 *
    668  * @note    Takes the write lock.
     668 * @note    Takes the read lock.
    669669 */
    670670int GuestSession::i_closeSession(uint32_t uFlags, uint32_t uTimeoutMS, int *prcGuest)
     
    674674    LogFlowThisFunc(("uFlags=%x, uTimeoutMS=%RU32\n", uFlags, uTimeoutMS));
    675675
    676     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     676    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    677677
    678678    /* Guest Additions < 4.3 don't support closing dedicated
     
    713713    LogFlowThisFunc(("Sending closing request to guest session ID=%RU32, uFlags=%x\n",
    714714                     mData.mSession.mID, uFlags));
     715
     716    alock.release();
    715717
    716718    VBOXHGCMSVCPARM paParms[4];
     
    718720    HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
    719721    HGCMSvcSetU32(&paParms[i++], uFlags);
    720 
    721     alock.release(); /* Drop the write lock before waiting. */
    722722
    723723    vrc = i_sendMessage(HOST_MSG_SESSION_CLOSE, i, paParms, VBOX_GUESTCTRL_DST_BOTH);
     
    10891089 * @param   prcGuest            Where to return the guest error when VERR_GSTCTL_GUEST_ERROR
    10901090 *                              was returned. Optional.
     1091 *
     1092 * @note    Takes the read lock.
    10911093 */
    10921094int GuestSession::i_directoryRemove(const Utf8Str &strPath, uint32_t fFlags, int *prcGuest)
     
    10971099    LogFlowThisFunc(("strPath=%s, uFlags=0x%x\n", strPath.c_str(), fFlags));
    10981100
    1099     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     1101    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    11001102
    11011103    GuestWaitEvent *pEvent = NULL;
     
    11121114    HGCMSvcSetU32(&paParms[i++], fFlags);
    11131115
    1114     alock.release(); /* Drop write lock before sending. */
     1116    alock.release(); /* Drop lock before sending. */
    11151117
    11161118    vrc = i_sendMessage(HOST_MSG_DIR_REMOVE, i, paParms);
     
    13111313 * @param  pCtxCb               Host callback context.
    13121314 * @param  pSvcCb               Service callback data.
     1315 *
     1316 * @note   Takes the read lock.
    13131317 */
    13141318int GuestSession::i_dispatchToObject(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb)
     
    19591963 * Called by IGuest right before this session gets removed from
    19601964 * the public session list.
     1965 *
     1966 * @note    Takes the write lock.
    19611967 */
    19621968int GuestSession::i_onRemove(void)
     
    21412147 * @param   prcGuest            Where to return the guest error when VERR_GSTCTL_GUEST_ERROR
    21422148 *                              was returned. Optional.
     2149 *
     2150 * @note    Takes the write lock.
    21432151 */
    21442152int GuestSession::i_startSession(int *prcGuest)
     
    21672175    /* Set current session status. */
    21682176    mData.mStatus = GuestSessionStatus_Starting;
    2169     mData.mRC = VINF_SUCCESS; /* Clear previous error, if any. */
     2177    mData.mRC     = VINF_SUCCESS; /* Clear previous error, if any. */
    21702178
    21712179    int vrc;
     
    22002208    HGCMSvcSetU32(&paParms[i++], mData.mSession.mOpenFlags);
    22012209
    2202     alock.release(); /* Drop write lock before sending. */
     2210    alock.release(); /* Drop lock before sending. */
    22032211
    22042212    vrc = i_sendMessage(HOST_MSG_SESSION_CREATE, i, paParms, VBOX_GUESTCTRL_DST_ROOT_SVC);
     
    22112219    else
    22122220    {
     2221        alock.acquire(); /* Re-aquire lock before changing status. */
     2222
    22132223        /*
    22142224         * Unable to start guest session - update its current state.
     
    23562366 * @retval  VERR_NOT_FOUND if the object ID was not found.
    23572367 * @param   idObject        Object ID to unregister.
     2368 *
     2369 * @note    Takes the write lock.
    23582370 */
    23592371int GuestSession::i_objectUnregister(uint32_t idObject)
     
    24692481 * @param   prcGuest            Where to return the guest error when VERR_GSTCTL_GUEST_ERROR
    24702482 *                              was returned. Optional.
    2471  * @note    Takes the write lock.
     2483 * @note    Takes the read lock.
    24722484 */
    24732485int GuestSession::i_pathRename(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *prcGuest)
     
    24782490                     strSource.c_str(), strDest.c_str(), uFlags));
    24792491
    2480     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2492    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    24812493
    24822494    GuestWaitEvent *pEvent = NULL;
     
    24952507    HGCMSvcSetU32(&paParms[i++], uFlags);
    24962508
    2497     alock.release(); /* Drop write lock before sending. */
     2509    alock.release(); /* Drop lock before sending. */
    24982510
    24992511    vrc = i_sendMessage(HOST_MSG_PATH_RENAME, i, paParms);
     
    25202532 *                              Any other return code indicates some host side error.
    25212533 *
    2522  * @note    Takes the write lock.
     2534 * @note    Takes the read lock.
    25232535 */
    25242536int GuestSession::i_pathUserDocuments(Utf8Str &strPath, int *prcGuest)
    25252537{
    2526     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2538    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    25272539
    25282540    /** @todo Cache the user's document path? */
     
    25382550    HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
    25392551
    2540     alock.release(); /* Drop write lock before sending. */
     2552    alock.release(); /* Drop lock before sending. */
    25412553
    25422554    vrc = i_sendMessage(HOST_MSG_PATH_USER_DOCUMENTS, i, paParms);
     
    25722584 *                              Any other return code indicates some host side error.
    25732585 *
    2574  * @note    Takes the write lock.
     2586 * @note    Takes the read lock.
    25752587 */
    25762588int GuestSession::i_pathUserHome(Utf8Str &strPath, int *prcGuest)
    25772589{
    2578     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2590    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    25792591
    25802592    /** @todo Cache the user's home path? */
     
    25902602    HGCMSvcSetU32(&paParms[i++], pEvent->ContextID());
    25912603
    2592     alock.release(); /* Drop write lock before sending. */
     2604    alock.release(); /* Drop lock before sending. */
    25932605
    25942606    vrc = i_sendMessage(HOST_MSG_PATH_USER_HOME, i, paParms);
     
    29572969 *                              Any other return code indicates some host side error.
    29582970 *
    2959  * @note    Takes the write lock.
     2971 * @note    Takes the read lock.
    29602972 */
    29612973int GuestSession::i_shutdown(uint32_t fFlags, int *prcGuest)
    29622974{
    2963     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     2975    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
    29642976
    29652977    AssertPtrReturn(mParent, VERR_INVALID_POINTER);
     
    29802992    HGCMSvcSetU32(&paParms[i++], fFlags);
    29812993
    2982     alock.release(); /* Drop write lock before sending. */
     2994    alock.release(); /* Drop lock before sending. */
    29832995
    29842996    int rcGuest = VERR_IPE_UNINITIALIZED_STATUS;
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