Changeset 7564 for trunk/src/kernel32/overlappedio.cpp
- Timestamp:
- Dec 7, 2001, 12:28:11 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/overlappedio.cpp
r7560 r7564 1 /* $Id: overlappedio.cpp,v 1. 5 2001-12-06 15:57:52sandervl Exp $ */1 /* $Id: overlappedio.cpp,v 1.6 2001-12-07 11:28:11 sandervl Exp $ */ 2 2 3 3 /* … … 25 25 //****************************************************************************** 26 26 //****************************************************************************** 27 OverlappedIOHandler::OverlappedIOHandler(LPOVERLAPPED_HANDLER lpReadHandler, 28 LPOVERLAPPED_HANDLER lpWriteHandler, 27 OverlappedIOHandler::OverlappedIOHandler(LPOVERLAPPED_HANDLER lpReadHandler, 28 LPOVERLAPPED_HANDLER lpWriteHandler, 29 29 LPOVERLAPPED_HANDLER lpPollHandler) : 30 30 hThreadRead(0), hThreadWrite(0), hThreadPoll(0) … … 49 49 hEventWrite = ::CreateEventA(NULL, FALSE, FALSE, NULL); 50 50 51 //the exit event semaphore is manual reset, because signallingthis event51 //the exit event semaphore is manual reset, because this event 52 52 //must be able to wake up multiple threads 53 53 hEventExit = ::CreateEventA(NULL, TRUE, FALSE, NULL); … … 58 58 goto failed; 59 59 } 60 60 61 61 DWORD dwThreadId; 62 62 LPOVERLAPPED_THREAD_PARAM threadparam; … … 89 89 } 90 90 91 if((lpPollHandler && !hThreadPoll) || !hThreadRead || (lpWriteHandler && !hThreadWrite)) 91 if((lpPollHandler && !hThreadPoll) || !hThreadRead || (lpWriteHandler && !hThreadWrite)) 92 92 { 93 93 DebugInt3(); … … 97 97 return; 98 98 99 outofmem: 99 outofmem: 100 100 errcode = OutOfMemory; 101 101 //fall through 102 102 failed: 103 //SvL: NOTE: We might not fail gracefully when threads have already been 103 //SvL: NOTE: We might not fail gracefully when threads have already been 104 104 // created. (thread accessing memory that has been freed) 105 105 // Don't feel like wasting time to fix this as this should never … … 223 223 case ASYNCIO_READ: 224 224 case ASYNCIO_READWRITE: 225 225 lpReadHandler(lpRequest, &dwResult, NULL); 226 226 lpOverlapped->Internal = lpRequest->dwLastError; 227 227 lpOverlapped->InternalHigh = dwResult; … … 235 235 236 236 case ASYNCIO_WRITE: 237 237 lpWriteHandler(lpRequest, &dwResult, NULL); 238 238 lpOverlapped->Internal = lpRequest->dwLastError; 239 239 lpOverlapped->InternalHigh = dwResult; … … 247 247 248 248 case ASYNCIO_POLL: 249 while(TRUE) 249 while(TRUE) 250 250 { 251 251 dwTimeOut = 0; … … 281 281 LPOVERLAPPED lpOverlapped, 282 282 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, 283 DWORD dwUserData) 283 DWORD dwUserData, 284 DWORD dwTimeOut) 284 285 { 285 286 LPASYNCIOREQUEST lpRequest, current; … … 290 291 return FALSE; 291 292 } 292 293 293 294 lpRequest = new ASYNCIOREQUEST; 294 295 if(lpRequest == NULL) { … … 304 305 lpRequest->lpCompletionRoutine = lpCompletionRoutine; 305 306 lpRequest->dwUserData = dwUserData; 307 lpRequest->dwTimeOut = dwTimeOut; 306 308 lpRequest->next = NULL; 307 309 … … 322 324 ::LeaveCriticalSection(&critsect); 323 325 324 lpOverlapped->Internal = STATUS_PENDING;326 lpOverlapped->Internal = ERROR_IO_PENDING; 325 327 lpOverlapped->InternalHigh = 0; 326 328 lpOverlapped->Offset = 0; … … 343 345 LPOVERLAPPED lpOverlapped, 344 346 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, 345 DWORD dwUserData) 347 DWORD dwUserData, 348 DWORD dwTimeOut) 346 349 { 347 350 LPASYNCIOREQUEST lpRequest, current; … … 351 354 return FALSE; 352 355 } 353 356 354 357 lpRequest = new ASYNCIOREQUEST; 355 358 if(lpRequest == NULL) { … … 365 368 lpRequest->lpCompletionRoutine = lpCompletionRoutine; 366 369 lpRequest->dwUserData = dwUserData; 370 lpRequest->dwTimeOut = dwTimeOut; 367 371 lpRequest->next = NULL; 368 372 … … 378 382 ::LeaveCriticalSection(&critsect); 379 383 380 lpOverlapped->Internal = STATUS_PENDING;384 lpOverlapped->Internal = ERROR_IO_PENDING; 381 385 lpOverlapped->InternalHigh = 0; 382 386 lpOverlapped->Offset = 0; … … 396 400 LPOVERLAPPED lpOverlapped, 397 401 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine, 398 DWORD dwUserData) 402 DWORD dwUserData, 403 DWORD dwTimeOut) 399 404 { 400 405 LPASYNCIOREQUEST lpRequest, current; … … 404 409 return FALSE; 405 410 } 406 411 407 412 lpRequest = new ASYNCIOREQUEST; 408 413 if(lpRequest == NULL) { … … 418 423 lpRequest->lpCompletionRoutine = lpCompletionRoutine; 419 424 lpRequest->dwUserData = dwUserData; 425 lpRequest->dwTimeOut = dwTimeOut; 420 426 lpRequest->next = NULL; 421 427 … … 431 437 ::LeaveCriticalSection(&critsect); 432 438 433 lpOverlapped->Internal = STATUS_PENDING;439 lpOverlapped->Internal = ERROR_IO_PENDING; 434 440 lpOverlapped->InternalHigh = 0; 435 441 lpOverlapped->Offset = 0; … … 449 455 LPASYNCIOREQUEST lpRequest; 450 456 451 for(int i=ASYNC_INDEX_READ;i<NR_ASYNC_OPERATIONS;i++) 457 for(int i=ASYNC_INDEX_READ;i<NR_ASYNC_OPERATIONS;i++) 452 458 { 453 459 while(TRUE) { … … 468 474 LPOVERLAPPED lpOverlapped, 469 475 LPDWORD lpcbTransfer, 470 DWORD dwTimeout)476 BOOL fWait) 471 477 { 472 478 DWORD ret; 473 479 474 ret = ::WaitForSingleObject(lpOverlapped->hEvent, dwTimeout);480 ret = ::WaitForSingleObject(lpOverlapped->hEvent, (fWait) ? INFINITE : 0); 475 481 476 482 if(lpcbTransfer) … … 488 494 489 495 ::EnterCriticalSection(&critsect); 490 if(pending[index]) 496 if(pending[index]) 491 497 { 492 if(pending[index]->hHandle != hHandle) 498 if(pending[index]->hHandle != hHandle) 493 499 { 494 500 lpRequest = pending[index];
Note:
See TracChangeset
for help on using the changeset viewer.