VirtualBox

Changeset 74495 in vbox


Ignore:
Timestamp:
Sep 27, 2018 12:08:01 PM (6 years ago)
Author:
vboxsync
Message:

DnD/Main: Cleaned up / documented error handling for GuestDnDSource::i_receiveDataThreadTask() and GuestDnDTarget::i_sendDataThreadTask().

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

Legend:

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

    r74492 r74495  
    55
    66/*
    7  * Copyright (C) 2014-2017 Oracle Corporation
     7 * Copyright (C) 2014-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    10661066
    10671067    int vrc = pThis->i_receiveData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
    1068     AssertRC(vrc);
    1069 /** @todo
    1070  *
    1071  *  r=bird: What happens with @a vrc?
    1072  *
    1073  */
     1068    if (RT_FAILURE(vrc)) /* In case we missed some error handling within i_receiveData(). */
     1069    {
     1070        AssertFailed();
     1071        LogRel(("DnD: Receiving data from guest failed with %Rrc\n", vrc));
     1072    }
    10741073
    10751074    AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS);
     
    10791078        pThis->mDataBase.m_cTransfersPending--;
    10801079
    1081     LogFlowFunc(("pSource=%p vrc=%Rrc (ignored)\n", (GuestDnDSource *)pThis, vrc));
     1080    LogFlowFunc(("pSource=%p, vrc=%Rrc (ignored)\n", (GuestDnDSource *)pThis, vrc));
    10821081}
    10831082
     
    11601159    if (RT_FAILURE(rc))
    11611160    {
    1162         if (rc == VERR_CANCELLED)
    1163         {
    1164             int rc2 = pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED);
     1161        if (rc == VERR_CANCELLED) /* Transfer was cancelled by the host. */
     1162        {
     1163            /*
     1164             * Now that we've cleaned up tell the guest side to cancel.
     1165             * This does not imply we're waiting for the guest to react, as the
     1166             * host side never must depend on anything from the guest.
     1167             */
     1168            int rc2 = sendCancel();
    11651169            AssertRC(rc2);
    11661170
    1167             rc2 = sendCancel();
     1171            rc2 = pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED);
    11681172            AssertRC(rc2);
    11691173        }
     
    11741178            AssertRC(rc2);
    11751179        }
     1180
     1181        rc = VINF_SUCCESS; /* The error was handled by the setProgress() calls above. */
    11761182    }
    11771183
     
    12781284    if (RT_FAILURE(rc))
    12791285    {
     1286        int rc2 = droppedFiles.Rollback();
     1287        if (RT_FAILURE(rc2))
     1288            LogRel(("DnD: Deleting left over temporary files failed (%Rrc), please remove directory '%s' manually\n",
     1289                    rc2, droppedFiles.GetDirAbs()));
     1290
    12801291        if (rc == VERR_CANCELLED)
    12811292        {
    1282             int rc2 = pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED);
     1293            /*
     1294             * Now that we've cleaned up tell the guest side to cancel.
     1295             * This does not imply we're waiting for the guest to react, as the
     1296             * host side never must depend on anything from the guest.
     1297             */
     1298            rc2 = sendCancel();
    12831299            AssertRC(rc2);
    12841300
    1285             rc2 = sendCancel();
     1301            rc2 = pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED);
    12861302            AssertRC(rc2);
    12871303        }
     
    12921308            AssertRC(rc2);
    12931309        }
    1294     }
    1295 
    1296     if (RT_FAILURE(rc))
    1297     {
    1298         int rc2 = droppedFiles.Rollback();
    1299         if (RT_FAILURE(rc2))
    1300             LogRel(("DnD: Deleting left over temporary files failed (%Rrc). Please remove directory manually: %s\n",
    1301                     rc2, droppedFiles.GetDirAbs()));
     1310
     1311        rc = VINF_SUCCESS; /* The error was handled by the setProgress() calls above. */
    13021312    }
    13031313
  • trunk/src/VBox/Main/src-client/GuestDnDTargetImpl.cpp

    r74492 r74495  
    55
    66/*
    7  * Copyright (C) 2014-2017 Oracle Corporation
     7 * Copyright (C) 2014-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    567567{
    568568    LogFlowFunc(("pTask=%p\n", pTask));
    569 
    570569    AssertPtrReturnVoid(pTask);
    571570
     
    578577
    579578    int vrc = pThis->i_sendData(pTask->getCtx(), RT_INDEFINITE_WAIT /* msTimeout */);
    580     NOREF(vrc);
    581 /** @todo
    582  *
    583  *  r=bird: What happens with @a vrc?
    584  *
    585  */
     579    if (RT_FAILURE(vrc)) /* In case we missed some error handling within i_sendData(). */
     580    {
     581        AssertFailed();
     582        LogRel(("DnD: Sending data to guest failed with %Rrc\n", vrc));
     583    }
    586584
    587585    AutoWriteLock alock(pThis COMMA_LOCKVAL_SRC_POS);
     
    591589        pThis->mDataBase.m_cTransfersPending--;
    592590
    593     LogFlowFunc(("pTarget=%p vrc=%Rrc (ignored)\n", (GuestDnDTarget *)pThis, vrc));
     591    LogFlowFunc(("pTarget=%p, vrc=%Rrc (ignored)\n", (GuestDnDTarget *)pThis, vrc));
    594592}
    595593
     
    14191417    if (RT_FAILURE(rc))
    14201418    {
    1421         if (rc == VERR_CANCELLED)
    1422             pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED, VINF_SUCCESS);
     1419        if (rc == VERR_CANCELLED) /* Transfer was cancelled by the host. */
     1420        {
     1421            /*
     1422             * Now that we've cleaned up tell the guest side to cancel.
     1423             * This does not imply we're waiting for the guest to react, as the
     1424             * host side never must depend on anything from the guest.
     1425             */
     1426            int rc2 = sendCancel();
     1427            AssertRC(rc2);
     1428
     1429            rc2 = pCtx->mpResp->setProgress(100, DND_PROGRESS_CANCELLED, VINF_SUCCESS);
     1430            AssertRC(rc2);
     1431        }
    14231432        else if (rc != VERR_GSTDND_GUEST_ERROR) /* Guest-side error are already handled in the callback. */
    1424             pCtx->mpResp->setProgress(100, DND_PROGRESS_ERROR, rc,
    1425                                       GuestDnDTarget::i_hostErrorToString(rc));
    1426     }
    1427 
    1428     /*
    1429      * Now that we've cleaned up tell the guest side to cancel.
    1430      * This does not imply we're waiting for the guest to react, as the
    1431      * host side never must depend on anything from the guest.
    1432      */
    1433     if (rc == VERR_CANCELLED)
    1434     {
    1435         int rc2 = sendCancel();
    1436         AssertRC(rc2);
     1433        {
     1434            int rc2 = pCtx->mpResp->setProgress(100, DND_PROGRESS_ERROR, rc,
     1435                                                GuestDnDTarget::i_hostErrorToString(rc));
     1436            AssertRC(rc2);
     1437        }
     1438
     1439        rc = VINF_SUCCESS; /* The error was handled by the setProgress() calls above. */
    14371440    }
    14381441
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