Changeset 75746 in vbox
- Timestamp:
- Nov 26, 2018 6:34:21 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestControl/service.cpp
r75737 r75746 137 137 138 138 /** 139 * Allocates the command with an HGCM request. Needs to be free'd using Free(). 139 * Allocates the command with an HGCM request - or put more accurately, it 140 * duplicates the given HGCM reguest (it does not allocate a HostCommand). 141 * 142 * Needs to be freed using Free(). 140 143 * 141 144 * @return IPRT status code. … … 168 171 if (mParmCount) 169 172 { 170 mpParms = (VBOXHGCMSVCPARM *)RTMemAllocZ(sizeof(VBOXHGCMSVCPARM) * mParmCount);173 mpParms = (VBOXHGCMSVCPARM *)RTMemAllocZ(sizeof(VBOXHGCMSVCPARM) * mParmCount); 171 174 if (NULL == mpParms) 172 175 rc = VERR_NO_MEMORY; … … 193 196 { 194 197 mpParms[i].u.pointer.addr = RTMemAlloc(mpParms[i].u.pointer.size); 195 if (NULL == mpParms[i].u.pointer.addr) 196 { 197 rc = VERR_NO_MEMORY; 198 break; 199 } 200 else 198 if (mpParms[i].u.pointer.addr != NULL) 201 199 memcpy(mpParms[i].u.pointer.addr, 202 200 paParms[i].u.pointer.addr, 203 201 mpParms[i].u.pointer.size); 202 else 203 rc = VERR_NO_MEMORY; 204 204 } 205 205 else … … 236 236 237 237 /** 238 * Frees the buffered HGCM request. 239 * 240 * @return IPRT status code. 238 * Frees the buffered HGCM request (not the HostCommand structure itself). 241 239 */ 242 240 void Free(void) … … 274 272 275 273 /** 276 * Copies data from the buffered HGCM request to the current HGCM request. 274 * Worker for Assign() that opies data from the buffered HGCM request to the 275 * current HGCM request. 277 276 * 278 277 * @return IPRT status code. … … 299 298 if (paDstParms[i].type != mpParms[i].type) 300 299 { 301 LogFlowFunc(("Parameter %RU32 type mismatch (got %RU32, expected %RU32)\n", 302 i, paDstParms[i].type, mpParms[i].type)); 300 LogFunc(("Parameter %RU32 type mismatch (got %RU32, expected %RU32)\n", i, paDstParms[i].type, mpParms[i].type)); 303 301 rc = VERR_INVALID_PARAMETER; 304 302 } … … 334 332 if (!paDstParms[i].u.pointer.addr) 335 333 rc = VERR_INVALID_PARAMETER; 336 337 if ( RT_SUCCESS(rc) 338 && paDstParms[i].u.pointer.size < mpParms[i].u.pointer.size) 334 else if (paDstParms[i].u.pointer.size < mpParms[i].u.pointer.size) 339 335 rc = VERR_BUFFER_OVERFLOW; 340 341 if (RT_SUCCESS(rc)) 342 { 336 else 343 337 memcpy(paDstParms[i].u.pointer.addr, 344 338 mpParms[i].u.pointer.addr, 345 339 mpParms[i].u.pointer.size); 346 }347 348 340 break; 349 341 } 350 342 351 343 default: 352 LogFlowFunc(("Parameter %RU32 of type %RU32 is not supported yet\n", 353 i, mpParms[i].type)); 344 LogFunc(("Parameter %RU32 of type %RU32 is not supported yet\n", i, mpParms[i].type)); 354 345 rc = VERR_NOT_SUPPORTED; 355 346 break; … … 359 350 if (RT_FAILURE(rc)) 360 351 { 361 LogFlowFunc(("Parameter %RU32 invalid (%Rrc), refusing\n", 362 i, rc)); 352 LogFunc(("Parameter %RU32 invalid (%Rrc), refusing\n", i, rc)); 363 353 break; 364 354 } … … 385 375 mMsgType, mParmCount, pConnection->mNumParms)); 386 376 /* 387 * So this call apparently failed because the guest wanted to peek388 * how much parameters it has to supply in order to successfully retrieve389 * this command. Let's tell him so!390 */377 * So this call apparently failed because the guest wanted to peek 378 * how much parameters it has to supply in order to successfully retrieve 379 * this command. Let's tell him so! 380 */ 391 381 rc = VERR_TOO_MUCH_DATA; 392 382 } … … 446 436 /** Array of HGCM parameters. */ 447 437 PVBOXHGCMSVCPARM mpParms; 448 /** Incoming timestamp ( us). */438 /** Incoming timestamp (nanoseconds). */ 449 439 uint64_t mTimestamp; 450 440 } HostCommand; … … 471 461 472 462 /** 473 * Structure for holding a connected guest client 474 * state. 463 * Structure for holding a connected guest client state. 475 464 */ 476 465 typedef struct ClientState … … 512 501 HostCmdListIter Dequeue(HostCmdListIter &curItem) 513 502 { 514 HostCommand *pHostCmd = (*curItem);503 HostCommand *pHostCmd = *curItem; 515 504 AssertPtr(pHostCmd); 516 505 … … 572 561 573 562 /* Only process newer commands. */ 563 /** @todo r=bird: This seems extremely bogus given that I cannot see 564 * ClientState::mHostCmdTS being set anywhere at all. */ 574 565 if (pHostCmd->mTimestamp <= mHostCmdTS) 575 566 return false; 576 567 577 568 /* 578 * If a sess eion filter is set, only obey those commands we're interested in569 * If a session filter is set, only obey those commands we're interested in 579 570 * by applying our context ID filter mask and compare the result with the 580 571 * original context ID. … … 582 573 bool fWant; 583 574 if (mFlags & CLIENTSTATE_FLAG_CONTEXTFILTER) 584 {585 575 fWant = (pHostCmd->mContextID & mFilterMask) == mFilterValue; 586 }587 576 else /* Client is interested in all commands. */ 588 577 fWant = true; … … 640 629 } 641 630 642 int Run( const ClientConnection*pConnection,643 HostCommand*pHostCmd)631 int Run(ClientConnection const *pConnection, 632 HostCommand *pHostCmd) 644 633 { 645 634 AssertPtrReturn(pConnection, VERR_INVALID_POINTER); 646 635 AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER); 647 636 648 int rc = VINF_SUCCESS;649 650 637 LogFlowFunc(("[Client %RU32] pConnection=%p, mHostCmdRc=%Rrc, mHostCmdTries=%RU32, mPeekCount=%RU32\n", 651 638 mID, pConnection, mHostCmdRc, mHostCmdTries, mPeekCount)); 652 639 653 mHostCmdRc = SendReply(pConnection, pHostCmd);640 int rc = mHostCmdRc = SendReply(pConnection, pHostCmd); 654 641 655 642 LogFlowThisFunc(("[Client %RU32] Processing command %RU32 ended with rc=%Rrc\n", mID, pHostCmd->mMsgType, mHostCmdRc)); 656 643 657 644 bool fRemove = false; 658 if (RT_FAILURE( mHostCmdRc))645 if (RT_FAILURE(rc)) 659 646 { 660 647 mHostCmdTries++; … … 668 655 * To not get the actual command if the client actually only wants to peek for 669 656 * the next command, there needs to be two rounds per try, e.g. 3 rounds = 6 tries. 670 * 671 ** @todo Fix the mess stated above. GUEST_MSG_WAIT should be become GUEST_MSG_PEEK, *only*657 */ 658 /** @todo Fix the mess stated above. GUEST_MSG_WAIT should be become GUEST_MSG_PEEK, *only* 672 659 * (and every time) returning the next upcoming host command (if any, blocking). Then 673 660 * it's up to the client what to do next, either peeking again or getting the actual 674 661 * host command via an own GUEST_ type message. 675 662 */ 676 if ( mHostCmdRc == VERR_TOO_MUCH_DATA)663 if (rc == VERR_TOO_MUCH_DATA) 677 664 { 678 665 if (mHostCmdTries == 6) … … 688 675 689 676 LogFlowThisFunc(("[Client %RU32] Tried command %RU32 for %RU32 times, (last result=%Rrc, fRemove=%RTbool)\n", 690 mID, pHostCmd->mMsgType, mHostCmdTries, mHostCmdRc, fRemove)); 691 692 if (RT_SUCCESS(rc)) /** @todo r=bird: confusing statement+state, rc hasn't been touched since the top and is always VINF_SUCCESS. */ 693 rc = mHostCmdRc; 677 mID, pHostCmd->mMsgType, mHostCmdTries, rc, fRemove)); 694 678 695 679 if (fRemove) … … 729 713 HostCmdListIter curCmd = mHostCmdList.begin(); 730 714 Assert(curCmd != mHostCmdList.end()); 731 HostCommand *pHostCmd = (*curCmd);715 HostCommand *pHostCmd = *curCmd; 732 716 AssertPtrReturn(pHostCmd, VERR_INVALID_POINTER); 733 717 … … 865 849 * to be able to successfully retrieve. */ 866 850 uint32_t mHostCmdTries; 867 /** Timestamp (us) of last host command processed. */ 851 /** Timestamp (nanoseconds) of last host command processed. 852 * @todo r=bird: Where is this set? */ 868 853 uint64_t mHostCmdTS; 869 854 /** Flag indicating whether a client call (GUEST_MSG_WAIT) currently is pending. … … 1061 1046 1062 1047 /** 1063 * Handles a client which disconnected. This functiond does some 1064 * internal cleanup as well as sends notifications to the host so 1065 * that the host can do the same (if required). 1048 * Handles a client which disconnected. 1049 * 1050 * This functiond does some internal cleanup as well as sends notifications to 1051 * the host so that the host can do the same (if required). 1066 1052 * 1067 1053 * @return IPRT status code. … … 1101 1087 * via a (multi stage) progress object. 1102 1088 */ 1089 /** @todo r=bird: We have RTListForEachSafe for this purpose... Would save a 1090 * few lines and bother here. */ 1103 1091 HostCommand *pCurCmd = RTListGetFirst(&mHostCmdList, HostCommand, Node); 1104 1092 while (pCurCmd) … … 1152 1140 { 1153 1141 /* 1154 * Lookup client in our listso that we can assign the context ID of1142 * Lookup client in our map so that we can assign the context ID of 1155 1143 * a command to that client. 1156 1144 */ … … 1413 1401 #endif 1414 1402 } 1403 /** @todo r=bird: If pHostCmd->Allocate fails, you leak stuff. It's not 1404 * likely, since it'll only fail if the host gives us an incorrect 1405 * parameter list (first param isn't uint32_t) or we're out of memory. 1406 * In the latter case, of course, you're not exactly helping... */ 1415 1407 1416 1408 return rc; … … 1418 1410 1419 1411 /** 1420 * @interface_method_impl{VBOXHGCMSVCFNTABLE,pfnCall}1412 * Worker for svcCall() that helps implement VBOXHGCMSVCFNTABLE::pfnCall. 1421 1413 * 1422 1414 * @note All functions which do not involve an unreasonable delay will be
Note:
See TracChangeset
for help on using the changeset viewer.

