VirtualBox

Changeset 63471 in vbox for trunk


Ignore:
Timestamp:
Aug 15, 2016 12:23:46 PM (9 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
110121
Message:

DnD/Main: Resolved worker thread @todos.

Location:
trunk/src/VBox/Main/src-client
Files:
2 edited

Legend:

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

    r63259 r63471  
    358358
    359359    RecvDataTask *pTask = NULL;
    360     RTTHREAD hThreadRcv;
    361     int rc = S_OK;
    362360
    363361    try
     
    381379        /* This function delete pTask in case of exceptions,
    382380         * so there is no need in the call of delete operator. */
    383 /** @todo r=bird: The code using hThreadRcv is racing the thread termination. Since the thread isn't
    384  * created waitable, the handle goes away if we it terminates before our RTThreadUserWait call returns. */
    385         hr = pTask->createThreadWithRaceCondition(&hThreadRcv);
     381        hr = pTask->createThreadWithType(RTTHREADTYPE_MAIN_WORKER);
    386382
    387383    }
     
    389385    {
    390386        hr = setError(E_OUTOFMEMORY);
    391         hThreadRcv = NIL_RTTHREAD;
    392387    }
    393388    catch (...)
    394389    {
    395         LogRel2(("DnD: Could not create thread for RecvDataTask \n"));
     390        LogRel2(("DnD: Could not create thread for data receiving task\n"));
    396391        hr = E_FAIL;
    397         hThreadRcv = NIL_RTTHREAD;
    398392    }
    399393
    400394    if (SUCCEEDED(hr))
    401395    {
    402         rc = RTThreadUserWait(hThreadRcv, 30 * 1000 /* 30s timeout */);
    403         if (RT_SUCCESS(rc))
    404         {
    405             mDataBase.m_cTransfersPending++;
    406 
    407             hr = pResp->queryProgressTo(aProgress.asOutParam());
    408             ComAssertComRC(hr);
    409 
    410             /* Note: pTask is now owned by the worker thread. */
    411         }
    412         else
    413             hr = setError(VBOX_E_IPRT_ERROR, tr("Waiting for receiving thread failed (%Rrc)"), rc);
     396        mDataBase.m_cTransfersPending++;
     397
     398        hr = pResp->queryProgressTo(aProgress.asOutParam());
     399        ComAssertComRC(hr);
     400
     401        /* Note: pTask is now owned by the worker thread. */
    414402    }
    415403    else
    416         hr = setError(VBOX_E_IPRT_ERROR, tr("Starting thread for GuestDnDSource::i_receiveDataThread failed (%Rrc)"), rc);
     404        hr = setError(VBOX_E_IPRT_ERROR, tr("Starting thread for GuestDnDSource::i_receiveDataThread failed (%Rhrc)"), hr);
    417405    /* Note: mDataBase.mfTransferIsPending will be set to false again by i_receiveDataThread. */
    418406
     
    10791067        return;
    10801068
    1081     int vrc = RTThreadUserSignal(RTThreadSelf());
    1082     AssertRC(vrc);
    1083 
    1084     vrc = pThis->i_receiveData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
     1069    int vrc = pThis->i_receiveData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
    10851070/** @todo
    10861071 *
     
    10921077
    10931078    Assert(pThis->mDataBase.m_cTransfersPending);
    1094     pThis->mDataBase.m_cTransfersPending--;
     1079    if (pThis->mDataBase.m_cTransfersPending)
     1080        pThis->mDataBase.m_cTransfersPending--;
    10951081
    10961082    LogFlowFunc(("pSource=%p vrc=%Rrc (ignored)\n", (GuestDnDSource *)pThis, vrc));
  • 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.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette