Changeset 29867 in vbox for trunk/src/VBox/HostServices/GuestControl
- Timestamp:
- May 28, 2010 3:09:23 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 62112
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestControl/service.cpp
r29797 r29867 28 28 * new host commands to perform. There can be multiple clients connected 29 29 * to a service. A client is represented by its HGCM client ID. 30 * - Context ID: A (almost) unique ID automatically generated on the host (Main API) 30 * - Context ID: A (almost) unique ID automatically generated on the host (Main API) 31 31 * to not only distinguish clients but individual requests. Because 32 32 * the host does not know anything about connected clients it needs 33 33 * an indicator which it can refer to later. This context ID gets 34 * internally bound by the service to a client which actually processes 34 * internally bound by the service to a client which actually processes 35 35 * the command in order to have a relationship between client<->context ID(s). 36 36 * 37 37 * The host can trigger commands which get buffered by the service (with full HGCM 38 * parameter info). As soon as a client connects (or is ready to do some new work) 39 * it gets a buffered host command to process it. This command then will be immediately 38 * parameter info). As soon as a client connects (or is ready to do some new work) 39 * it gets a buffered host command to process it. This command then will be immediately 40 40 * removed from the command list. If there are ready clients but no new commands to be 41 41 * processed, these clients will be set into a deferred state (that is being blocked 42 42 * to return until a new command is available). 43 43 * 44 * If a client needs to inform the host that something happend, it can send a 44 * If a client needs to inform the host that something happend, it can send a 45 45 * message to a low level HGCM callback registered in Main. This callback contains 46 * the actual data as well as the context ID to let the host do the next necessary 46 * the actual data as well as the context ID to let the host do the next necessary 47 47 * steps for this context. This context ID makes it possible to wait for an event 48 48 * inside the host's Main API function (like starting a process on the guest and 49 49 * wait for getting its PID returned by the client) as well as cancelling blocking 50 * host calls in order the client terminated/crashed (HGCM detects disconnected 50 * host calls in order the client terminated/crashed (HGCM detects disconnected 51 51 * clients and reports it to this service's callback). 52 52 */ … … 80 80 /** 81 81 * Structure for holding all clients with their 82 * generated host contexts. This is necessary for 82 * generated host contexts. This is necessary for 83 83 * mainting the relationship between a client and its context IDs. 84 84 */ … … 135 135 GuestCall() : mClientID(0), mHandle(0), mParms(NULL), mNumParms(0) {} 136 136 /** The normal contructor. */ 137 GuestCall(uint32_t aClientID, VBOXHGCMCALLHANDLE aHandle, 137 GuestCall(uint32_t aClientID, VBOXHGCMCALLHANDLE aHandle, 138 138 VBOXHGCMSVCPARM aParms[], uint32_t cParms) 139 139 : mClientID(aClientID), mHandle(aHandle), mParms(aParms), mNumParms(cParms) {} … … 475 475 AssertPtr(pCmd); 476 476 int rc; 477 477 478 478 /* Sufficient parameter space? */ 479 479 if (pCmd->mParmBuf.uParmCount > cParms) … … 481 481 paParms[0].setUInt32(pCmd->mParmBuf.uMsg); /* Message ID */ 482 482 paParms[1].setUInt32(pCmd->mParmBuf.uParmCount); /* Required parameters for message */ 483 483 484 484 /* 485 485 * So this call apparently failed because the guest wanted to peek … … 500 500 * defer the guest call until we have something from the host. 501 501 */ 502 int Service::retrieveNextHostCmd(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, 502 int Service::retrieveNextHostCmd(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, 503 503 uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 504 504 { 505 505 int rc = VINF_SUCCESS; 506 506 507 /* 507 /* 508 508 * Lookup client in our list so that we can assign the context ID of 509 509 * a command to that client. … … 547 547 * later reference & cleanup). */ 548 548 Assert(curCmd.mContextID > 0); 549 /// @todo r=bird: check if already in the list. 549 550 it->mContextList.push_back(curCmd.mContextID); 550 551 … … 568 569 { 569 570 if (it->mClientID == u32ClientID) 570 { 571 { 571 572 if (it->mNumParms >= 2) 572 573 { 573 574 it->mParms[0].setUInt32(GETHOSTMSG_EXEC_HOST_CANCEL_WAIT); /* Message ID. */ 574 575 it->mParms[1].setUInt32(0); /* Required parameters for message. */ 575 } 576 } 576 577 if (mpHelpers) 577 mpHelpers->pfnCallComplete(it->mHandle, rc); 578 mpHelpers->pfnCallComplete(it->mHandle, rc); 578 579 it = mClientList.erase(it); 579 580 } … … 636 637 && newCmd.mParmBuf.uParmCount > 0) 637 638 { 638 /* 639 /* 639 640 * Assume that the context ID *always* is the first parameter, 640 641 * assign the context ID to the command. … … 651 652 { 652 653 GuestCall guest = mClientList.front(); 653 rc = sendHostCmdToGuest(&newCmd, 654 rc = sendHostCmdToGuest(&newCmd, 654 655 guest.mHandle, guest.mNumParms, guest.mParms); 655 656 … … 657 658 AssertPtr(mpHelpers); 658 659 mpHelpers->pfnCallComplete(guest.mHandle, rc); 659 mClientList.pop_front(); 660 660 mClientList.pop_front(); 661 661 662 /* If we got VERR_TOO_MUCH_DATA we buffer the host command in the next block 662 * and return success to the host. */ 663 * and return success to the host. */ 663 664 if (rc == VERR_TOO_MUCH_DATA) 664 665 { … … 675 676 if (!fProcessed) 676 677 { 677 mHostCmds.push_back(newCmd); 678 mHostCmds.push_back(newCmd); 678 679 #if 0 679 680 /* Limit list size by deleting oldest element. */
Note:
See TracChangeset
for help on using the changeset viewer.