Changeset 19562 in vbox for trunk/src/VBox/Runtime/r3/win
- Timestamp:
- May 10, 2009 9:44:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/fileaio-win.cpp
r19186 r19562 90 90 /** Overlapped structure. */ 91 91 OVERLAPPED Overlapped; 92 /** Current state the request is in. */ 93 RTFILEAIOREQSTATE enmState; 92 94 /** The file handle. */ 93 95 HANDLE hFile; … … 122 124 #define OVERLAPPED_2_RTFILEAIOREQINTERNAL(pOverlapped) ( (PRTFILEAIOREQINTERNAL)((uintptr_t)(pOverlapped) - RT_OFFSETOF(RTFILEAIOREQINTERNAL, Overlapped)) ) 123 125 126 RTR3DECL(int) RTFileAioGetLimits(PRTFILEAIOLIMITS pAioLimits) 127 { 128 int rcBSD = 0; 129 AssertPtrReturn(pAioLimits, VERR_INVALID_POINTER); 130 131 /* No limits known. */ 132 pAioLimits->cReqsOutstandingMax = RTFILEAIO_UNLIMITED_REQS; 133 pAioLimits->cbBufferAlignment = 0; 134 135 return VINF_SUCCESS; 136 } 137 124 138 RTR3DECL(int) RTFileAioReqCreate(PRTFILEAIOREQ phReq) 125 139 { … … 133 147 pReqInt->fCompleted = false; 134 148 pReqInt->u32Magic = RTFILEAIOREQ_MAGIC; 149 RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED); 135 150 136 151 *phReq = (RTFILEAIOREQ)pReqInt; … … 139 154 } 140 155 141 RTDECL( void) RTFileAioReqDestroy(RTFILEAIOREQ hReq)156 RTDECL(int) RTFileAioReqDestroy(RTFILEAIOREQ hReq) 142 157 { 143 158 /* … … 145 160 */ 146 161 if (hReq == NIL_RTFILEAIOREQ) 147 return ;162 return VINF_SUCCESS; 148 163 PRTFILEAIOREQINTERNAL pReqInt = hReq; 149 RTFILEAIOREQ_VALID_RETURN_VOID(pReqInt); 164 RTFILEAIOREQ_VALID_RETURN(pReqInt); 165 RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS); 150 166 151 167 /* … … 154 170 ASMAtomicUoWriteU32(&pReqInt->u32Magic, ~RTFILEAIOREQ_MAGIC); 155 171 RTMemFree(pReqInt); 172 return VINF_SUCCESS; 156 173 } 157 174 … … 169 186 PRTFILEAIOREQINTERNAL pReqInt = hReq; 170 187 RTFILEAIOREQ_VALID_RETURN(pReqInt); 188 RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS); 171 189 Assert(hFile != NIL_RTFILE); 172 190 AssertPtr(pvBuf); … … 204 222 PRTFILEAIOREQINTERNAL pReqInt = hReq; 205 223 RTFILEAIOREQ_VALID_RETURN(pReqInt); 224 RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS); 206 225 AssertReturn(hFile != NIL_RTFILE, VERR_INVALID_HANDLE); 207 226 … … 226 245 PRTFILEAIOREQINTERNAL pReqInt = hReq; 227 246 RTFILEAIOREQ_VALID_RETURN(pReqInt); 247 RTFILEAIOREQ_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_NOT_SUBMITTED); 228 248 229 249 /** … … 234 254 * is only available from Vista and up. 235 255 * The solution is to return VERR_FILE_AIO_IN_PROGRESS 236 * if the request didn't completed yet .256 * if the request didn't completed yet (checked above). 237 257 * Shouldn't be a big issue because a request is normally 238 258 * only canceled if it exceeds a timeout which is quite huge. 239 259 */ 240 if (pReqInt->fCompleted) 241 return VERR_FILE_AIO_COMPLETED; 242 else 243 return VERR_FILE_AIO_IN_PROGRESS; 260 return VERR_FILE_AIO_COMPLETED; 244 261 } 245 262 … … 249 266 PRTFILEAIOREQINTERNAL pReqInt = hReq; 250 267 RTFILEAIOREQ_VALID_RETURN(pReqInt); 251 252 if (pReqInt->fCompleted) 253 { 254 rc = pReqInt->Rc; 255 if (*pcbTransfered) 256 *pcbTransfered = pReqInt->cbTransfered; 257 } 258 else 259 rc = VERR_FILE_AIO_IN_PROGRESS; 268 RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS); 269 RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, PREPARED, VERR_FILE_AIO_NOT_SUBMITTED); 270 271 rc = pReqInt->Rc; 272 if (pcbTransfered && RT_SUCCESS(rc)) 273 *pcbTransfered = pReqInt->cbTransfered; 260 274 261 275 return rc; … … 325 339 } 326 340 327 RTDECL(int) RTFileAioCtxSubmit(RTFILEAIOCTX hAioCtx, PRTFILEAIOREQ pahReqs, size_t cReqs , size_t *pcReqs)341 RTDECL(int) RTFileAioCtxSubmit(RTFILEAIOCTX hAioCtx, PRTFILEAIOREQ pahReqs, size_t cReqs) 328 342 { 329 343 /* 330 344 * Parameter validation. 331 345 */ 332 AssertPtrReturn(pcReqs, VERR_INVALID_POINTER);333 *pcReqs = 0;334 346 int rc = VINF_SUCCESS; 335 347 PRTFILEAIOCTXINTERNAL pCtxInt = hAioCtx; … … 361 373 if (RT_UNLIKELY(!fSucceeded && GetLastError() != ERROR_IO_PENDING)) 362 374 { 375 RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED); 363 376 rc = RTErrConvertFromWin32(GetLastError()); 377 pReqInt->Rc = rc; 364 378 break; 365 379 } 380 RTFILEAIOREQ_SET_STATE(pReqInt, SUBMITTED); 366 381 } 367 382 368 *pcReqs = i;369 383 ASMAtomicAddS32(&pCtxInt->cRequests, i); 370 384 … … 440 454 441 455 /* Mark the request as finished. */ 442 pReqInt->fCompleted = true;456 RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED); 443 457 444 458 /* completion status. */
Note:
See TracChangeset
for help on using the changeset viewer.