Changeset 10829 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jul 23, 2008 1:06:20 PM (17 years ago)
- svn:sync-xref-src-repo-rev:
- 33614
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxControl/VBoxControl.cpp
r10825 r10829 884 884 int rc = VINF_SUCCESS; 885 885 886 /* We leave a bit of space here in case the maximum values are raised. */ 887 uint32_t cbBuf = MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024; 888 void *pvBuf = RTMemAlloc(cbBuf); 889 if (NULL == pvBuf) 890 { 891 rc = VERR_NO_MEMORY; 892 VBoxControlError("Out of memory\n"); 893 } 894 if (RT_SUCCESS(rc)) 895 { 896 rc = VbglR3GuestPropConnect(&u32ClientId); 897 if (!RT_SUCCESS(rc)) 898 VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); 899 } 886 rc = VbglR3GuestPropConnect(&u32ClientId); 887 if (!RT_SUCCESS(rc)) 888 VBoxControlError("Failed to connect to the guest property service, error %Rrc\n", rc); 900 889 901 890 /* … … 913 902 * enough with buffer space. */ 914 903 bool finish = false; 915 for (int i = 0; (i < 10) && !finish; ++i) 916 { 917 rc = VbglR3GuestPropRead(u32ClientId, pszName, pvBuf, cbBuf, 918 &pszValue, &u64Timestamp, &pszFlags, 919 &cbBuf); 904 /* We leave a bit of space here in case the maximum values are raised. */ 905 void *pvBuf = NULL; 906 uint32_t cbBuf = MAX_VALUE_LEN + MAX_FLAGS_LEN + 1024; 907 for (unsigned i = 0; (i < 10) && !finish; ++i) 908 { 909 pvBuf = RTMemRealloc(pvBuf, cbBuf); 910 if (NULL == pvBuf) 911 { 912 rc = VERR_NO_MEMORY; 913 VBoxControlError("Out of memory\n"); 914 } 915 else 916 rc = VbglR3GuestPropRead(u32ClientId, pszName, pvBuf, cbBuf, 917 &pszValue, &u64Timestamp, &pszFlags, 918 &cbBuf); 920 919 if (VERR_BUFFER_OVERFLOW == rc) 921 { 922 pvBuf = RTMemRealloc(pvBuf, cbBuf); 923 if (NULL == pvBuf) 924 rc = VERR_NO_MEMORY; 925 } 926 if (rc != VERR_BUFFER_OVERFLOW) 920 /* Leave a bit of extra space to be safe */ 921 cbBuf += 1024; 922 else 927 923 finish = true; 928 924 } -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp
r10816 r10829 258 258 { 259 259 int rc = VINF_SUCCESS; 260 uint32_t cchBuf = 1024;261 void *pvBuf = RTMemAlloc(cchBuf);262 260 char *pszValue = NULL; 263 261 *ppszValue = NULL; 264 if (NULL == pvBuf) 265 rc = VERR_NO_MEMORY; 266 if (RT_SUCCESS(rc)) 267 { 268 /* There is a race here between our reading the property size and the 269 * host changing the value before we read it. Try up to ten times and 270 * report the problem if that fails. */ 271 bool finish = false; 272 for (unsigned i = 0; (i < 10) && !finish; ++i) 273 { 262 263 /* There is a race here between our reading the property size and the 264 * host changing the value before we read it. Try up to ten times and 265 * report the problem if that fails. */ 266 bool finish = false; 267 /* We leave a bit of space here in case the maximum value is raised. */ 268 uint32_t cchBuf = MAX_VALUE_LEN + 1024; 269 void *pvBuf = NULL; 270 for (unsigned i = 0; (i < 10) && !finish; ++i) 271 { 272 pvBuf = RTMemRealloc(pvBuf, cchBuf); 273 if (NULL == pvBuf) 274 rc = VERR_NO_MEMORY; 275 else 274 276 rc = VbglR3GuestPropRead(u32ClientId, pszName, pvBuf, cchBuf, 275 277 &pszValue, NULL, NULL, &cchBuf); 276 if (VERR_BUFFER_OVERFLOW == rc)277 {278 pvBuf = RTMemRealloc(pvBuf, cchBuf);279 if (NULL == pvBuf)280 rc = VERR_NO_MEMORY;281 }282 if (rc != VERR_BUFFER_OVERFLOW)283 finish = true;284 }285 278 if (VERR_BUFFER_OVERFLOW == rc) 286 /* VERR_BUFFER_OVERFLOW has a different meaning here as a 287 * return code, but we need to report the race. */ 288 rc = VERR_TOO_MUCH_DATA; 289 } 279 /* Leave a bit of extra space to be safe */ 280 cchBuf += 1024; 281 else 282 finish = true; 283 } 284 if (VERR_BUFFER_OVERFLOW == rc) 285 /* VERR_BUFFER_OVERFLOW has a different meaning here as a 286 * return code, but we need to report the race. */ 287 rc = VERR_TOO_MUCH_DATA; 290 288 if (RT_SUCCESS(rc)) 291 289 *ppszValue = pszValue;
Note:
See TracChangeset
for help on using the changeset viewer.