vbox的更動 67018 路徑 trunk/src/VBox/HostServices
- 時間撮記:
- 2017-5-22 下午02:55:44 (8 年 以前)
- 檔案:
-
- 修改 1 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/HostServices/SharedFolders/shflhandle.cpp
r62489 r67018 35 35 } SHFLINTHANDLE, *PSHFLINTHANDLE; 36 36 37 static SHFLINTHANDLE * pHandles = NULL;38 static int32_t lastHandleIndex = 0;39 static RTCRITSECT lock;37 static SHFLINTHANDLE *g_pHandles = NULL; 38 static int32_t gLastHandleIndex = 0; 39 static RTCRITSECT gLock; 40 40 41 41 int vbsfInitHandleTable() 42 42 { 43 pHandles = (SHFLINTHANDLE *)RTMemAllocZ (sizeof (SHFLINTHANDLE) * SHFLHANDLE_MAX);44 if ( pHandles == NULL)43 g_pHandles = (SHFLINTHANDLE *)RTMemAllocZ (sizeof (SHFLINTHANDLE) * SHFLHANDLE_MAX); 44 if (!g_pHandles) 45 45 { 46 46 AssertFailed(); … … 49 49 50 50 /* Never return handle 0 */ 51 pHandles[0].uFlags = SHFL_HF_TYPE_DONTUSE;52 lastHandleIndex= 1;53 54 return RTCritSectInit(& lock);51 g_pHandles[0].uFlags = SHFL_HF_TYPE_DONTUSE; 52 gLastHandleIndex = 1; 53 54 return RTCritSectInit(&gLock); 55 55 } 56 56 57 57 int vbsfFreeHandleTable() 58 58 { 59 if ( pHandles)60 RTMemFree( pHandles);61 62 pHandles = NULL;63 64 if (RTCritSectIsInitialized(& lock))65 RTCritSectDelete(& lock);59 if (g_pHandles) 60 RTMemFree(g_pHandles); 61 62 g_pHandles = NULL; 63 64 if (RTCritSectIsInitialized(&gLock)) 65 RTCritSectDelete(&gLock); 66 66 67 67 return VINF_SUCCESS; … … 75 75 Assert((uType & SHFL_HF_TYPE_MASK) != 0 && pvUserData); 76 76 77 RTCritSectEnter(& lock);77 RTCritSectEnter(&gLock); 78 78 79 79 /* Find next free handle */ 80 if(lastHandleIndex >= SHFLHANDLE_MAX-1) 81 { 82 lastHandleIndex = 1; 83 } 80 if (gLastHandleIndex >= SHFLHANDLE_MAX-1) 81 gLastHandleIndex = 1; 84 82 85 83 /* Nice linear search */ 86 for(handle= lastHandleIndex;handle<SHFLHANDLE_MAX;handle++)87 { 88 if (pHandles[handle].pvUserData == 0)84 for(handle=gLastHandleIndex;handle<SHFLHANDLE_MAX;handle++) 85 { 86 if (g_pHandles[handle].pvUserData == 0) 89 87 { 90 lastHandleIndex = handle;88 gLastHandleIndex = handle; 91 89 break; 92 90 } 93 91 } 94 92 95 if (handle == SHFLHANDLE_MAX)93 if (handle == SHFLHANDLE_MAX) 96 94 { 97 95 /* Try once more from the start */ 98 96 for(handle=1;handle<SHFLHANDLE_MAX;handle++) 99 97 { 100 if (pHandles[handle].pvUserData == 0)98 if (g_pHandles[handle].pvUserData == 0) 101 99 { 102 lastHandleIndex = handle;100 gLastHandleIndex = handle; 103 101 break; 104 102 } 105 103 } 106 if(handle == SHFLHANDLE_MAX) 107 { /* Out of handles */ 108 RTCritSectLeave(&lock); 104 if (handle == SHFLHANDLE_MAX) 105 { 106 /* Out of handles */ 107 RTCritSectLeave(&gLock); 109 108 AssertFailed(); 110 109 return SHFL_HANDLE_NIL; 111 110 } 112 111 } 113 pHandles[handle].uFlags = (uType & SHFL_HF_TYPE_MASK) | SHFL_HF_VALID;114 pHandles[handle].pvUserData = pvUserData;115 pHandles[handle].pClient = pClient;116 117 lastHandleIndex++;118 119 RTCritSectLeave(& lock);112 g_pHandles[handle].uFlags = (uType & SHFL_HF_TYPE_MASK) | SHFL_HF_VALID; 113 g_pHandles[handle].pvUserData = pvUserData; 114 g_pHandles[handle].pClient = pClient; 115 116 gLastHandleIndex++; 117 118 RTCritSectLeave(&gLock); 120 119 121 120 return handle; … … 125 124 { 126 125 if ( handle < SHFLHANDLE_MAX 127 && ( pHandles[handle].uFlags & SHFL_HF_VALID)128 && pHandles[handle].pClient == pClient)129 { 130 pHandles[handle].uFlags = 0;131 pHandles[handle].pvUserData = 0;132 pHandles[handle].pClient = 0;126 && (g_pHandles[handle].uFlags & SHFL_HF_VALID) 127 && g_pHandles[handle].pClient == pClient) 128 { 129 g_pHandles[handle].uFlags = 0; 130 g_pHandles[handle].pvUserData = 0; 131 g_pHandles[handle].pClient = 0; 133 132 return VINF_SUCCESS; 134 133 } … … 140 139 { 141 140 if ( handle < SHFLHANDLE_MAX 142 && ( pHandles[handle].uFlags & SHFL_HF_VALID)143 && pHandles[handle].pClient == pClient)141 && (g_pHandles[handle].uFlags & SHFL_HF_VALID) 142 && g_pHandles[handle].pClient == pClient) 144 143 { 145 144 Assert((uType & SHFL_HF_TYPE_MASK) != 0); 146 145 147 if ( pHandles[handle].uFlags & uType)148 return pHandles[handle].pvUserData;146 if (g_pHandles[handle].uFlags & uType) 147 return g_pHandles[handle].pvUserData; 149 148 } 150 149 return 0; … … 166 165 { 167 166 if ( handle < SHFLHANDLE_MAX 168 && ( pHandles[handle].uFlags & SHFL_HF_VALID)169 && pHandles[handle].pClient == pClient)170 return pHandles[handle].uFlags & SHFL_HF_TYPE_MASK;171 else 172 167 && (g_pHandles[handle].uFlags & SHFL_HF_VALID) 168 && g_pHandles[handle].pClient == pClient) 169 return g_pHandles[handle].uFlags & SHFL_HF_TYPE_MASK; 170 171 return 0; 173 172 } 174 173 … … 213 212 else 214 213 AssertFailed(); 215 216 return; 217 } 214 }
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器