VirtualBox

Changeset 100660 in vbox for trunk


Ignore:
Timestamp:
Jul 20, 2023 9:55:41 AM (19 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
158499
Message:

Shared Clipboard: Added ShClTransferStop() for stopping an already started transfer (thread). bugref:9437

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/SharedClipboard-transfers.h

    r100636 r100660  
    11291129int ShClTransferRun(PSHCLTRANSFER pTransfer, PFNSHCLTRANSFERTHREAD pfnThreadFunc, void *pvUser);
    11301130int ShClTransferStart(PSHCLTRANSFER pTransfer);
     1131int ShClTransferStop(PSHCLTRANSFER pTransfer);
    11311132int ShClTransferComplete(PSHCLTRANSFER pTransfer);
    11321133int ShClTransferCancel(PSHCLTRANSFER pTransfer);
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-transfers.cpp

    r100649 r100660  
    12241224    pTransfer->cObjHandles     = 0;
    12251225    pTransfer->uObjHandleNext  = 1;
     1226
     1227    pTransfer->Thread.fStarted   = false;
     1228    pTransfer->Thread.fStop      = false;
     1229    pTransfer->Thread.fCancelled = false;
    12261230
    12271231    int rc = shClTransferSetStatus(pTransfer, SHCLTRANSFERSTATUS_INITIALIZED);
     
    22142218
    22152219/**
     2220 * Stops a started transfer.
     2221 *
     2222 * @returns VBox status code.
     2223 * @param   pTransfer           Clipboard transfer to stop.
     2224 */
     2225int ShClTransferStop(PSHCLTRANSFER pTransfer)
     2226{
     2227    AssertPtrReturn(pTransfer, VERR_INVALID_POINTER);
     2228
     2229    LogFlowFuncEnter();
     2230
     2231    int rc = shClTransferThreadDestroy(pTransfer, SHCL_TIMEOUT_DEFAULT_MS);
     2232
     2233    LogFlowFuncLeaveRC(rc);
     2234    return rc;
     2235}
     2236
     2237/**
    22162238 * Completes a transfer (as successful).
    22172239 *
     
    24312453 * Destroys the thread of a clipboard transfer.
    24322454 *
    2433  * @returns VBox status code.
     2455 * @returns VBox status code. Will return thread rc.
    24342456 * @param   pTransfer           Clipboard transfer to destroy thread for.
    24352457 * @param   uTimeoutMs          Timeout (in ms) to wait for thread destruction.
     
    24412463    shClTransferLock(pTransfer);
    24422464
    2443     if (pTransfer->Thread.hThread == NIL_RTTHREAD)
     2465    if (!pTransfer->Thread.fStarted)
    24442466    {
    24452467        shClTransferUnlock(pTransfer);
     
    24552477
    24562478    int rcThread = VERR_IPE_UNINITIALIZED_STATUS;
     2479    Assert(pTransfer->Thread.hThread != NIL_RTTHREAD);
    24572480    int rc = RTThreadWait(pTransfer->Thread.hThread, uTimeoutMs, &rcThread);
    24582481
    24592482    LogFlowFunc(("Waiting for thread resulted in %Rrc (thread exited with %Rrc)\n", rc, rcThread));
    24602483
     2484    if (RT_SUCCESS(rc))
     2485    {
     2486        pTransfer->Thread.fStarted = false;
     2487        pTransfer->Thread.hThread  = NIL_RTTHREAD;
     2488
     2489        rc = rcThread; /* Return the thread rc to the caller. */
     2490    }
     2491    else
     2492        LogRel(("Shared Clipboard: Waiting for thread of transfer %RU16 failed with %Rrc\n", pTransfer->State.uID, rc));
     2493
     2494    LogFlowFuncLeaveRC(rc);
    24612495    return rc;
    24622496}
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