Changeset 39232 in vbox
- Timestamp:
- Nov 8, 2011 12:44:08 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestProperties/service.cpp
r39230 r39232 64 64 struct Property 65 65 { 66 #define USE_STRSPACE67 #ifdef USE_STRSPACE68 66 /** The string space core record. */ 69 67 RTSTRSPACECORE mStrCore; 70 #endif71 68 /** The name of the property */ 72 69 std::string mName; … … 81 78 Property() : mTimestamp(0), mFlags(NILFLAG) 82 79 { 83 #ifdef USE_STRSPACE84 80 RT_ZERO(mStrCore); 85 #endif86 81 } 87 82 /** Constructor with const char * */ … … 91 86 mFlags(u32Flags) 92 87 { 93 #ifdef USE_STRSPACE94 88 RT_ZERO(mStrCore); 95 89 mStrCore.pszString = mName.c_str(); 96 #endif97 90 } 98 91 /** Constructor with std::string */ … … 172 165 /** Global flags for the service */ 173 166 ePropFlags meGlobalFlags; 174 #ifdef USE_STRSPACE175 167 /** The property string space handle. */ 176 168 RTSTRSPACE mhProperties; 177 169 /** The number of properties. */ 178 170 unsigned mcProperties; 179 #else180 /** The property list */181 PropertyList mProperties;182 #endif183 171 /** The list of property changes for guest notifications */ 184 172 PropertyList mGuestNotifications; … … 280 268 Property *getPropertyInternal(const char *pszName) 281 269 { 282 #ifdef USE_STRSPACE283 270 return (Property *)RTStrSpaceGet(&mhProperties, pszName); 284 #else285 for (PropertyList::iterator it = mProperties.begin();286 it != mProperties.end();287 ++it)288 if (it->mName.compare(pszName) == 0)289 return &*it; /* the wonders of stdandard C++... ;-) */290 return NULL;291 #endif292 271 } 293 272 … … 296 275 : mpHelpers(pHelpers) 297 276 , meGlobalFlags(NILFLAG) 298 #ifdef USE_STRSPACE299 277 , mhProperties(NULL) 300 278 , mcProperties(0) 301 #endif302 279 , mpfnHostCallback(NULL) 303 280 , mpvHostData(NULL) … … 509 486 /** @todo validate the array sizes... */ 510 487 511 #ifdef USE_STRSPACE512 488 for (unsigned i = 0; RT_SUCCESS(rc) && papszNames[i] != NULL; ++i) 513 489 { … … 564 540 } 565 541 566 #else /* !USE_STRSPACE */567 /*568 * Add the properties to the end of the list. If we succeed then we569 * will remove duplicates afterwards.570 */571 /* Remember the last property before we started adding, for rollback or572 * cleanup. */573 PropertyList::iterator itEnd = mProperties.end();574 if (!mProperties.empty())575 --itEnd;576 try577 {578 for (unsigned i = 0; RT_SUCCESS(rc) && papszNames[i] != NULL; ++i)579 {580 uint32_t fFlags;581 if ( !VALID_PTR(papszNames[i])582 || !VALID_PTR(papszValues[i])583 || !VALID_PTR(papszFlags[i])584 )585 rc = VERR_INVALID_POINTER;586 if (RT_SUCCESS(rc))587 rc = validateFlags(papszFlags[i], &fFlags);588 if (RT_SUCCESS(rc))589 mProperties.push_back(Property(papszNames[i], papszValues[i],590 pau64Timestamps[i], fFlags));591 }592 }593 catch (std::bad_alloc)594 {595 rc = VERR_NO_MEMORY;596 }597 598 /*599 * If all went well then remove the duplicate elements.600 */601 if (RT_SUCCESS(rc) && itEnd != mProperties.end())602 {603 ++itEnd;604 for (unsigned i = 0; papszNames[i] != NULL; ++i)605 for (PropertyList::iterator it = mProperties.begin(); it != itEnd; ++it)606 if (it->mName.compare(papszNames[i]) == 0)607 {608 mProperties.erase(it);609 break;610 }611 }612 613 /*614 * If something went wrong then rollback. This is possible because we615 * haven't deleted anything yet.616 */617 if (RT_FAILURE(rc))618 {619 if (itEnd != mProperties.end())620 ++itEnd;621 mProperties.erase(itEnd, mProperties.end());622 }623 #endif /* !USE_STRSPACE */624 542 return rc; 625 543 } … … 639 557 int Service::getProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 640 558 { 641 int rc = VINF_SUCCESS;559 int rc; 642 560 const char *pcszName = NULL; /* shut up gcc */ 643 char *pchBuf; 644 uint32_t cbName, cchBuf; 645 char szFlags[MAX_FLAGS_LEN]; 561 char *pchBuf; 562 uint32_t cbName, cbBuf; 646 563 647 564 /* … … 651 568 if ( cParms != 4 /* Hardcoded value as the next lines depend on it. */ 652 569 || RT_FAILURE(paParms[0].getString(&pcszName, &cbName)) /* name */ 653 || RT_FAILURE(paParms[1].getBuffer((void **)&pchBuf, &c chBuf)) /* buffer */570 || RT_FAILURE(paParms[1].getBuffer((void **)&pchBuf, &cbBuf)) /* buffer */ 654 571 ) 655 572 rc = VERR_INVALID_PARAMETER; 656 573 else 657 574 rc = validateName(pcszName, cbName); 575 if (RT_FAILURE(rc)) 576 { 577 LogFlowThisFunc(("rc = %Rrc\n", rc)); 578 return rc; 579 } 658 580 659 581 /* … … 661 583 */ 662 584 663 #ifdef USE_STRSPACE664 585 /* Get the property. */ 665 Property *it = NULL; 666 if (RT_SUCCESS(rc)) 667 { 668 it = getPropertyInternal(pcszName); 669 if (!it) 670 rc = VERR_NOT_FOUND; 671 } 672 673 #else /* !USE_STRSPACE */ 674 /* Get the value size */ 675 PropertyList::const_iterator it; 676 if (RT_SUCCESS(rc)) 677 { 586 Property *pProp = getPropertyInternal(pcszName); 587 if (pProp) 588 { 589 char szFlags[MAX_FLAGS_LEN]; 590 rc = writeFlags(pProp->mFlags, szFlags); 591 if (RT_SUCCESS(rc)) 592 { 593 /* Check that the buffer is big enough */ 594 size_t cchBufActual = pProp->mValue.size() + 1 + strlen(szFlags); /** @todo r=bird: Buffer overflow bug here? size() == strlen(). */ 595 paParms[3].setUInt32((uint32_t)cchBufActual); 596 if (cchBufActual <= cbBuf) 597 { 598 /* Write the value, flags and timestamp */ 599 pProp->mValue.copy(pchBuf, cbBuf, 0); 600 pchBuf[pProp->mValue.size()] = '\0'; /* Terminate the value */ 601 strcpy(pchBuf + pProp->mValue.size() + 1, szFlags); 602 paParms[2].setUInt64(pProp->mTimestamp); 603 604 /* 605 * Done! Do exit logging and return. 606 */ 607 Log2(("Queried string %s, value=%s, timestamp=%lld, flags=%s\n", 608 pcszName, pProp->mValue.c_str(), pProp->mTimestamp, szFlags)); 609 } 610 else 611 rc = VERR_BUFFER_OVERFLOW; 612 } 613 } 614 else 678 615 rc = VERR_NOT_FOUND; 679 for (it = mProperties.begin(); it != mProperties.end(); ++it) 680 if (it->mName.compare(pcszName) == 0) 681 { 682 rc = VINF_SUCCESS; 683 break; 684 } 685 } 686 #endif /* !USE_STRSPACE */ 687 if (RT_SUCCESS(rc)) 688 rc = writeFlags(it->mFlags, szFlags); 689 if (RT_SUCCESS(rc)) 690 { 691 /* Check that the buffer is big enough */ 692 size_t cchBufActual = it->mValue.size() + 1 + strlen(szFlags); 693 paParms[3].setUInt32 ((uint32_t)cchBufActual); 694 if (cchBufActual <= cchBuf) 695 { 696 /* Write the value, flags and timestamp */ 697 it->mValue.copy(pchBuf, cchBuf, 0); 698 pchBuf[it->mValue.size()] = '\0'; /* Terminate the value */ 699 strcpy(pchBuf + it->mValue.size() + 1, szFlags); 700 paParms[2].setUInt64 (it->mTimestamp); 701 702 /* 703 * Done! Do exit logging and return. 704 */ 705 Log2(("Queried string %s, value=%s, timestamp=%lld, flags=%s\n", 706 pcszName, it->mValue.c_str(), it->mTimestamp, szFlags)); 707 } 708 else 709 rc = VERR_BUFFER_OVERFLOW; 710 } 711 712 LogFlowThisFunc(("rc = %Rrc\n", rc)); 616 617 LogFlowThisFunc(("rc = %Rrc (%s)\n", rc, pcszName)); 713 618 return rc; 714 619 } … … 738 643 739 644 LogFlowThisFunc(("\n")); 740 741 #ifndef USE_STRSPACE /** @todo r=bird: This check is wrong as it will prevent updating742 * existing properties when the maximum is reached! */743 /*744 * First of all, make sure that we won't exceed the maximum number of properties.745 */746 if (mProperties.size() >= MAX_PROPS)747 rc = VERR_TOO_MUCH_DATA;748 #endif749 645 750 646 /* … … 774 670 if ((3 == cParms) && RT_SUCCESS(rc)) 775 671 rc = validateFlags(pcszFlags, &fFlags); 776 if (RT_SUCCESS(rc)) 672 if (RT_FAILURE(rc)) 673 { 674 LogFlowThisFunc(("rc = %Rrc\n", rc)); 675 return rc; 676 } 677 678 /* 679 * If the property already exists, check its flags to see if we are allowed 680 * to change it. 681 */ 682 Property *pProp = getPropertyInternal(pcszName); 683 rc = checkPermission(pProp ? (ePropFlags)pProp->mFlags : NILFLAG, isGuest); 684 if (rc == VINF_SUCCESS) 777 685 { 778 686 /* 779 * If the property already exists, check its flags to see if we are allowed 780 * to change it. 687 * Set the actual value 781 688 */ 782 #ifdef USE_STRSPACE 783 Property *it = getPropertyInternal(pcszName); 784 bool found = it != NULL; 785 #else 786 PropertyList::iterator it; 787 bool found = false; 788 for (it = mProperties.begin(); it != mProperties.end(); ++it) 789 if (it->mName.compare(pcszName) == 0) 689 if (pProp) 690 { 691 pProp->mValue = pcszValue; 692 pProp->mTimestamp = u64TimeNano; 693 pProp->mFlags = fFlags; 694 } 695 else if (mcProperties < MAX_PROPS) 696 { 697 /* Create a new string space record. */ 698 pProp = new Property(pcszName, pcszValue, u64TimeNano, fFlags); 699 if (pProp) 790 700 { 791 found = true; 792 break; 793 } 794 #endif /* !USE_STRSPACE */ 795 796 rc = checkPermission(found ? (ePropFlags)it->mFlags : NILFLAG, 797 isGuest); 798 if (rc == VINF_SUCCESS) 799 { 800 /* 801 * Set the actual value 802 */ 803 if (found) 804 { 805 it->mValue = pcszValue; 806 it->mTimestamp = u64TimeNano; 807 it->mFlags = fFlags; 808 } 809 #ifdef USE_STRSPACE 810 else if (mcProperties < MAX_PROPS) 811 { 812 /* Create a new string space record. */ 813 it = new Property(pcszName, pcszValue, u64TimeNano, fFlags); 814 if (it) 701 if (RTStrSpaceInsert(&mhProperties, &pProp->mStrCore)) 702 mcProperties++; 703 else 815 704 { 816 if (RTStrSpaceInsert(&mhProperties, &it->mStrCore)) 817 mcProperties++; 818 else 819 { 820 AssertFailed(); 821 delete it; 822 rc = VERR_INTERNAL_ERROR_3; 823 } 705 AssertFailed(); 706 delete pProp; 707 rc = VERR_INTERNAL_ERROR_3; 824 708 } 825 else826 rc = VERR_NO_MEMORY;827 709 } 828 710 else 829 rc = VERR_TOO_MUCH_DATA; 830 #else 831 else /* This can throw. No problem as we have nothing to roll back. */ 832 mProperties.push_back(Property(pcszName, pcszValue, u64TimeNano, fFlags)); 833 #endif 834 835 /* 836 * Send a notification to the host and return. 837 */ 838 // if (isGuest) /* Notify the host even for properties that the host 839 // * changed. Less efficient, but ensures consistency. */ 840 doNotifications(pcszName, u64TimeNano); 841 Log2(("Set string %s, rc=%Rrc, value=%s\n", pcszName, rc, pcszValue)); 711 rc = VERR_NO_MEMORY; 842 712 } 843 } 844 845 LogFlowThisFunc(("rc = %Rrc\n", rc)); 713 else 714 rc = VERR_TOO_MUCH_DATA; 715 716 /* 717 * Send a notification to the host and return. 718 */ 719 // if (isGuest) /* Notify the host even for properties that the host 720 // * changed. Less efficient, but ensures consistency. */ 721 doNotifications(pcszName, u64TimeNano); 722 Log2(("Set string %s, rc=%Rrc, value=%s\n", pcszName, rc, pcszValue)); 723 } 724 725 LogFlowThisFunc(("rc = %Rrc (%s = %s)\n", rc, pcszName, pcszValue)); 846 726 return rc; 847 727 } … … 860 740 int Service::delProperty(uint32_t cParms, VBOXHGCMSVCPARM paParms[], bool isGuest) 861 741 { 862 int rc = VINF_SUCCESS;742 int rc; 863 743 const char *pcszName = NULL; /* shut up gcc */ 864 uint32_t cbName;744 uint32_t cbName; 865 745 866 746 LogFlowThisFunc(("\n")); … … 875 755 else 876 756 rc = VERR_INVALID_PARAMETER; 877 if (RT_SUCCESS(rc)) 878 { 879 /* 880 * If the property exists, check its flags to see if we are allowed 881 * to change it. 882 */ 883 #ifdef USE_STRSPACE 884 Property *it = getPropertyInternal(pcszName); 885 bool found = it != NULL; 886 if (it) 887 rc = checkPermission((ePropFlags)it->mFlags, isGuest); 888 #else 889 PropertyList::iterator it; 890 bool found = false; 891 for (it = mProperties.begin(); it != mProperties.end(); ++it) 892 if (it->mName.compare(pcszName) == 0) 893 { 894 found = true; 895 rc = checkPermission((ePropFlags)it->mFlags, isGuest); 896 break; 897 } 898 #endif 899 900 /* 901 * And delete the property if all is well. 902 */ 903 if (rc == VINF_SUCCESS && found) 904 { 905 uint64_t u64Timestamp = getCurrentTimestamp(); 906 #ifdef USE_STRSPACE 907 bool fRc = RTStrSpaceRemove(&mhProperties, it->mStrCore.pszString); 908 Assert(fRc); NOREF(fRc); 909 mcProperties--; 910 delete it; 911 #else 912 mProperties.erase(it); 913 #endif 914 // if (isGuest) /* Notify the host even for properties that the host 915 // * changed. Less efficient, but ensures consistency. */ 916 doNotifications(pcszName, u64Timestamp); 917 } 918 } 919 920 LogFlowThisFunc(("rc = %Rrc\n", rc)); 757 if (RT_FAILURE(rc)) 758 { 759 LogFlowThisFunc(("rc = %Rrc\n", rc)); 760 return rc; 761 } 762 763 /* 764 * If the property exists, check its flags to see if we are allowed 765 * to change it. 766 */ 767 Property *pProp = getPropertyInternal(pcszName); 768 if (pProp) 769 rc = checkPermission((ePropFlags)pProp->mFlags, isGuest); 770 771 /* 772 * And delete the property if all is well. 773 */ 774 if (rc == VINF_SUCCESS && pProp) 775 { 776 uint64_t u64Timestamp = getCurrentTimestamp(); 777 bool fRc = RTStrSpaceRemove(&mhProperties, pProp->mStrCore.pszString); 778 Assert(fRc); NOREF(fRc); 779 mcProperties--; 780 delete pProp; 781 // if (isGuest) /* Notify the host even for properties that the host 782 // * changed. Less efficient, but ensures consistency. */ 783 doNotifications(pcszName, u64Timestamp); 784 } 785 786 LogFlowThisFunc(("rc = %Rrc (%s)\n", rc, pcszName)); 921 787 return rc; 922 788 } 923 924 #ifdef USE_STRSPACE925 789 926 790 /** … … 990 854 return 0; 991 855 } 992 #endif /* USE_STRSPACE */993 856 994 857 /** … … 1011 874 char *pchBuf = NULL; 1012 875 uint32_t cbPatterns = 0; 1013 uint32_t c chBuf = 0;876 uint32_t cbBuf = 0; 1014 877 LogFlowThisFunc(("\n")); 1015 878 if ( (cParms != 3) /* Hardcoded value as the next lines depend on it. */ 1016 879 || RT_FAILURE(paParms[0].getString(&pchPatterns, &cbPatterns)) /* patterns */ 1017 || RT_FAILURE(paParms[1].getBuffer((void **) &pchBuf, &cchBuf)) /* return buffer */880 || RT_FAILURE(paParms[1].getBuffer((void **)&pchBuf, &cbBuf)) /* return buffer */ 1018 881 ) 1019 882 rc = VERR_INVALID_PARAMETER; … … 1024 887 * First repack the patterns into the format expected by RTStrSimplePatternMatch() 1025 888 */ 1026 char pszPatterns[MAX_PATTERN_LEN];889 char szPatterns[MAX_PATTERN_LEN]; 1027 890 if (RT_SUCCESS(rc)) 1028 891 { 1029 892 for (unsigned i = 0; i < cbPatterns - 1; ++i) 1030 893 if (pchPatterns[i] != '\0') 1031 pszPatterns[i] = pchPatterns[i];894 szPatterns[i] = pchPatterns[i]; 1032 895 else 1033 pszPatterns[i] = '|'; 1034 pszPatterns[cbPatterns - 1] = '\0'; 1035 } 1036 1037 #ifdef USE_STRSPACE 896 szPatterns[i] = '|'; 897 szPatterns[cbPatterns - 1] = '\0'; 898 } 899 1038 900 /* 1039 901 * Next enumerate into the buffer. … … 1042 904 { 1043 905 EnumData EnumData; 1044 EnumData.pszPattern = pszPatterns;906 EnumData.pszPattern = szPatterns; 1045 907 EnumData.pchCur = pchBuf; 1046 EnumData.cbLeft = c chBuf;908 EnumData.cbLeft = cbBuf; 1047 909 EnumData.cbNeeded = 0; 1048 910 rc = RTStrSpaceEnumerate(&mhProperties, enumPropsCallback, &EnumData); … … 1064 926 } 1065 927 1066 #else /* !USE_STRSPACE */1067 /*1068 * Next enumerate into a temporary buffer. This can throw, but this is1069 * not a problem as we have nothing to roll back.1070 */1071 std::string buffer;1072 for (PropertyList::const_iterator it = mProperties.begin();1073 RT_SUCCESS(rc) && (it != mProperties.end()); ++it)1074 {1075 if (it->Matches(pszPatterns))1076 {1077 char szFlags[MAX_FLAGS_LEN];1078 char szTimestamp[256];1079 uint32_t cchTimestamp;1080 buffer += it->mName;1081 buffer += '\0';1082 buffer += it->mValue;1083 buffer += '\0';1084 cchTimestamp = RTStrFormatNumber(szTimestamp, it->mTimestamp,1085 10, 0, 0, 0);1086 buffer.append(szTimestamp, cchTimestamp);1087 buffer += '\0';1088 rc = writeFlags(it->mFlags, szFlags);1089 if (RT_SUCCESS(rc))1090 buffer += szFlags;1091 buffer += '\0';1092 }1093 }1094 if (RT_SUCCESS(rc))1095 buffer.append(4, '\0'); /* The final terminators */1096 1097 /*1098 * Finally write out the temporary buffer to the real one if it is not too1099 * small.1100 */1101 if (RT_SUCCESS(rc))1102 {1103 paParms[2].setUInt32((uint32_t)buffer.size());1104 /* Copy the memory if it fits into the guest buffer */1105 if (buffer.size() <= cchBuf)1106 buffer.copy(pchBuf, cchBuf);1107 else1108 rc = VERR_BUFFER_OVERFLOW;1109 }1110 #endif /* !USE_STRSPACE */1111 928 return rc; 1112 929 } … … 1151 968 uint64_t u64Timestamp; 1152 969 char *pchBuf; 1153 uint32_t c chBuf;1154 rc = paParms[2].getBuffer((void **) &pchBuf, &cchBuf);970 uint32_t cbBuf; 971 rc = paParms[2].getBuffer((void **)&pchBuf, &cbBuf); 1155 972 if (RT_SUCCESS(rc)) 1156 973 { … … 1173 990 paParms[1].setUInt64(u64Timestamp); 1174 991 paParms[3].setUInt32((uint32_t)buffer.size()); 1175 if (buffer.size() <= c chBuf)1176 buffer.copy(pchBuf, c chBuf);992 if (buffer.size() <= cbBuf) 993 buffer.copy(pchBuf, cbBuf); 1177 994 else 1178 995 rc = VERR_BUFFER_OVERFLOW; … … 1198 1015 char *pchBuf; 1199 1016 uint32_t cchPatterns = 0; 1200 uint32_t c chBuf = 0;1017 uint32_t cbBuf = 0; 1201 1018 uint64_t u64Timestamp; 1202 1019 … … 1208 1025 || RT_FAILURE(paParms[0].getString(&pszPatterns, &cchPatterns)) /* patterns */ 1209 1026 || RT_FAILURE(paParms[1].getUInt64(&u64Timestamp)) /* timestamp */ 1210 || RT_FAILURE(paParms[2].getBuffer((void **) &pchBuf, &cchBuf)) /* return buffer */1027 || RT_FAILURE(paParms[2].getBuffer((void **)&pchBuf, &cbBuf)) /* return buffer */ 1211 1028 ) 1212 1029 rc = VERR_INVALID_PARAMETER; … … 1251 1068 void Service::doNotifications(const char *pszProperty, uint64_t u64Timestamp) 1252 1069 { 1253 int rc = VINF_SUCCESS;1254 1255 1070 AssertPtrReturnVoid(pszProperty); 1256 1071 LogFlowThisFunc (("pszProperty=%s, u64Timestamp=%llu\n", pszProperty, u64Timestamp)); … … 1268 1083 prop.mTimestamp = u64Timestamp; 1269 1084 /* prop is currently a delete event for pszProperty */ 1270 bool found = false; 1271 #ifdef USE_STRSPACE 1272 if (RT_SUCCESS(rc)) 1273 { 1274 Property *pProp = getPropertyInternal(pszProperty); 1275 if (pProp) 1276 { 1277 found = true; 1278 /* Make prop into a change event. */ 1279 prop.mValue = pProp->mValue; 1280 prop.mFlags = pProp->mFlags; 1281 } 1282 } 1283 #else /* !USE_STRSPACE */ 1284 if (RT_SUCCESS(rc)) 1285 for (PropertyList::const_iterator it = mProperties.begin(); 1286 !found && it != mProperties.end(); ++it) 1287 if (it->mName.compare(pszProperty) == 0) 1288 { 1289 found = true; 1290 /* Make prop into a change event. */ 1291 prop.mValue = it->mValue; 1292 prop.mFlags = it->mFlags; 1293 } 1294 #endif /* !USE_STRSPACE */ 1085 Property const * const pProp = getPropertyInternal(pszProperty); 1086 if (pProp) 1087 { 1088 /* Make prop into a change event. */ 1089 prop.mValue = pProp->mValue; 1090 prop.mFlags = pProp->mFlags; 1091 } 1295 1092 1296 1093 /* Release waiters if applicable and add the event to the queue for 1297 1094 * guest notifications */ 1298 if (RT_SUCCESS(rc)) 1299 { 1300 try 1095 int rc = VINF_SUCCESS; 1096 try 1097 { 1098 CallList::iterator it = mGuestWaiters.begin(); 1099 while (it != mGuestWaiters.end()) 1301 1100 { 1302 CallList::iterator it = mGuestWaiters.begin(); 1303 while (it != mGuestWaiters.end()) 1101 const char *pszPatterns; 1102 uint32_t cchPatterns; 1103 it->mParms[0].getString(&pszPatterns, &cchPatterns); 1104 if (prop.Matches(pszPatterns)) 1304 1105 { 1305 const char *pszPatterns; 1306 uint32_t cchPatterns; 1307 it->mParms[0].getString(&pszPatterns, &cchPatterns); 1308 if (prop.Matches(pszPatterns)) 1309 { 1310 GuestCall curCall = *it; 1311 int rc2 = getNotificationWriteOut(curCall.mParms, prop); 1312 if (RT_SUCCESS(rc2)) 1313 rc2 = curCall.mRc; 1314 mpHelpers->pfnCallComplete(curCall.mHandle, rc2); 1315 it = mGuestWaiters.erase(it); 1316 } 1317 else 1318 ++it; 1106 GuestCall curCall = *it; 1107 int rc2 = getNotificationWriteOut(curCall.mParms, prop); 1108 if (RT_SUCCESS(rc2)) 1109 rc2 = curCall.mRc; 1110 mpHelpers->pfnCallComplete(curCall.mHandle, rc2); 1111 it = mGuestWaiters.erase(it); 1319 1112 } 1320 mGuestNotifications.push_back(prop); 1113 else 1114 ++it; 1321 1115 } 1322 catch (std::bad_alloc) 1323 { 1324 rc = VERR_NO_MEMORY; 1325 } 1116 mGuestNotifications.push_back(prop); 1117 } 1118 catch (std::bad_alloc) 1119 { 1120 rc = VERR_NO_MEMORY; 1326 1121 } 1327 1122 if (mGuestNotifications.size() > MAX_GUEST_NOTIFICATIONS) … … 1332 1127 * current value 1333 1128 */ 1334 if ( found&& mpfnHostCallback != NULL)1129 if (pProp && mpfnHostCallback != NULL) 1335 1130 { 1336 1131 char szFlags[MAX_FLAGS_LEN]; … … 1347 1142 * send the host an empty value 1348 1143 */ 1349 if (! found&& mpfnHostCallback != NULL)1144 if (!pProp && mpfnHostCallback != NULL) 1350 1145 { 1351 1146 /* Send out a host notification */ … … 1353 1148 rc = notifyHost(pszProperty, NULL, u64Timestamp, NULL); 1354 1149 } 1355 LogFlowThisFunc 1150 LogFlowThisFunc(("returning\n")); 1356 1151 } 1357 1152 … … 1367 1162 uint64_t u64Timestamp, const char *pszFlags) 1368 1163 { 1369 LogFlowFunc 1370 1164 LogFlowFunc(("pszName=%s, pszValue=%s, u64Timestamp=%llu, pszFlags=%s\n", 1165 pszName, pszValue, u64Timestamp, pszFlags)); 1371 1166 HOSTCALLBACKDATA HostCallbackData; 1372 1167 HostCallbackData.u32Magic = HOSTCALLBACKMAGIC; … … 1550 1345 extern "C" DECLCALLBACK(DECLEXPORT(int)) VBoxHGCMSvcLoad (VBOXHGCMSVCFNTABLE *ptable) 1551 1346 { 1552 int rc = V INF_SUCCESS;1347 int rc = VERR_IPE_UNINITIALIZED_STATUS; 1553 1348 1554 1349 LogFlowFunc(("ptable = %p\n", ptable)); 1555 1350 1556 if (!VALID_PTR(ptable)) 1557 { 1351 if (!RT_VALID_PTR(ptable)) 1558 1352 rc = VERR_INVALID_PARAMETER; 1559 }1560 1353 else 1561 1354 { 1562 1355 LogFlowFunc(("ptable->cbSize = %d, ptable->u32Version = 0x%08X\n", ptable->cbSize, ptable->u32Version)); 1563 1356 1564 if ( ptable->cbSize != sizeof 1357 if ( ptable->cbSize != sizeof(VBOXHGCMSVCFNTABLE) 1565 1358 || ptable->u32Version != VBOX_HGCM_SVC_VERSION) 1566 {1567 1359 rc = VERR_VERSION_MISMATCH; 1568 }1569 1360 else 1570 1361 { 1571 std::auto_ptr<Service> apService;1362 Service *pService = NULL; 1572 1363 /* No exceptions may propagate outside. */ 1573 try { 1574 apService = std::auto_ptr<Service>(new Service(ptable->pHelpers)); 1575 } catch (int rcThrown) { 1364 try 1365 { 1366 pService = new Service(ptable->pHelpers); 1367 rc = VINF_SUCCESS; 1368 } 1369 catch (int rcThrown) 1370 { 1576 1371 rc = rcThrown; 1577 } catch (...) { 1578 rc = VERR_UNRESOLVED_ERROR; 1372 } 1373 catch (...) 1374 { 1375 rc = VERR_UNEXPECTED_EXCEPTION; 1579 1376 } 1580 1377 … … 1594 1391 1595 1392 /* Service specific initialization. */ 1596 ptable->pvService = apService.release();1393 ptable->pvService = pService; 1597 1394 } 1395 else 1396 Assert(!pService); 1598 1397 } 1599 1398 }
Note:
See TracChangeset
for help on using the changeset viewer.