Changeset 95326 in vbox for trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
- Timestamp:
- Jun 21, 2022 2:34:48 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r94184 r95326 1519 1519 * of space here in case the maximum values are raised. */ 1520 1520 void *pvBuf = NULL; 1521 uint32_t cbBuf = GUEST_PROP_MAX_NAME_LEN + GUEST_PROP_MAX_VALUE_LEN + GUEST_PROP_MAX_FLAGS_LEN + 1024;1521 uint32_t cbBuf = GUEST_PROP_MAX_NAME_LEN + GUEST_PROP_MAX_VALUE_LEN + GUEST_PROP_MAX_FLAGS_LEN + _1K; 1522 1522 /* Because there is a race condition between our reading the size of a 1523 1523 * property and the guest updating it, we loop a few times here and 1524 1524 * hope. Actually this should never go wrong, as we are generous 1525 1525 * enough with buffer space. */ 1526 bool fFinished = false; 1527 for (unsigned i = 0; (RT_SUCCESS(rc) || rc == VERR_BUFFER_OVERFLOW) && !fFinished && i < 10; i++) 1528 { 1529 void *pvTmpBuf = RTMemRealloc(pvBuf, cbBuf); 1530 if (NULL == pvTmpBuf) 1531 { 1532 rc = VERR_NO_MEMORY; 1533 VBoxControlError("Out of memory\n"); 1534 } 1535 else 1536 { 1537 pvBuf = pvTmpBuf; 1526 for (unsigned iTry = 0; ; iTry++) 1527 { 1528 pvBuf = RTMemRealloc(pvBuf, cbBuf); 1529 if (pvBuf != NULL) 1530 { 1538 1531 rc = VbglR3GuestPropWait(u32ClientId, pszPatterns, pvBuf, cbBuf, 1539 1532 u64TimestampIn, u32Timeout, 1540 1533 &pszName, &pszValue, &u64TimestampOut, 1541 1534 &pszFlags, &cbBuf, &fWasDeleted); 1542 } 1543 if (VERR_BUFFER_OVERFLOW == rc) 1544 /* Leave a bit of extra space to be safe */ 1545 cbBuf += 1024; 1535 if (rc == VERR_BUFFER_OVERFLOW && iTry < 10) 1536 { 1537 cbBuf += _1K; /* Add a bit of extra space to be on the safe side. */ 1538 continue; 1539 } 1540 if (rc == VERR_TOO_MUCH_DATA) 1541 VBoxControlError("Temporarily unable to get a notification\n"); 1542 else if (rc == VERR_INTERRUPTED) 1543 VBoxControlError("The request timed out or was interrupted\n"); 1544 else if (RT_FAILURE(rc) && rc != VERR_NOT_FOUND) 1545 VBoxControlError("Failed to get a notification, error %Rrc\n", rc); 1546 } 1546 1547 else 1547 fFinished = true; 1548 if (rc == VERR_TOO_MUCH_DATA) 1549 VBoxControlError("Temporarily unable to get a notification\n"); 1550 else if (rc == VERR_INTERRUPTED) 1551 VBoxControlError("The request timed out or was interrupted\n"); 1552 else if (RT_FAILURE(rc) && rc != VERR_NOT_FOUND) 1553 VBoxControlError("Failed to get a notification, error %Rrc\n", rc); 1548 { 1549 VBoxControlError("Out of memory\n"); 1550 rc = VERR_NO_MEMORY; 1551 } 1552 break; 1554 1553 } 1555 1554
Note:
See TracChangeset
for help on using the changeset viewer.