Changeset 3472 for trunk/src/wsock32/asyncapi.cpp
- Timestamp:
- May 2, 2000, 3:09:44 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/asyncapi.cpp
r3439 r3472 1 /* $Id: asyncapi.cpp,v 1. 6 2000-04-23 15:55:52 sandervlExp $ */1 /* $Id: asyncapi.cpp,v 1.7 2000-05-02 13:09:43 bird Exp $ */ 2 2 3 3 /* … … 31 31 #include "dbglocal.h" 32 32 33 //kso: dirty fix to make this compile! not permanent! 34 BOOL WINAPI QueryPerformanceCounter(LARGE_INTEGER *p); 35 #define LowPart u.LowPart 36 37 33 38 ODINDEBUGCHANNEL(WSOCK32-ASYNC) 34 39 … … 42 47 int size = 0; 43 48 int fail = NO_ERROR; 44 49 45 50 if(!pThreadParm->fCancelled) 46 51 { … … 59 64 } 60 65 else { 61 ret = gethostbyaddr(pThreadParm->u.gethostbyaddr.addr, 66 ret = gethostbyaddr(pThreadParm->u.gethostbyaddr.addr, 62 67 pThreadParm->u.gethostbyaddr.len, 63 68 pThreadParm->u.gethostbyaddr.type); … … 152 157 if(!pThreadParm->fCancelled) { 153 158 dprintf(("WSAsyncThreadProc %x %x %x %x", pThreadParm->hwnd, pThreadParm->msg, pThreadParm->hAsyncTaskHandle, lParam)); 154 PostMessageA(pThreadParm->hwnd, pThreadParm->msg, 159 PostMessageA(pThreadParm->hwnd, pThreadParm->msg, 155 160 (WPARAM)pThreadParm->hAsyncTaskHandle, lParam); 156 161 } 157 162 pThreadParm->fActive = FALSE; 158 RemoveFromQueue(pThreadParm); 159 } 160 //****************************************************************************** 161 //****************************************************************************** 162 LHANDLE WSAAsyncRequest(AsyncRequestType requesttype, HWND hwnd, int msg, char *buf, 163 RemoveFromQueue(pThreadParm); 164 } 165 //****************************************************************************** 166 //****************************************************************************** 167 LHANDLE WSAAsyncRequest(AsyncRequestType requesttype, HWND hwnd, int msg, char *buf, 163 168 int buflen, PVOID param1, PVOID param2, PVOID param3, 164 169 PVOID param4) … … 303 308 } 304 309 return 0; 305 } 310 } 306 311 //****************************************************************************** 307 312 //****************************************************************************** … … 315 320 dprintf(("WSAAsyncGetHostByName %s", name)); 316 321 317 return WSAAsyncRequest(ASYNC_GETHOSTBYNAME, hWnd, wMsg, buf, buflen, 322 return WSAAsyncRequest(ASYNC_GETHOSTBYNAME, hWnd, wMsg, buf, buflen, 318 323 (PVOID)name, 0, 0, 0); 319 324 } … … 331 336 dprintf(("WSAAsyncGetHostByAddr %s", addr)); 332 337 333 return WSAAsyncRequest(ASYNC_GETHOSTBYADDR, hWnd, wMsg, buf, buflen, 338 return WSAAsyncRequest(ASYNC_GETHOSTBYADDR, hWnd, wMsg, buf, buflen, 334 339 (PVOID)addr, (PVOID)len, (PVOID)type, 0); 335 340 } … … 345 350 dprintf(("WSAAsyncGetProtoByName %s", name)); 346 351 347 return WSAAsyncRequest(ASYNC_GETPROTOBYNAME, hWnd, wMsg, buf, buflen, 352 return WSAAsyncRequest(ASYNC_GETPROTOBYNAME, hWnd, wMsg, buf, buflen, 348 353 (PVOID)name, 0, 0, 0); 349 354 } … … 359 364 dprintf(("WSAAsyncGetProtoByNumber %d", number)); 360 365 361 return WSAAsyncRequest(ASYNC_GETPROTOBYNUMBER, hWnd, wMsg, buf, buflen, 366 return WSAAsyncRequest(ASYNC_GETPROTOBYNUMBER, hWnd, wMsg, buf, buflen, 362 367 (PVOID)number, 0, 0, 0); 363 368 } … … 374 379 dprintf(("WSAAsyncGetServByName %s", name)); 375 380 376 return WSAAsyncRequest(ASYNC_GETSERVBYNAME, hWnd, wMsg, buf, buflen, 381 return WSAAsyncRequest(ASYNC_GETSERVBYNAME, hWnd, wMsg, buf, buflen, 377 382 (PVOID)name, (PVOID)proto, 0, 0); 378 383 } … … 389 394 dprintf(("WSAAsyncGetServByPort %d %s", port, proto)); 390 395 391 return WSAAsyncRequest(ASYNC_GETSERVBYPORT, hWnd, wMsg, buf, buflen, 396 return WSAAsyncRequest(ASYNC_GETSERVBYPORT, hWnd, wMsg, buf, buflen, 392 397 (PVOID)port, (PVOID)proto, 0, 0); 393 398 } … … 401 406 402 407 dprintf(("AsyncNotifyEvent %x %x %x %x", pThreadParm->u.asyncselect.s, pThreadParm->hwnd, pThreadParm->msg, event)); 403 PostMessageA(pThreadParm->hwnd, pThreadParm->msg, (WPARAM)pThreadParm->u.asyncselect.s, 408 PostMessageA(pThreadParm->hwnd, pThreadParm->msg, (WPARAM)pThreadParm->u.asyncselect.s, 404 409 (LPARAM)event); 405 410 } … … 416 421 int noread, nowrite, noexcept, state, sockoptlen, sockoptval; 417 422 int tmp, i, lEventsPending, ret, bytesread; 418 423 419 424 while(TRUE) 420 425 { … … 464 469 selecterr += SOCBASEERR; 465 470 } 466 switch(selecterr) 471 switch(selecterr) 467 472 { 468 473 case SOCEINTR: … … 481 486 //but can still send 482 487 pThreadParm->u.asyncselect.lEventsPending &= ~(FD_READ | FD_ACCEPT); 483 goto asyncloopstart; 488 goto asyncloopstart; 484 489 485 490 case SOCEINVAL: … … 513 518 AsyncNotifyEvent(pThreadParm, FD_CONNECT, WSAECONNREFUSED); 514 519 } 515 } 520 } 516 521 } 517 522 else … … 524 529 { 525 530 state = ioctl(s, FIONREAD, (CHAR *) &bytesread, sizeof(bytesread)); 526 if(state == SOCKET_ERROR) 531 if(state == SOCKET_ERROR) 527 532 { 528 if(lEventsPending & FD_CLOSE) 533 if(lEventsPending & FD_CLOSE) 529 534 { 530 535 dprintf(("FD_CLOSE; ioctl; socket error")); … … 540 545 } 541 546 } 542 if(lEventsPending & FD_ACCEPT) 547 if(lEventsPending & FD_ACCEPT) 543 548 { 544 549 sockoptlen = sizeof(sockoptlen); … … 560 565 //SvL: This generates FD_CLOSE messages when the connection is just fine 561 566 // (recv executed in another thread when select returns) 562 else 567 else 563 568 if((lEventsPending & FD_CLOSE) && (state == 0 && bytesread == 0)) { 564 569 dprintf(("FD_CLOSE; state == 0 && bytesread == 0")); … … 573 578 } 574 579 } 575 if((pThreadParm->u.asyncselect.lEventsPending & (FD_ACCEPT|FD_CLOSE|FD_CONNECT)) == 580 if((pThreadParm->u.asyncselect.lEventsPending & (FD_ACCEPT|FD_CLOSE|FD_CONNECT)) == 576 581 (lEventsPending & (FD_ACCEPT|FD_CLOSE|FD_CONNECT))) { 577 582 DosSleep(10); … … 580 585 //remove it first, then delete semaphore object 581 586 pThreadParm->fActive = FALSE; 582 RemoveFromQueue(pThreadParm); 587 RemoveFromQueue(pThreadParm); 583 588 delete pThreadParm->u.asyncselect.asyncSem; 584 589 pThreadParm->u.asyncselect.asyncSem = 0;
Note:
See TracChangeset
for help on using the changeset viewer.