Changeset 34253 in vbox
- Timestamp:
- Nov 22, 2010 3:34:38 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestControl/service.cpp
r33540 r34253 167 167 /** Client contexts list. */ 168 168 ClientContextsList mClientContextsList; 169 169 /** Number of connected clients. */ 170 uint32_t mNumClients; 170 171 public: 171 172 explicit Service(PVBOXHGCMSVCHELPERS pHelpers) … … 173 174 , mpfnHostCallback(NULL) 174 175 , mpvHostData(NULL) 176 , mNumClients(0) 175 177 { 176 178 } … … 293 295 294 296 295 /** @todo Write some nice doc headers! */ 296 /* Stores a HGCM request in an internal buffer (pEx). Needs to be freed later using execBufferFree(). */ 297 /** 298 * Stores a HGCM request in an internal buffer. Needs to be free'd using paramBufferFree(). 299 * 300 * @return IPRT status code. 301 * @param pBuf Buffer to store the HGCM request into. 302 * @param uMsg Message type. 303 * @param cParms Number of parameters of HGCM request. 304 * @param paParms Array of parameters of HGCM request. 305 */ 297 306 int Service::paramBufferAllocate(PVBOXGUESTCTRPARAMBUFFER pBuf, uint32_t uMsg, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 298 307 { … … 361 370 } 362 371 363 /* Frees a buffered HGCM request. */ 372 /** 373 * Frees a buffered HGCM request. 374 * 375 * @return IPRT status code. 376 * @param pBuf Parameter buffer to free. 377 */ 364 378 void Service::paramBufferFree(PVBOXGUESTCTRPARAMBUFFER pBuf) 365 379 { … … 382 396 } 383 397 384 /* Assigns data from a buffered HGCM request to the current HGCM request. */ 398 /** 399 * Assigns data from a buffered HGCM request to the current HGCM request. 400 * 401 * @return IPRT status code. 402 * @param pBuf Parameter buffer to assign. 403 * @param cParms Number of parameters the HGCM request can handle. 404 * @param paParms Array of parameters of HGCM request to fill the data into. 405 */ 385 406 int Service::paramBufferAssign(PVBOXGUESTCTRPARAMBUFFER pBuf, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 386 407 { … … 423 444 } 424 445 446 /** 447 * Handles a client which just connected. 448 * 449 * @return IPRT status code. 450 * @param u32ClientID 451 * @param pvClient 452 */ 425 453 int Service::clientConnect(uint32_t u32ClientID, void *pvClient) 426 454 { 427 455 LogFlowFunc(("New client (%ld) connected\n", u32ClientID)); 456 mNumClients++; 428 457 return VINF_SUCCESS; 429 458 } 430 459 460 /** 461 * Handles a client which disconnected. This functiond does some 462 * internal cleanup as well as sends notifications to the host so 463 * that the host can do the same (if required). 464 * 465 * @return IPRT status code. 466 * @param u32ClientID The client's ID of which disconnected. 467 * @param pvClient User data, not used at the moment. 468 */ 431 469 int Service::clientDisconnect(uint32_t u32ClientID, void *pvClient) 432 470 { 433 471 LogFlowFunc(("Client (%ld) disconnected\n", u32ClientID)); 472 mNumClients--; 473 Assert(mNumClients >= 0); 434 474 435 475 /* … … 484 524 } 485 525 526 /** 527 * Sends a specified host command to a client. 528 * 529 * @return IPRT status code. 530 * @param pCmd Host comamnd to send. 531 * @param callHandle Call handle of the client to send the command to. 532 * @param cParms Number of parameters. 533 * @param paParms Array of parameters. 534 */ 486 535 int Service::sendHostCmdToGuest(HostCmd *pCmd, VBOXHGCMCALLHANDLE callHandle, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 487 536 { … … 509 558 } 510 559 511 /* 560 /** 512 561 * Either fills in parameters from a pending host command into our guest context or 513 562 * defer the guest call until we have something from the host. 563 * 564 * @return IPRT status code. 565 * @param u32ClientID The client's ID. 566 * @param callHandle The client's call handle. 567 * @param cParms Number of parameters. 568 * @param paParms Array of parameters. 514 569 */ 515 570 int Service::retrieveNextHostCmd(uint32_t u32ClientID, VBOXHGCMCALLHANDLE callHandle, … … 571 626 } 572 627 573 /* 628 /** 574 629 * Client asks itself (in another thread) to cancel all pending waits which are blocking the client 575 630 * from shutting down / doing something else. 631 * 632 * @return IPRT status code. 633 * @param u32ClientID The client's ID. 576 634 */ 577 635 int Service::cancelPendingWaits(uint32_t u32ClientID) … … 598 656 } 599 657 658 /** 659 * Notifies the host (using low-level HGCM callbacks) about an event 660 * which was sent from the client. 661 * 662 * @return IPRT status code. 663 * @param eFunction Function (event) that occured. 664 * @param cParms Number of parameters. 665 * @param paParms Array of parameters. 666 */ 600 667 int Service::notifyHost(uint32_t eFunction, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 601 668 { … … 657 724 } 658 725 726 /** 727 * Processes a command receiveed from the host side and re-routes it to 728 * a connect client on the guest. 729 * 730 * @return IPRT status code. 731 * @param eFunction Function code to process. 732 * @param cParms Number of parameters. 733 * @param paParms Array of parameters. 734 */ 659 735 int Service::processHostCmd(uint32_t eFunction, uint32_t cParms, VBOXHGCMSVCPARM paParms[]) 660 736 { 661 int rc = VINF_SUCCESS; 737 /* 738 * If no client is connected at all we don't buffer any host commands 739 * and immediately return an error to the host. This avoids the host 740 * waiting for a response from the guest side in case VBoxService on 741 * the guest is not running/system is messed up somehow. 742 */ 743 if (mNumClients <= 0) 744 return VERR_NOT_FOUND; 662 745 663 746 HostCmd newCmd; 664 rc = paramBufferAllocate(&newCmd.mParmBuf, eFunction, cParms, paParms);747 int rc = paramBufferAllocate(&newCmd.mParmBuf, eFunction, cParms, paParms); 665 748 if ( RT_SUCCESS(rc) 666 749 && newCmd.mParmBuf.uParmCount > 0)
Note:
See TracChangeset
for help on using the changeset viewer.