- Timestamp:
- Oct 19, 2001, 8:34:47 PM (24 years ago)
- Location:
- trunk/src/wsock32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/asyncapi.cpp
r7041 r7140 1 /* $Id: asyncapi.cpp,v 1.1 6 2001-10-13 18:51:07 sandervlExp $ */1 /* $Id: asyncapi.cpp,v 1.17 2001-10-19 18:34:47 achimha Exp $ */ 2 2 3 3 /* … … 403 403 pThreadParm->u.asyncselect.lEventsPending &= ~event; 404 404 405 event = WSAMAKESELECTREPLY(event, socket_error); 405 // @@@AH 20011019 this changes the event code. Don' think we can do this 406 // for the semaphore notification... 407 ULONG eventReply = WSAMAKESELECTREPLY(event, socket_error); 406 408 407 409 if (pThreadParm->u.asyncselect.mode == WSA_SELECT_HWND) 408 410 { 409 dprintf(("AsyncSelectNotifyEvent: notifying window, socket: 0x%x, window handle: 0x%x, window message: 0x%x, event: 0x%x", pThreadParm->u.asyncselect.s, pThreadParm->notifyHandle, pThreadParm->notifyData, event ));411 dprintf(("AsyncSelectNotifyEvent: notifying window, socket: 0x%x, window handle: 0x%x, window message: 0x%x, event: 0x%x", pThreadParm->u.asyncselect.s, pThreadParm->notifyHandle, pThreadParm->notifyData, eventReply)); 410 412 PostMessageA((HWND)pThreadParm->notifyHandle, (DWORD)pThreadParm->notifyData, (WPARAM)pThreadParm->u.asyncselect.s, 411 (LPARAM)event );413 (LPARAM)eventReply); 412 414 } 413 415 else … … 415 417 { 416 418 dprintf(("AsyncSelectNotifyEvent: notifying event semaphore, socket: 0x%x, HEVENT: 0x%x, event: 0x%x", pThreadParm->u.asyncselect.s, pThreadParm->notifyHandle, event)); 419 // set the event bit in the mask 417 420 pThreadParm->u.asyncselect.lLastEvent |= event; 421 // set the error code for the right value 422 // for this, we first have to find out which bit field to write to 423 char slot = 0; 424 ULONG eventValue = event; 425 while (eventValue > 0) 426 { 427 slot++; 428 eventValue = eventValue >> 1; 429 } 430 pThreadParm->u.asyncselect.iErrorCode[slot] = socket_error; 431 // now post the semaphore so that the client can check the event 418 432 SetEvent(pThreadParm->notifyHandle); 419 433 } … … 495 509 case SOCECONNRESET: 496 510 case SOCEPIPE: 497 if(lEventsPending & FD_CLOSE) { 511 if(lEventsPending & FD_CLOSE) 512 { 498 513 dprintf(("FD_CLOSE; broken connection")); 499 514 AsyncSelectNotifyEvent(pThreadParm, FD_CLOSE, WSAECONNRESET); 500 515 } 501 516 … … 701 716 pThreadParm->u.asyncselect.lEvents = lEventMask; 702 717 pThreadParm->u.asyncselect.lEventsPending = lEventMask; 718 pThreadParm->u.asyncselect.s = s; 719 // reset all event bits 703 720 pThreadParm->u.asyncselect.lLastEvent = 0; 704 pThreadParm->u.asyncselect.s = s; 721 // reset all error bits 722 memset(&pThreadParm->u.asyncselect.iErrorCode, 0, sizeof(int) * FD_MAX_EVENTS); 705 723 pThreadParm->u.asyncselect.asyncSem = new VSemaphore; 706 724 if(pThreadParm->u.asyncselect.asyncSem == NULL) { … … 731 749 if (pThreadInfo) 732 750 { 733 // TODO return correct errors!!! 734 for (int i = 0; i < FD_MAX_EVENTS; i++) 735 { 736 lpEvent->iErrorCode[i] = 0; 737 } 751 // return our internal error bit representation 752 memcpy(&lpEvent->iErrorCode, &pThreadInfo->u.asyncselect.iErrorCode, sizeof(int) * FD_MAX_EVENTS); 753 // return our internal event bit representation 738 754 lpEvent->lNetworkEvents = InterlockedExchange((LPLONG)&pThreadInfo->u.asyncselect.lLastEvent, 0); 739 755 } -
trunk/src/wsock32/asyncthread.h
r7139 r7140 1 /* $Id: asyncthread.h,v 1. 9 2001-10-19 18:05:25achimha Exp $ */1 /* $Id: asyncthread.h,v 1.10 2001-10-19 18:34:47 achimha Exp $ */ 2 2 3 3 /* … … 71 71 DWORD lEvents; 72 72 DWORD lEventsPending; 73 DWORD lLastEvent;74 73 SOCKET s; 75 74 int mode; 76 // error codes for all events 77 int iErrorCode[FD_MAX_EVENTS]; 75 // event bits to signal which event has occured 76 DWORD lLastEvent; 77 // error codes for all events 78 int iErrorCode[FD_MAX_EVENTS]; 78 79 } asyncselect; 79 80 } u;
Note:
See TracChangeset
for help on using the changeset viewer.