VirtualBox

Ignore:
Timestamp:
Aug 15, 2016 12:23:46 PM (8 years ago)
Author:
vboxsync
Message:

DnD/Main: Resolved worker thread @todos.

File:
1 edited

Legend:

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

    r63252 r63471  
    584584
    585585    Assert(pThis->mDataBase.m_cTransfersPending);
    586     pThis->mDataBase.m_cTransfersPending--;
     586    if (pThis->mDataBase.m_cTransfersPending)
     587        pThis->mDataBase.m_cTransfersPending--;
    587588
    588589    LogFlowFunc(("pTarget=%p vrc=%Rrc (ignored)\n", (GuestDnDTarget *)pThis, vrc));
     
    631632    SendDataTask *pTask = NULL;
    632633    PSENDDATACTX pSendCtx = NULL;
    633     RTTHREAD rcThreadSend;
    634     int rc = S_OK;
    635634
    636635    try
     
    655654        }
    656655
    657         //this function delete pTask in case of exceptions, so there is no need in the call of delete operator
    658         //pSendCtx is deleted in the pTask destructor
    659 /** @todo r=bird: The code using hThreadSend is racing the thread termination. Since the thread isn't
    660  * created waitable, the handle goes away if we it terminates before our RTThreadUserWait call returns. */
    661         hr = pTask->createThreadWithRaceCondition(&rcThreadSend);
     656        /* This function delete pTask in case of exceptions,
     657         * so there is no need in the call of delete operator. */
     658        hr = pTask->createThreadWithType(RTTHREADTYPE_MAIN_WORKER);
    662659
    663660    }
     
    665662    {
    666663        hr = setError(E_OUTOFMEMORY);
    667         rcThreadSend = NIL_RTTHREAD;
    668664    }
    669665    catch (...)
    670666    {
    671         LogRel2(("DnD: Could not create thread for SendDataTask \n"));
     667        LogRel2(("DnD: Could not create thread for data sending task\n"));
    672668        hr = E_FAIL;
    673         rcThreadSend = NIL_RTTHREAD;
    674669    }
    675670
    676671    if (SUCCEEDED(hr))
    677672    {
    678         rc = RTThreadUserWait(rcThreadSend, 30 * 1000 /* 30s timeout */);
    679         if (RT_SUCCESS(rc))
    680         {
    681             mDataBase.m_cTransfersPending++;
    682 
    683             hr = pResp->queryProgressTo(aProgress.asOutParam());
    684             ComAssertComRC(hr);
    685 
    686             /* Note: pTask is now owned by the worker thread. */
    687         }
    688         else
    689             hr = setError(VBOX_E_IPRT_ERROR, tr("Waiting for sending thread failed (%Rrc)"), rc);
     673        mDataBase.m_cTransfersPending++;
     674
     675        hr = pResp->queryProgressTo(aProgress.asOutParam());
     676        ComAssertComRC(hr);
     677
     678        /* Note: pTask is now owned by the worker thread. */
    690679    }
    691680    else
    692         hr = setError(VBOX_E_IPRT_ERROR, tr("Starting thread for GuestDnDTarget::i_sendDataThread (%Rrc)"), rc);
     681        hr = setError(VBOX_E_IPRT_ERROR, tr("Starting thread for GuestDnDTarget::i_sendDataThread (%Rhrc)"), hr);
    693682
    694683    LogFlowFunc(("Returning hr=%Rhrc\n", hr));
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