Changeset 43899 in vbox
- Timestamp:
- Nov 16, 2012 2:34:12 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82125
- Location:
- trunk/src/VBox/HostServices/HostChannel
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/HostChannel/HostChannel.cpp
r43892 r43899 712 712 } VBOXHOSTCHANNELEVENT; 713 713 714 /* This is called under the lock. */ 715 int vboxHostChannelQueryEvent(VBOXHOSTCHCLIENT *pClient, 716 bool *pfEvent, 717 uint32_t *pu32Handle, 718 uint32_t *pu32Id, 719 void *pvParm, 720 uint32_t cbParm, 721 uint32_t *pcbParmOut) 722 { 714 int vboxHostChannelEventWait(VBOXHOSTCHCLIENT *pClient, 715 bool *pfEvent, 716 VBOXHGCMCALLHANDLE callHandle, 717 VBOXHGCMSVCPARM *paParms) 718 { 719 int rc = vboxHostChannelLock(); 720 if (RT_FAILURE(rc)) 721 { 722 return rc; 723 } 724 725 if (pClient->fAsync) 726 { 727 /* If there is a wait request already, cancel it. */ 728 vboxHostChannelReportAsync(pClient, 0, VBOX_HOST_CHANNEL_EVENT_CANCELLED, NULL, 0); 729 pClient->fAsync = false; 730 } 731 723 732 /* Check if there is something in the client's event queue. */ 724 725 733 VBOXHOSTCHANNELEVENT *pEvent = RTListGetFirst(&pClient->listEvents, VBOXHOSTCHANNELEVENT, NodeEvent); 726 734 … … 732 740 RTListNodeRemove(&pEvent->NodeEvent); 733 741 742 HOSTCHLOG(("HostChannel: QueryEvent: (%d), cbEvent %d\n", 743 pClient->u32ClientID, pEvent->cbEvent)); 744 745 vboxHostChannelEventParmsSet(paParms, pEvent->u32ChannelHandle, 746 pEvent->u32Id, pEvent->pvEvent, pEvent->cbEvent); 747 734 748 *pfEvent = true; 735 *pu32Handle = pEvent->u32ChannelHandle;736 *pu32Id = pEvent->u32Id;737 738 uint32_t cbToCopy = RT_MIN(cbParm, pEvent->cbEvent);739 740 HOSTCHLOG(("HostChannel: QueryEvent: (%d), cbParm %d, cbEvent %d\n",741 pClient->u32ClientID, cbParm, pEvent->cbEvent));742 743 if (cbToCopy > 0)744 {745 memcpy(pvParm, pEvent->pvEvent, cbToCopy);746 }747 748 *pcbParmOut = cbToCopy;749 749 750 750 RTMemFree(pEvent); … … 752 752 else 753 753 { 754 /* No event available at the time. Process asynchronously. */ 755 pClient->fAsync = true; 756 pClient->async.callHandle = callHandle; 757 pClient->async.paParms = paParms; 758 754 759 /* Tell the caller that there is no event. */ 755 760 *pfEvent = false; 756 761 } 757 762 758 return VINF_SUCCESS; 759 } 763 vboxHostChannelUnlock(); 764 return rc; 765 } 766 767 int vboxHostChannelEventCancel(VBOXHOSTCHCLIENT *pClient) 768 { 769 int rc = vboxHostChannelLock(); 770 771 if (RT_SUCCESS(rc)) 772 { 773 if (pClient->fAsync) 774 { 775 /* If there is a wait request alredy, cancel it. */ 776 vboxHostChannelReportAsync(pClient, 0, VBOX_HOST_CHANNEL_EVENT_CANCELLED, NULL, 0); 777 778 pClient->fAsync = false; 779 } 780 781 vboxHostChannelUnlock(); 782 } 783 784 return rc; 785 } 786 760 787 761 788 /* @thread provider */ -
trunk/src/VBox/HostServices/HostChannel/HostChannel.h
r43785 r43899 98 98 uint32_t *pu32SizeDataReturned); 99 99 100 int vboxHostChannelQueryEvent(VBOXHOSTCHCLIENT *pClient, 101 bool *pfEvent, 102 uint32_t *pu32Handle, 103 uint32_t *pu32Id, 104 void *pvParm, 105 uint32_t cbParm, 106 uint32_t *pcbParmOut); 100 int vboxHostChannelEventWait(VBOXHOSTCHCLIENT *pClient, 101 bool *pfEvent, 102 VBOXHGCMCALLHANDLE callHandle, 103 VBOXHGCMSVCPARM *paParms); 104 105 int vboxHostChannelEventCancel(VBOXHOSTCHCLIENT *pClient); 107 106 108 107 int vboxHostChannelQuery(VBOXHOSTCHCLIENT *pClient, … … 121 120 122 121 123 void vboxHostChannelReportAsync(VBOXHOSTCHCLIENT *pClient, uint32_t u32ChannelHandle, 124 uint32_t u32Id, const void *pvEvent, uint32_t cbEvent); 122 void vboxHostChannelEventParmsSet(VBOXHGCMSVCPARM *paParms, 123 uint32_t u32ChannelHandle, 124 uint32_t u32Id, 125 const void *pvEvent, 126 uint32_t cbEvent); 127 128 void vboxHostChannelReportAsync(VBOXHOSTCHCLIENT *pClient, 129 uint32_t u32ChannelHandle, 130 uint32_t u32Id, 131 const void *pvEvent, 132 uint32_t cbEvent); 125 133 126 134 #endif /* __VBOXHOSTCHANNEL__H */ -
trunk/src/VBox/HostServices/HostChannel/service.cpp
r43462 r43899 107 107 } 108 108 109 void vboxHostChannelEventParmsSet(VBOXHGCMSVCPARM *paParms, 110 uint32_t u32ChannelHandle, 111 uint32_t u32Id, 112 const void *pvEvent, 113 uint32_t cbEvent) 114 { 115 if (cbEvent > 0) 116 { 117 void *pvParm = NULL; 118 uint32_t cbParm = 0; 119 120 VBoxHGCMParmPtrGet(&paParms[2], &pvParm, &cbParm); 121 122 uint32_t cbToCopy = RT_MIN(cbParm, cbEvent); 123 if (cbToCopy > 0) 124 { 125 Assert(pvParm); 126 memcpy(pvParm, pvEvent, cbToCopy); 127 } 128 } 129 130 VBoxHGCMParmUInt32Set(&paParms[0], u32ChannelHandle); 131 VBoxHGCMParmUInt32Set(&paParms[1], u32Id); 132 VBoxHGCMParmUInt32Set(&paParms[3], cbEvent); 133 } 134 109 135 /* This is called under the lock. */ 110 136 void vboxHostChannelReportAsync(VBOXHOSTCHCLIENT *pClient, … … 114 140 uint32_t cbEvent) 115 141 { 116 if (cbEvent > 0) 117 { 118 void *pvParm = NULL; 119 uint32_t cbParm = 0; 120 121 VBoxHGCMParmPtrGet(&pClient->async.paParms[2], &pvParm, &cbParm); 122 123 uint32_t cbToCopy = RT_MIN(cbParm, cbEvent); 124 if (cbToCopy > 0) 125 { 126 memcpy(pvParm, pvEvent, cbToCopy); 127 } 128 } 129 130 VBoxHGCMParmUInt32Set(&pClient->async.paParms[0], u32ChannelHandle); 131 VBoxHGCMParmUInt32Set(&pClient->async.paParms[1], u32Id); 132 VBoxHGCMParmUInt32Set(&pClient->async.paParms[3], cbEvent); 142 Assert(RTCritSectIsOwner(&g_critsect)); 143 144 vboxHostChannelEventParmsSet(pClient->async.paParms, 145 u32ChannelHandle, 146 u32Id, 147 pvEvent, 148 cbEvent); 133 149 134 150 LogRelFlow(("svcCall: CallComplete for pending\n")); … … 438 454 else 439 455 { 440 void *pvParm; 441 uint32_t cbParm; 442 443 rc = VBoxHGCMParmPtrGet(&paParms[2], &pvParm, &cbParm); 456 bool fEvent = false; 457 458 rc = vboxHostChannelEventWait(pClient, &fEvent, callHandle, paParms); 444 459 445 460 if (RT_SUCCESS(rc)) 446 461 { 447 /* This is accessed from the SVC thread and other threads. */ 448 rc = vboxHostChannelLock(); 449 450 if (RT_SUCCESS(rc)) 462 if (!fEvent) 451 463 { 452 if (pClient->fAsync) 453 { 454 /* If there is a wait request already, cancel it. */ 455 vboxHostChannelReportAsync(pClient, 0, VBOX_HOST_CHANNEL_EVENT_CANCELLED, NULL, 0); 456 457 pClient->fAsync = false; 458 } 459 460 bool fEvent = false; 461 uint32_t u32Handle = 0; 462 uint32_t u32Id = 0; 463 uint32_t cbParmOut = 0; 464 465 rc = vboxHostChannelQueryEvent(pClient, &fEvent, &u32Handle, &u32Id, 466 pvParm, cbParm, &cbParmOut); 467 468 if (RT_SUCCESS(rc)) 469 { 470 if (fEvent) 471 { 472 VBoxHGCMParmUInt32Set(&paParms[0], u32Handle); 473 VBoxHGCMParmUInt32Set(&paParms[1], u32Id); 474 VBoxHGCMParmUInt32Set(&paParms[3], cbParmOut); 475 } 476 else 477 { 478 /* No event available at the time. Process asynchronously. */ 479 fAsynchronousProcessing = true; 480 481 pClient->fAsync = true; 482 pClient->async.callHandle = callHandle; 483 pClient->async.paParms = paParms; 484 485 LogRel2(("svcCall: async.\n")); 486 } 487 } 488 489 vboxHostChannelUnlock(); 464 /* No event available at the time. Process asynchronously. */ 465 fAsynchronousProcessing = true; 466 467 LogRel2(("svcCall: async.\n")); 490 468 } 491 469 } … … 503 481 else 504 482 { 505 /* This is accessed from the SVC thread and other threads. */ 506 rc = vboxHostChannelLock(); 507 508 if (RT_SUCCESS(rc)) 509 { 510 if (pClient->fAsync) 511 { 512 /* If there is a wait request alredy, cancel it. */ 513 vboxHostChannelReportAsync(pClient, 0, VBOX_HOST_CHANNEL_EVENT_CANCELLED, NULL, 0); 514 515 pClient->fAsync = false; 516 } 517 518 vboxHostChannelUnlock(); 519 } 483 rc = vboxHostChannelEventCancel(pClient); 520 484 } 521 485 } break;
Note:
See TracChangeset
for help on using the changeset viewer.