Changeset 53077 in vbox for trunk/src/VBox/Additions/common/VBoxGuest
- Timestamp:
- Oct 16, 2014 12:36:28 PM (10 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
r52789 r53077 691 691 * @returns VBox status code. 692 692 */ 693 static int VBoxGuestHeartbeatSend(void) 694 { 695 VMMDevRequestHeader *pReq; 696 int rc = VbglGRAlloc(&pReq, sizeof(*pReq), VMMDevReq_GuestHeartbeat); 697 Log(("VBoxGuestHeartbeatSend: VbglGRAlloc VBoxGuestHeartbeatSend completed with rc=%Rrc\n", rc)); 698 if (RT_SUCCESS(rc)) 699 { 700 rc = VbglGRPerform(pReq); 693 static int VBoxGuestHeartbeatSend(PVBOXGUESTDEVEXT pDevExt) 694 { 695 int rc; 696 if (pDevExt->pReqGuestHeartbeat) 697 { 698 rc = VbglGRPerform(pDevExt->pReqGuestHeartbeat); 701 699 Log(("VBoxGuestHeartbeatSend: VbglGRPerform VBoxGuestHeartbeatSend completed with rc=%Rrc\n", rc)); 702 VbglGRFree(pReq); 703 } 700 } 701 else 702 rc = VERR_INVALID_STATE; 704 703 return rc; 705 704 } … … 735 734 * Callback for heartbeat timer. 736 735 */ 737 static DECLCALLBACK(void) VBoxGuestHeartbeatTimerHandler(PRTTIMER p1, void *p 2, uint64_t p3)736 static DECLCALLBACK(void) VBoxGuestHeartbeatTimerHandler(PRTTIMER p1, void *pvUser, uint64_t p3) 738 737 { 739 738 NOREF(p1); 740 NOREF(p2);741 739 NOREF(p3); 742 740 743 int rc = VBoxGuestHeartbeatSend(); 741 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pvUser; 742 if (!pDevExt) 743 return; 744 745 int rc = VBoxGuestHeartbeatSend(pDevExt); 744 746 if (RT_FAILURE(rc)) 745 747 { … … 1032 1034 pDevExt->MouseNotifyCallback.pfnNotify = NULL; 1033 1035 pDevExt->MouseNotifyCallback.pvUser = NULL; 1036 pDevExt->pReqGuestHeartbeat = NULL; 1034 1037 1035 1038 /* … … 1111 1114 LogRelFunc(("VBoxReportGuestDriverStatus failed, rc=%Rrc\n", rc)); 1112 1115 1116 /** @todo Move heartbeat initialization into a separate function. */ 1113 1117 /* Make sure that heartbeat checking is disabled. */ 1114 1118 rc = VBoxGuestHeartbeatHostConfigure(pDevExt, false); … … 1118 1122 if (RT_SUCCESS(rc)) 1119 1123 { 1120 LogFlowFunc(("Setting up heartbeat to trigger every %RU64 sec\n", pDevExt->cNsHeartbeatInterval / 1000000000)); 1121 rc = RTTimerCreateEx(&pDevExt->pHeartbeatTimer, pDevExt->cNsHeartbeatInterval, 1122 0, (PFNRTTIMER)VBoxGuestHeartbeatTimerHandler, NULL); 1124 /* Preallocate the request to use it from the timer callback because: 1125 * 1) on Windows VbglGRAlloc must be called at IRQL <= APC_LEVEL 1126 * and the timer callback runs at DISPATCH_LEVEL; 1127 * 2) avoid repeated allocations. 1128 */ 1129 rc = VbglGRAlloc(&pDevExt->pReqGuestHeartbeat, sizeof(*pDevExt->pReqGuestHeartbeat), VMMDevReq_GuestHeartbeat); 1130 if (RT_FAILURE(rc)) 1131 LogRelFunc(("VbglGRAlloc(VMMDevReq_GuestHeartbeat) %Rrc\n", rc)); 1132 1133 if (RT_SUCCESS(rc)) 1134 { 1135 LogFlowFunc(("Setting up heartbeat to trigger every %RU64 sec\n", pDevExt->cNsHeartbeatInterval / 1000000000)); 1136 rc = RTTimerCreateEx(&pDevExt->pHeartbeatTimer, pDevExt->cNsHeartbeatInterval, 1137 0, (PFNRTTIMER)VBoxGuestHeartbeatTimerHandler, pDevExt); 1138 } 1139 1123 1140 if (RT_SUCCESS(rc)) 1124 1141 { … … 1132 1149 /* Disable host heartbeat check if we failed */ 1133 1150 VBoxGuestHeartbeatHostConfigure(pDevExt, false); 1151 1152 VbglGRFree(pDevExt->pReqGuestHeartbeat); 1153 pDevExt->pReqGuestHeartbeat = NULL; 1134 1154 } 1135 1155 } … … 1211 1231 VBoxGuestHeartbeatHostConfigure(pDevExt, false); 1212 1232 } 1233 1234 VbglGRFree(pDevExt->pReqGuestHeartbeat); 1235 pDevExt->pReqGuestHeartbeat = NULL; 1213 1236 1214 1237 /* -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
r52789 r53077 186 186 /** Heartbeat timer interval in nanoseconds. */ 187 187 uint64_t cNsHeartbeatInterval; 188 /** Preallocated VMMDevReq_GuestHeartbeat request. */ 189 VMMDevRequestHeader *pReqGuestHeartbeat; 188 190 } VBOXGUESTDEVEXT; 189 191 /** Pointer to the VBoxGuest driver data. */
Note:
See TracChangeset
for help on using the changeset viewer.