Changeset 63154 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 8, 2016 12:01:32 PM (8 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r62383 r63154 823 823 #endif 824 824 825 uint32_t GetOffset() { return m_ cbOffset; }826 827 size_t GetSize() { return m_cb Size; }825 uint32_t GetOffset() { return m_offBuffer; } 826 827 size_t GetSize() { return m_cbUsed; } 828 828 829 829 int ParseBlock(GuestProcessStreamBlock &streamBlock); … … 832 832 833 833 /** Currently allocated size of internal stream buffer. */ 834 uint32_t m_cbAllocated;835 /** Currently used size of allocated internal stream buffer. */836 size_t m_cb Size;837 /** Current offset within the internal stream buffer. */838 uint32_t m_cbOffset;834 size_t m_cbAllocated; 835 /** Currently used size at m_offBuffer. */ 836 size_t m_cbUsed; 837 /** Current byte offset within the internal stream buffer. */ 838 size_t m_offBuffer; 839 839 /** Internal stream buffer. */ 840 840 BYTE *m_pbBuffer; -
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r62485 r63154 357 357 GuestProcessStream::GuestProcessStream(void) 358 358 : m_cbAllocated(0), 359 m_cb Size(0),360 m_ cbOffset(0),359 m_cbUsed(0), 360 m_offBuffer(0), 361 361 m_pbBuffer(NULL) 362 362 { … … 385 385 386 386 /* Rewind the buffer if it's empty. */ 387 size_t cbInBuf = m_cb Size - m_cbOffset;387 size_t cbInBuf = m_cbUsed - m_offBuffer; 388 388 bool const fAddToSet = cbInBuf == 0; 389 389 if (fAddToSet) 390 m_cb Size = m_cbOffset= 0;390 m_cbUsed = m_offBuffer = 0; 391 391 392 392 /* Try and see if we can simply append the data. */ 393 if (cbData + m_cb Size<= m_cbAllocated)394 { 395 memcpy(&m_pbBuffer[m_cb Size], pbData, cbData);396 m_cb Size+= cbData;393 if (cbData + m_cbUsed <= m_cbAllocated) 394 { 395 memcpy(&m_pbBuffer[m_cbUsed], pbData, cbData); 396 m_cbUsed += cbData; 397 397 } 398 398 else 399 399 { 400 400 /* Move any buffered data to the front. */ 401 cbInBuf = m_cb Size - m_cbOffset;401 cbInBuf = m_cbUsed - m_offBuffer; 402 402 if (cbInBuf == 0) 403 m_cb Size = m_cbOffset= 0;404 else if (m_ cbOffset) /* Do we have something to move? */405 { 406 memmove(m_pbBuffer, &m_pbBuffer[m_ cbOffset], cbInBuf);407 m_cb Size= cbInBuf;408 m_ cbOffset= 0;403 m_cbUsed = m_offBuffer = 0; 404 else if (m_offBuffer) /* Do we have something to move? */ 405 { 406 memmove(m_pbBuffer, &m_pbBuffer[m_offBuffer], cbInBuf); 407 m_cbUsed = cbInBuf; 408 m_offBuffer = 0; 409 409 } 410 410 411 411 /* Do we need to grow the buffer? */ 412 if (cbData + m_cbSize > m_cbAllocated) 413 { 414 size_t cbAlloc = m_cbSize + cbData; 412 if (cbData + m_cbUsed > m_cbAllocated) 413 { 414 /** @todo Put an upper limit on the allocation? */ 415 size_t cbAlloc = m_cbUsed + cbData; 415 416 cbAlloc = RT_ALIGN_Z(cbAlloc, _64K); 416 417 void *pvNew = RTMemRealloc(m_pbBuffer, cbAlloc); … … 427 428 if (RT_SUCCESS(rc)) 428 429 { 429 if (cbData + m_cb Size<= m_cbAllocated)430 if (cbData + m_cbUsed <= m_cbAllocated) 430 431 { 431 memcpy(&m_pbBuffer[m_cb Size], pbData, cbData);432 m_cb Size+= cbData;432 memcpy(&m_pbBuffer[m_cbUsed], pbData, cbData); 433 m_cbUsed += cbData; 433 434 } 434 435 else … … 452 453 453 454 m_cbAllocated = 0; 454 m_cb Size= 0;455 m_ cbOffset= 0;455 m_cbUsed = 0; 456 m_offBuffer = 0; 456 457 } 457 458 … … 460 461 { 461 462 LogFlowFunc(("Dumping contents of stream=0x%p (cbAlloc=%u, cbSize=%u, cbOff=%u) to %s\n", 462 m_pbBuffer, m_cbAllocated, m_cb Size, m_cbOffset, pszFile));463 m_pbBuffer, m_cbAllocated, m_cbUsed, m_offBuffer, pszFile)); 463 464 464 465 RTFILE hFile; … … 466 467 if (RT_SUCCESS(rc)) 467 468 { 468 rc = RTFileWrite(hFile, m_pbBuffer, m_cb Size, NULL /* pcbWritten */);469 rc = RTFileWrite(hFile, m_pbBuffer, m_cbUsed, NULL /* pcbWritten */); 469 470 RTFileClose(hFile); 470 471 } … … 493 494 { 494 495 if ( !m_pbBuffer 495 || !m_cb Size)496 || !m_cbUsed) 496 497 { 497 498 return VERR_NO_DATA; 498 499 } 499 500 500 AssertReturn(m_ cbOffset <= m_cbSize, VERR_INVALID_PARAMETER);501 if (m_ cbOffset == m_cbSize)501 AssertReturn(m_offBuffer <= m_cbUsed, VERR_INVALID_PARAMETER); 502 if (m_offBuffer == m_cbUsed) 502 503 return VERR_NO_DATA; 503 504 504 505 int rc = VINF_SUCCESS; 505 506 506 char *pszOff = (char*)&m_pbBuffer[m_ cbOffset];507 char *pszOff = (char*)&m_pbBuffer[m_offBuffer]; 507 508 char *pszStart = pszOff; 508 509 uint32_t uDistance; … … 511 512 size_t pairLen = strlen(pszStart); 512 513 uDistance = (pszStart - pszOff); 513 if (m_ cbOffset + uDistance + pairLen + 1 >= m_cbSize)514 if (m_offBuffer + uDistance + pairLen + 1 >= m_cbUsed) 514 515 { 515 516 rc = VERR_MORE_DATA; … … 547 548 if ( !uDistance 548 549 && *pszStart == '\0' 549 && m_ cbOffset < m_cbSize)550 && m_offBuffer < m_cbUsed) 550 551 { 551 552 uDistance++; 552 553 } 553 m_ cbOffset+= uDistance;554 m_offBuffer += uDistance; 554 555 555 556 return rc; -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r62485 r63154 738 738 alock.release(); /* Drop write lock before sending. */ 739 739 740 uint32_t cbRead;741 740 vrc = sendCommand(HOST_FILE_READ, i, paParms); 742 741 if (RT_SUCCESS(vrc)) 742 { 743 uint32_t cbRead = 0; 743 744 vrc = i_waitForRead(pEvent, uTimeoutMS, pvData, cbData, &cbRead); 744 745 if (RT_SUCCESS(vrc)) 746 { 747 LogFlowThisFunc(("cbRead=%RU32\n", cbRead)); 748 749 if (pcbRead) 750 *pcbRead = cbRead; 745 if (RT_SUCCESS(vrc)) 746 { 747 LogFlowThisFunc(("cbRead=%RU32\n", cbRead)); 748 if (pcbRead) 749 *pcbRead = cbRead; 750 } 751 751 } 752 752 … … 794 794 alock.release(); /* Drop write lock before sending. */ 795 795 796 uint32_t cbRead;797 796 vrc = sendCommand(HOST_FILE_READ_AT, i, paParms); 798 797 if (RT_SUCCESS(vrc)) 798 { 799 uint32_t cbRead = 0; 799 800 vrc = i_waitForRead(pEvent, uTimeoutMS, pvData, cbData, &cbRead); 800 801 if (RT_SUCCESS(vrc))802 {803 LogFlowThisFunc(("cbRead=%RU32\n", cbRead)); 804 805 if (pcbRead)806 *pcbRead = cbRead;801 if (RT_SUCCESS(vrc)) 802 { 803 LogFlowThisFunc(("cbRead=%RU32\n", cbRead)); 804 805 if (pcbRead) 806 *pcbRead = cbRead; 807 } 807 808 } 808 809 … … 1099 1100 alock.release(); /* Drop write lock before sending. */ 1100 1101 1101 uint32_t cbWritten;1102 1102 vrc = sendCommand(HOST_FILE_WRITE, i, paParms); 1103 1103 if (RT_SUCCESS(vrc)) 1104 { 1105 uint32_t cbWritten = 0; 1104 1106 vrc = i_waitForWrite(pEvent, uTimeoutMS, &cbWritten); 1105 1106 if (RT_SUCCESS(vrc)) 1107 { 1108 LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten)); 1109 1110 if (cbWritten) 1111 *pcbWritten = cbWritten; 1107 if (RT_SUCCESS(vrc)) 1108 { 1109 LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten)); 1110 if (cbWritten) 1111 *pcbWritten = cbWritten; 1112 } 1112 1113 } 1113 1114 … … 1159 1160 alock.release(); /* Drop write lock before sending. */ 1160 1161 1161 uint32_t cbWritten;1162 1162 vrc = sendCommand(HOST_FILE_WRITE_AT, i, paParms); 1163 1163 if (RT_SUCCESS(vrc)) 1164 { 1165 uint32_t cbWritten = 0; 1164 1166 vrc = i_waitForWrite(pEvent, uTimeoutMS, &cbWritten); 1165 1166 if (RT_SUCCESS(vrc)) 1167 { 1168 LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten)); 1169 1170 if (cbWritten) 1171 *pcbWritten = cbWritten; 1167 if (RT_SUCCESS(vrc)) 1168 { 1169 LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten)); 1170 if (cbWritten) 1171 *pcbWritten = cbWritten; 1172 } 1172 1173 } 1173 1174
Note:
See TracChangeset
for help on using the changeset viewer.