Changeset 75985 in vbox for trunk/src/VBox/HostServices/GuestProperties
- Timestamp:
- Dec 5, 2018 5:37:36 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 127206
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r75984 r75985 212 212 * @returns VWRN_NOT_FOUND if the last notification was not found in the queue 213 213 * @param pszPatterns the patterns to match the property name against 214 * @param u64Timestampthe timestamp of the last notification214 * @param nsTimestamp the timestamp of the last notification 215 215 * @param pProp where to return the property found. If none is 216 216 * found this will be set to nil. 217 * @throws can throw std::bad_alloc 217 218 * @thread HGCM 218 219 */ 219 int getOldNotification(const char *pszPatterns, uint64_t u64Timestamp, 220 Property *pProp) 220 int getOldNotification(const char *pszPatterns, uint64_t nsTimestamp, Property *pProp) 221 221 { 222 222 AssertPtrReturn(pszPatterns, VERR_INVALID_POINTER); 223 223 /* Zero means wait for a new notification. */ 224 AssertReturn( u64Timestamp != 0, VERR_INVALID_PARAMETER);224 AssertReturn(nsTimestamp != 0, VERR_INVALID_PARAMETER); 225 225 AssertPtrReturn(pProp, VERR_INVALID_POINTER); 226 int rc = getOldNotificationInternal(pszPatterns, u64Timestamp, pProp);226 int rc = getOldNotificationInternal(pszPatterns, nsTimestamp, pProp); 227 227 #ifdef VBOX_STRICT 228 228 /* 229 229 * ENSURE that pProp is the first event in the notification queue that: 230 * - Appears later than u64Timestamp230 * - Appears later than nsTimestamp 231 231 * - Matches the pszPatterns 232 232 */ … … 235 235 PropertyList::const_iterator it = mGuestNotifications.begin(); 236 236 for (; it != mGuestNotifications.end() 237 && it->mTimestamp != u64Timestamp; ++it)237 && it->mTimestamp != nsTimestamp; ++it) 238 238 { /*nothing*/ } 239 239 if (it == mGuestNotifications.end()) /* Not found */ … … 428 428 int delProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest); 429 429 int enumProps(uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 430 int getNotification(uint32_t u32ClientId, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, 431 VBOXHGCMSVCPARM paParms[]); 432 int getOldNotificationInternal(const char *pszPattern, 433 uint64_t u64Timestamp, Property *pProp); 430 int getNotification(uint32_t u32ClientId, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]); 431 int getOldNotificationInternal(const char *pszPattern, uint64_t nsTimestamp, Property *pProp); 434 432 int getNotificationWriteOut(uint32_t cParms, VBOXHGCMSVCPARM paParms[], Property prop); 435 int doNotifications(const char *pszProperty, uint64_t u64Timestamp); 436 int notifyHost(const char *pszName, const char *pszValue, 437 uint64_t u64Timestamp, const char *pszFlags); 433 int doNotifications(const char *pszProperty, uint64_t nsTimestamp); 434 int notifyHost(const char *pszName, const char *pszValue, uint64_t nsTimestamp, const char *pszFlags); 438 435 439 436 void call(VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, … … 540 537 const char **papszValues; 541 538 const char **papszFlags; 542 uint64_t *pa u64Timestamps;539 uint64_t *paNsTimestamps; 543 540 uint32_t cbDummy; 544 541 int rc = VINF_SUCCESS; … … 550 547 || RT_FAILURE(HGCMSvcGetPv(&paParms[0], (void **)&papszNames, &cbDummy)) 551 548 || RT_FAILURE(HGCMSvcGetPv(&paParms[1], (void **)&papszValues, &cbDummy)) 552 || RT_FAILURE(HGCMSvcGetPv(&paParms[2], (void **)&pa u64Timestamps, &cbDummy))549 || RT_FAILURE(HGCMSvcGetPv(&paParms[2], (void **)&paNsTimestamps, &cbDummy)) 553 550 || RT_FAILURE(HGCMSvcGetPv(&paParms[3], (void **)&papszFlags, &cbDummy)) 554 551 ) … … 591 588 /* Update existing property. */ 592 589 pProp->mValue = papszValues[i]; 593 pProp->mTimestamp = pa u64Timestamps[i];590 pProp->mTimestamp = paNsTimestamps[i]; 594 591 pProp->mFlags = fFlags; 595 592 } … … 597 594 { 598 595 /* Create a new property */ 599 pProp = new Property(papszNames[i], papszValues[i], pa u64Timestamps[i], fFlags);596 pProp = new Property(papszNames[i], papszValues[i], paNsTimestamps[i], fFlags); 600 597 if (!pProp) 601 598 { … … 893 890 if (rc == VINF_SUCCESS && pProp) 894 891 { 895 uint64_t u64Timestamp = getCurrentTimestamp();892 uint64_t nsTimestamp = getCurrentTimestamp(); 896 893 PRTSTRSPACECORE pStrCore = RTStrSpaceRemove(&mhProperties, pProp->mStrCore.pszString); 897 894 AssertPtr(pStrCore); NOREF(pStrCore); … … 900 897 // if (isGuest) /* Notify the host even for properties that the host 901 898 // * changed. Less efficient, but ensures consistency. */ 902 int rc2 = doNotifications(pcszName, u64Timestamp);899 int rc2 = doNotifications(pcszName, nsTimestamp); 903 900 if (RT_SUCCESS(rc)) 904 901 rc = rc2; … … 1051 1048 1052 1049 1053 /** Helper query used by getOldNotification */1054 int Service::getOldNotificationInternal(const char *pszPatterns, 1055 uint64_t u64Timestamp,1056 1050 /** Helper query used by getOldNotification 1051 * @throws can throw std::bad_alloc 1052 */ 1053 int Service::getOldNotificationInternal(const char *pszPatterns, uint64_t nsTimestamp, Property *pProp) 1057 1054 { 1058 1055 /* We count backwards, as the guest should normally be querying the … … 1061 1058 PropertyList::reverse_iterator it = mGuestNotifications.rbegin(); 1062 1059 for (; it != mGuestNotifications.rend(); ++it) 1063 if (it->mTimestamp == u64Timestamp)1060 if (it->mTimestamp == nsTimestamp) 1064 1061 { 1065 1062 rc = VINF_SUCCESS; … … 1138 1135 uint32_t cchPatterns = 0; 1139 1136 uint32_t cbBuf = 0; 1140 uint64_t u64Timestamp;1137 uint64_t nsTimestamp; 1141 1138 1142 1139 /* … … 1146 1143 if ( cParms != 4 /* Hardcoded value as the next lines depend on it. */ 1147 1144 || RT_FAILURE(HGCMSvcGetStr(&paParms[0], &pszPatterns, &cchPatterns)) /* patterns */ 1148 || RT_FAILURE(HGCMSvcGetU64(&paParms[1], & u64Timestamp)) /* timestamp */1145 || RT_FAILURE(HGCMSvcGetU64(&paParms[1], &nsTimestamp)) /* timestamp */ 1149 1146 || RT_FAILURE(HGCMSvcGetBuf(&paParms[2], (void **)&pchBuf, &cbBuf)) /* return buffer */ 1150 1147 ) … … 1152 1149 else 1153 1150 { 1154 LogFlow(("pszPatterns=%s, u64Timestamp=%llu\n", pszPatterns, u64Timestamp));1151 LogFlow(("pszPatterns=%s, nsTimestamp=%llu\n", pszPatterns, nsTimestamp)); 1155 1152 1156 1153 /* … … 1159 1156 */ 1160 1157 Property prop; 1161 if (RT_SUCCESS(rc) && u64Timestamp != 0)1162 rc = getOldNotification(pszPatterns, u64Timestamp, &prop);1158 if (RT_SUCCESS(rc) && nsTimestamp != 0) 1159 rc = getOldNotification(pszPatterns, nsTimestamp, &prop); 1163 1160 if (RT_SUCCESS(rc)) 1164 1161 { … … 1214 1211 * added/deleted/changed 1215 1212 * @param pszProperty the name of the property which has changed 1216 * @param u64Timestampthe time at which the change took place1213 * @param nsTimestamp the time at which the change took place 1217 1214 * 1218 1215 * @thread HGCM service 1219 1216 */ 1220 int Service::doNotifications(const char *pszProperty, uint64_t u64Timestamp)1217 int Service::doNotifications(const char *pszProperty, uint64_t nsTimestamp) 1221 1218 { 1222 1219 AssertPtrReturn(pszProperty, VERR_INVALID_POINTER); 1223 LogFlowThisFunc(("pszProperty=%s, u64Timestamp=%llu\n", pszProperty, u64Timestamp));1220 LogFlowThisFunc(("pszProperty=%s, nsTimestamp=%llu\n", pszProperty, nsTimestamp)); 1224 1221 /* Ensure that our timestamp is different to the last one. */ 1225 1222 if ( !mGuestNotifications.empty() 1226 && u64Timestamp == mGuestNotifications.back().mTimestamp)1227 ++ u64Timestamp;1223 && nsTimestamp == mGuestNotifications.back().mTimestamp) 1224 ++nsTimestamp; 1228 1225 1229 1226 /* … … 1233 1230 Property prop; 1234 1231 prop.mName = pszProperty; 1235 prop.mTimestamp = u64Timestamp;1232 prop.mTimestamp = nsTimestamp; 1236 1233 /* prop is currently a delete event for pszProperty */ 1237 1234 Property const * const pProp = getPropertyInternal(pszProperty); … … 1293 1290 rc = GuestPropWriteFlags(prop.mFlags, szFlags); 1294 1291 if (RT_SUCCESS(rc)) 1295 rc = notifyHost(pszProperty, pszValue, u64Timestamp, szFlags);1292 rc = notifyHost(pszProperty, pszValue, nsTimestamp, szFlags); 1296 1293 } 1297 1294 /* … … 1302 1299 { 1303 1300 /* Send out a host notification */ 1304 rc = notifyHost(pszProperty, "", u64Timestamp, "");1301 rc = notifyHost(pszProperty, "", nsTimestamp, ""); 1305 1302 } 1306 1303 } … … 1327 1324 * @param pszName the property name 1328 1325 * @param pszValue the new value, or NULL if the property was deleted 1329 * @param u64Timestampthe time of the change1326 * @param nsTimestamp the time of the change 1330 1327 * @param pszFlags the new flags string 1331 1328 */ 1332 int Service::notifyHost(const char *pszName, const char *pszValue, 1333 uint64_t u64Timestamp, const char *pszFlags) 1334 { 1335 LogFlowFunc(("pszName=%s, pszValue=%s, u64Timestamp=%llu, pszFlags=%s\n", 1336 pszName, pszValue, u64Timestamp, pszFlags)); 1329 int Service::notifyHost(const char *pszName, const char *pszValue, uint64_t nsTimestamp, const char *pszFlags) 1330 { 1331 LogFlowFunc(("pszName=%s, pszValue=%s, nsTimestamp=%llu, pszFlags=%s\n", pszName, pszValue, nsTimestamp, pszFlags)); 1337 1332 #ifdef ASYNC_HOST_NOTIFY 1338 1333 int rc = VINF_SUCCESS; … … 1361 1356 *pu8++ = 0; 1362 1357 1363 pHostCallbackData->u64Timestamp = u64Timestamp;1358 pHostCallbackData->u64Timestamp = nsTimestamp; 1364 1359 1365 1360 pHostCallbackData->pcszFlags = (const char *)pu8; … … 1385 1380 HostCallbackData.pcszName = pszName; 1386 1381 HostCallbackData.pcszValue = pszValue; 1387 HostCallbackData. u64Timestamp = u64Timestamp;1382 HostCallbackData.nsTimestamp = nsTimestamp; 1388 1383 HostCallbackData.pcszFlags = pszFlags; 1389 1384 int rc = mpfnHostCallback(mpvHostData, 0 /*u32Function*/,
Note:
See TracChangeset
for help on using the changeset viewer.