VirtualBox

Changeset 24917 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Nov 24, 2009 3:45:00 PM (15 years ago)
Author:
vboxsync
Message:

SSM,Main: Fixed error propagation on the target side so that a source side cancellation ends up a s VERR_SSM_CANCELLED instead of VERR_SSM_LOADED_TOO_MUCH.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImplTeleporter.cpp

    r24899 r24917  
    148148    uint32_t    u32Magic;
    149149    /** The size of the data block following this header.
    150      * 0 indicates the end of the stream. */
     150     * 0 indicates the end of the stream, while UINT32_MAX indicates
     151     * cancelation. */
    151152    uint32_t    cb;
    152153} TELEPORTERTCPHDR;
     
    388389                return rc;
    389390            }
    390             if (   Hdr.u32Magic != TELEPORTERTCPHDR_MAGIC
    391                 || Hdr.cb > TELEPORTERTCPHDR_MAX_SIZE)
    392             {
     391
     392            if (RT_UNLIKELY(   Hdr.u32Magic != TELEPORTERTCPHDR_MAGIC
     393                            || Hdr.cb > TELEPORTERTCPHDR_MAX_SIZE
     394                            || Hdr.cb == 0))
     395            {
     396                if (    Hdr.u32Magic == TELEPORTERTCPHDR_MAGIC
     397                    &&  (   Hdr.cb == 0
     398                         || Hdr.cb == UINT32_MAX)
     399                   )
     400                {
     401                    pState->mfEndOfStream = true;
     402                    pState->mcbReadBlock  = 0;
     403                    return Hdr.cb ? VERR_SSM_CANCELLED : VERR_EOF;
     404                }
    393405                pState->mfIOError = true;
    394406                LogRel(("Teleporter/TCP: Invalid block: u32Magic=%#x cb=%#x\n", Hdr.u32Magic, Hdr.cb));
     
    397409
    398410            pState->mcbReadBlock = Hdr.cb;
    399             if (!Hdr.cb)
    400             {
    401                 pState->mfEndOfStream = true;
    402                 return VERR_EOF;
    403             }
    404 
    405411            if (pState->mfStopReading)
    406412                return VERR_EOF;
     
    499505 * @copydoc SSMSTRMOPS::pfnClose
    500506 */
    501 static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser)
     507static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser, bool fCancelled)
    502508{
    503509    TeleporterState *pState = (TeleporterState *)pvUser;
     
    505511    if (pState->mfIsSource)
    506512    {
    507         TELEPORTERTCPHDR EofHdr = { TELEPORTERTCPHDR_MAGIC, 0 };
     513        TELEPORTERTCPHDR EofHdr;
     514        EofHdr.u32Magic = TELEPORTERTCPHDR_MAGIC;
     515        EofHdr.cb       = fCancelled ? UINT32_MAX : 0;
    508516        int rc = RTTcpWrite(pState->mhSocket, &EofHdr, sizeof(EofHdr));
    509517        if (RT_SUCCESS(rc))
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