Changeset 24917 in vbox
- Timestamp:
- Nov 24, 2009 3:45:00 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/ssm.h
r24895 r24917 979 979 * @returns VBox status code. 980 980 * @param pvUser The user argument. 981 * @param fCancelled True if the operation was cancelled. 981 982 */ 982 DECLCALLBACKMEMBER(int, pfnClose)(void *pvUser );983 DECLCALLBACKMEMBER(int, pfnClose)(void *pvUser, bool fCancelled); 983 984 984 985 /** Struct magic + version (SSMSTRMOPS_VERSION). */ -
trunk/src/VBox/Main/ConsoleImplTeleporter.cpp
r24899 r24917 148 148 uint32_t u32Magic; 149 149 /** 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. */ 151 152 uint32_t cb; 152 153 } TELEPORTERTCPHDR; … … 388 389 return rc; 389 390 } 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 } 393 405 pState->mfIOError = true; 394 406 LogRel(("Teleporter/TCP: Invalid block: u32Magic=%#x cb=%#x\n", Hdr.u32Magic, Hdr.cb)); … … 397 409 398 410 pState->mcbReadBlock = Hdr.cb; 399 if (!Hdr.cb)400 {401 pState->mfEndOfStream = true;402 return VERR_EOF;403 }404 405 411 if (pState->mfStopReading) 406 412 return VERR_EOF; … … 499 505 * @copydoc SSMSTRMOPS::pfnClose 500 506 */ 501 static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser )507 static DECLCALLBACK(int) teleporterTcpOpClose(void *pvUser, bool fCancelled) 502 508 { 503 509 TeleporterState *pState = (TeleporterState *)pvUser; … … 505 511 if (pState->mfIsSource) 506 512 { 507 TELEPORTERTCPHDR EofHdr = { TELEPORTERTCPHDR_MAGIC, 0 }; 513 TELEPORTERTCPHDR EofHdr; 514 EofHdr.u32Magic = TELEPORTERTCPHDR_MAGIC; 515 EofHdr.cb = fCancelled ? UINT32_MAX : 0; 508 516 int rc = RTTcpWrite(pState->mhSocket, &EofHdr, sizeof(EofHdr)); 509 517 if (RT_SUCCESS(rc)) -
trunk/src/VBox/VMM/SSM.cpp
r24897 r24917 1812 1812 * @copydoc SSMSTRMOPS::pfnClose 1813 1813 */ 1814 static DECLCALLBACK(int) ssmR3FileClose(void *pvUser) 1815 { 1814 static DECLCALLBACK(int) ssmR3FileClose(void *pvUser, bool fCancelled) 1815 { 1816 NOREF(fCancelled); 1816 1817 return RTFileClose((RTFILE)(uintptr_t)pvUser); 1817 1818 } … … 2157 2158 * @returns VBox status code. 2158 2159 * @param pStrm The stream handle. 2159 */ 2160 static int ssmR3StrmClose(PSSMSTRM pStrm) 2160 * @param fCancelled Indicates whether the operation was cancelled or 2161 * not. 2162 */ 2163 static int ssmR3StrmClose(PSSMSTRM pStrm, bool fCancelled) 2161 2164 { 2162 2165 /* … … 2185 2188 } 2186 2189 2187 rc = pStrm->pOps->pfnClose(pStrm->pvUser );2190 rc = pStrm->pOps->pfnClose(pStrm->pvUser, fCancelled); 2188 2191 if (RT_FAILURE(rc)) 2189 2192 ssmR3StrmSetError(pStrm, rc); … … 2191 2194 else 2192 2195 { 2193 rc = pStrm->pOps->pfnClose(pStrm->pvUser );2196 rc = pStrm->pOps->pfnClose(pStrm->pvUser, fCancelled); 2194 2197 if (RT_FAILURE(rc)) 2195 2198 ssmR3StrmSetError(pStrm, rc); … … 4126 4129 */ 4127 4130 ssmR3SetCancellable(pVM, pSSM, false); 4128 int rc = ssmR3StrmClose(&pSSM->Strm );4131 int rc = ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED); 4129 4132 if (RT_SUCCESS(rc)) 4130 4133 rc = pSSM->rc; … … 5224 5227 } 5225 5228 /* bail out. */ 5226 int rc2 = ssmR3StrmClose(&pSSM->Strm );5229 int rc2 = ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED); 5227 5230 RTMemFree(pSSM); 5228 5231 rc2 = RTFileDelete(pszFilename); … … 5275 5278 * decompressor, for saved file format version 1. 5276 5279 * 5277 * @returns VBox status code. 5280 * @returns VBox status code. Set pSSM->rc on error. 5278 5281 * @param pvSSM The SSM handle. 5279 5282 * @param pvBuf Where to store the compressed data. … … 5299 5302 return VINF_SUCCESS; 5300 5303 } 5301 return rc;5304 return pSSM->rc = rc; 5302 5305 } 5303 5306 5304 5307 if (pSSM->enmAfter != SSMAFTER_DEBUG_IT) 5305 5308 AssertMsgFailed(("SSM: attempted reading more than the unit!\n")); 5306 return VERR_SSM_LOADED_TOO_MUCH;5309 return pSSM->rc = VERR_SSM_LOADED_TOO_MUCH; 5307 5310 } 5308 5311 … … 5310 5313 /** 5311 5314 * Internal read worker for reading data from a version 1 unit. 5315 * 5316 * @returns VBox status code, pSSM->rc is set on error. 5312 5317 * 5313 5318 * @param pSSM The saved state handle. … … 5396 5401 * Read reader that keep works the progress indicator and unit offset. 5397 5402 * 5398 * Does not set SSM::rc. 5399 * 5400 * @returns VBox status code. 5403 * @returns VBox status code. Does NOT set pSSM->rc. 5401 5404 * @param pSSM The saved state handle. 5402 5405 * @param pvBuf Where to put the bits … … 5413 5416 } 5414 5417 5415 /** @todo weed out lazy saving */ 5418 if (rc == VERR_SSM_CANCELLED) 5419 return rc; 5420 5416 5421 if (pSSM->enmAfter != SSMAFTER_DEBUG_IT) 5417 5422 AssertMsgFailed(("SSM: attempted reading more than the unit!\n")); … … 5423 5428 * Reads and checks the LZF "header". 5424 5429 * 5425 * @returns VBox status code. 5430 * @returns VBox status code. Sets pSSM->rc on error. 5426 5431 * @param pSSM The saved state handle.. 5427 5432 * @param pcbDecompr Where to store the size of the decompressed data. … … 5438 5443 int rc = ssmR3DataReadV2Raw(pSSM, &cKB, 1); 5439 5444 if (RT_FAILURE(rc)) 5440 return rc;5445 return pSSM->rc = rc; 5441 5446 pSSM->u.Read.cbRecLeft -= sizeof(cKB); 5442 5447 … … 5456 5461 * buffer. 5457 5462 * 5458 * @returns VBox status code. 5463 * @returns VBox status code. Sets pSSM->rc on error. 5459 5464 * @param SSM The saved state handle. 5460 5465 * @param pvDst Pointer to the output buffer. … … 5480 5485 rc = ssmR3DataReadV2Raw(pSSM, &pSSM->u.Read.abComprBuffer[0], cbCompr); 5481 5486 if (RT_FAILURE(rc)) 5482 return rc;5487 return pSSM->rc = rc; 5483 5488 pb = &pSSM->u.Read.abComprBuffer[0]; 5484 5489 } … … 5498 5503 5499 5504 AssertLogRelMsgFailed(("cbCompr=%#x cbDecompr=%#x rc=%Rrc\n", cbCompr, cbDecompr, rc)); 5500 return VERR_SSM_INTEGRITY_DECOMPRESSION;5505 return pSSM->rc = VERR_SSM_INTEGRITY_DECOMPRESSION; 5501 5506 } 5502 5507 … … 5505 5510 * Reads and checks the raw zero "header". 5506 5511 * 5507 * @returns VBox status code. 5512 * @returns VBox status code. Sets pSSM->rc on error. 5508 5513 * @param pSSM The saved state handle.. 5509 5514 * @param pcbDecompr Where to store the size of the zero data. … … 5517 5522 int rc = ssmR3DataReadV2Raw(pSSM, &cKB, 1); 5518 5523 if (RT_FAILURE(rc)) 5519 return rc;5524 return pSSM->rc = rc; 5520 5525 pSSM->u.Read.cbRecLeft = 0; 5521 5526 … … 5537 5542 * is returned. 5538 5543 * 5539 * @returns VBox status code. 5544 * @returns VBox status code. Does not set pSSM->rc. 5540 5545 * @param pSSM The saved state handle. 5541 5546 */ … … 5818 5823 * Buffer miss, do a buffered read. 5819 5824 * 5825 * @returns VBox status code. Sets pSSM->rc on error. 5826 * 5820 5827 * @param pSSM The saved state handle. 5821 5828 * @param pvBuf Where to store the read data. … … 7449 7456 7450 7457 /* failure path */ 7451 ssmR3StrmClose(&pSSM->Strm );7458 ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED); 7452 7459 } 7453 7460 else … … 7774 7781 * Executes the loading of a V2.X file. 7775 7782 * 7776 * @returns VBox status code. 7783 * @returns VBox status code. May or may not set pSSM->rc, the returned 7784 * status code is ALWAYS the more accurate of the two. 7777 7785 * @param pVM The VM handle. 7778 7786 * @param pSSM The saved state handle. … … 8131 8139 } 8132 8140 } 8133 rc = Handle.rc;8134 8141 8135 8142 /* progress */ … … 8138 8145 8139 8146 ssmR3SetCancellable(pVM, &Handle, false); 8140 ssmR3StrmClose(&Handle.Strm); 8147 ssmR3StrmClose(&Handle.Strm, Handle.rc == VERR_SSM_CANCELLED); 8148 rc = Handle.rc; 8141 8149 } 8142 8150 … … 8281 8289 false /*fChecksumOnRead*/, 1 /*cBuffers*/, &Handle); 8282 8290 if (RT_SUCCESS(rc)) 8283 ssmR3StrmClose(&Handle.Strm );8291 ssmR3StrmClose(&Handle.Strm, false /*fCancelled*/); 8284 8292 else 8285 8293 Log(("SSM: Failed to open saved state file '%s', rc=%Rrc.\n", pszFilename, rc)); … … 8361 8369 * Close the stream and free the handle. 8362 8370 */ 8363 int rc = ssmR3StrmClose(&pSSM->Strm );8371 int rc = ssmR3StrmClose(&pSSM->Strm, pSSM->rc == VERR_SSM_CANCELLED); 8364 8372 if (pSSM->u.Read.pZipDecompV1) 8365 8373 {
Note:
See TracChangeset
for help on using the changeset viewer.