Changeset 68568 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Aug 31, 2017 12:10:33 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 117785
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r68566 r68568 190 190 /** The IRQ high-level Mutex. */ 191 191 static kmutex_t g_HighLevelIrqMtx; 192 /** Layered device handle for kernel keep-attached opens */193 static ldi_handle_t g_LdiHandle = NULL;194 /** Ref counting for IDCOpen calls */195 static uint64_t g_cLdiOpens = 0;196 /** The Mutex protecting the LDI handle in IDC opens */197 static kmutex_t g_LdiMtx;198 192 /** Whether soft-ints are setup. */ 199 193 static bool g_fSoftIntRegistered = false; … … 220 214 cmn_err(CE_NOTE, "failed to initialize driver logging rc=%d!\n", rc); 221 215 222 mutex_init(&g_LdiMtx, NULL, MUTEX_DRIVER, NULL);223 224 216 /* 225 217 * Prevent module autounloading. … … 260 252 261 253 if (!rc) 262 {263 mutex_destroy(&g_LdiMtx);264 254 RTR0Term(); 265 }266 255 return rc; 267 256 } … … 786 775 else if (uReq == VBGL_IOCTL_IDC_CONNECT) 787 776 { 788 /* Reference ourselves to make sure we don't go away. 789 Note! Would be better if the IDC code did this. */ 790 mutex_enter(&g_LdiMtx); 791 if (g_LdiHandle) 792 { 793 ++g_cLdiOpens; 794 rc = VINF_SUCCESS; 795 } 796 else 797 { 798 ldi_ident_t DevIdent = ldi_ident_from_anon(); 799 rc = ldi_open_by_name(VBOXGUEST_DEVICE_NAME, FREAD, kcred, &g_LdiHandle, DevIdent); 800 ldi_ident_release(DevIdent); 801 if (!rc) 802 ++g_cLdiOpens; 803 else 804 { 805 LogRel(("VBoxGuestIDCOpen: ldi_open_by_name failed. rc=%d\n", rc)); 806 rc = VERR_OPEN_FAILED; 807 } 808 } 809 mutex_exit(&g_LdiMtx); 810 777 rc = VGDrvCommonCreateKernelSession(&g_DevExt, &pSession); 811 778 if (RT_SUCCESS(rc)) 812 779 { 813 rc = VGDrvCommonCreateKernelSession(&g_DevExt, &pSession); 814 if (RT_SUCCESS(rc)) 815 { 816 rc = VGDrvCommonIoCtl(uReq, &g_DevExt, pSession, pReqHdr, cbReq); 817 if (RT_FAILURE(rc)) 818 VGDrvCommonCloseSession(&g_DevExt, pSession); 819 } 780 rc = VGDrvCommonIoCtl(uReq, &g_DevExt, pSession, pReqHdr, cbReq); 781 if (RT_FAILURE(rc)) 782 VGDrvCommonCloseSession(&g_DevExt, pSession); 820 783 } 821 784 } 822 785 else 823 786 rc = VERR_INVALID_HANDLE; 824 825 /*826 * Dereference the driver on disconnect and failed connect.827 */828 if (RT_UNLIKELY( ( uReq == VBGL_IOCTL_IDC_CONNECT829 && RT_FAILURE(rc))830 || ( uReq == VBGL_IOCTL_IDC_DISCONNECT831 && RT_SUCCESS(rc)) ))832 {833 mutex_enter(&g_LdiMtx);834 if (g_cLdiOpens > 0)835 --g_cLdiOpens;836 if ( g_cLdiOpens == 0837 && g_LdiHandle)838 {839 ldi_close(g_LdiHandle, FREAD, kcred);840 g_LdiHandle = NULL;841 }842 mutex_exit(&g_LdiMtx);843 }844 787 } 845 788 else -
trunk/src/VBox/Additions/common/VBoxGuestLib/Makefile.kmk
r68561 r68568 73 73 HGCM.cpp \ 74 74 VbglR0CanUsePhysPageList.cpp 75 VBoxGuestR0Lib_SOURCES.win = VBoxGuestR0LibIdc-win.cpp 76 VBoxGuestR0Lib_SOURCES.os2 = VBoxGuestR0LibIdc-os2.cpp 77 ifn1of ($(KBUILD_TARGET), win os2) 78 VBoxGuestR0Lib_SOURCES += VBoxGuestR0LibIdc-unix.cpp 75 VBoxGuestR0Lib_SOURCES.os2 = VBoxGuestR0LibIdc-os2.cpp 76 VBoxGuestR0Lib_SOURCES.solaris = VBoxGuestR0LibIdc-solaris.cpp 77 VBoxGuestR0Lib_SOURCES.win = VBoxGuestR0LibIdc-win.cpp 78 ifn1of ($(KBUILD_TARGET), os2 solaris win) 79 VBoxGuestR0Lib_SOURCES += VBoxGuestR0LibIdc-unix.cpp 79 80 endif 80 81 -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibIdc-win.cpp
r68561 r68568 138 138 */ 139 139 rc = vbglR0IdcNtCallInternal(pDeviceObject, pFileObject, VBGL_IOCTL_IDC_CONNECT, &pReq->Hdr); 140 if (RT_SUCCESS(rc) )140 if (RT_SUCCESS(rc) && RT_SUCCESS(pReq->Hdr.rc)) 141 141 { 142 142 pHandle->s.pDeviceObject = pDeviceObject; … … 161 161 PFILE_OBJECT pFileObject = pHandle->s.pFileObject; 162 162 int rc = vbglR0IdcNtCallInternal(pHandle->s.pDeviceObject, pFileObject, VBGL_IOCTL_IDC_DISCONNECT, &pReq->Hdr); 163 if (RT_SUCCESS(rc) )163 if (RT_SUCCESS(rc) && RT_SUCCESS(pReq->Hdr.rc)) 164 164 { 165 165 pHandle->s.pDeviceObject = NULL; -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR0LibInternal.h
r68550 r68568 33 33 #ifdef RT_OS_WINDOWS 34 34 # include <iprt/nt/ntddk.h> 35 #elif defined(RT_OS_SOLARIS) 36 # include <sys/conf.h> 37 # include <sys/sunldi.h> 38 # include <sys/file.h> 39 # undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */ 35 40 #endif 36 41 … … 43 48 /** Pointer to the session handle. */ 44 49 void *pvSession; 45 # 50 #ifdef RT_OS_WINDOWS 46 51 /** Pointer to the NT device object. */ 47 52 PDEVICE_OBJECT pDeviceObject; 48 53 /** Pointer to the NT file object. */ 49 54 PFILE_OBJECT pFileObject; 50 # endif 55 #elif defined(RT_OS_SOLARIS) 56 /** LDI device handle to keep the device attached. */ 57 ldi_handle_t hDev; 58 #endif 51 59 }; 52 60 /** Indicate that the structure is present. */
Note:
See TracChangeset
for help on using the changeset viewer.