Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
2.3 KiB

  1. /*++
  2. Copyright (c) 1998 - 2000 Microsoft Corporation
  3. Module Name:
  4. emio.cpp
  5. Abstract:
  6. Contains:
  7. High-level Event Manager routines for asynchronous I/O
  8. Environment:
  9. User Mode - Win32
  10. History:
  11. 1. 14-Feb-2000 -- File creation (based on Ilya Kleyman (ilyak)
  12. previous work by AjayCh)
  13. --*/
  14. #include "stdafx.h"
  15. /*++
  16. Routine Description:
  17. Called when asynchronous send, receive or accept completes
  18. Arguments:
  19. Status - status of the operation being completed
  20. BytesTransferred - number of bytes transferred
  21. Overlapped - internal data structure
  22. Return Values:
  23. None
  24. Notes:
  25. Callback
  26. --*/
  27. static void WINAPI EventMgrIoCompletionCallback (
  28. IN DWORD Status,
  29. IN DWORD BytesTransferred,
  30. IN LPOVERLAPPED Overlapped)
  31. {
  32. PIOContext IoContext;
  33. IoContext = (PIOContext) Overlapped;
  34. CALL_BRIDGE& CallBridge = IoContext->pOvProcessor->GetCallBridge();
  35. switch (IoContext -> reqType) {
  36. case EMGR_OV_IO_REQ_ACCEPT:
  37. HandleAcceptCompletion ((PAcceptContext) IoContext, Status);
  38. break;
  39. case EMGR_OV_IO_REQ_SEND:
  40. HandleSendCompletion ((PSendRecvContext) IoContext, BytesTransferred, Status);
  41. break;
  42. case EMGR_OV_IO_REQ_RECV:
  43. HandleRecvCompletion ((PSendRecvContext) IoContext, BytesTransferred, Status);
  44. break;
  45. default:
  46. // This should never happen
  47. DebugF(_T("H323: Unknown I/O completed: %d.\n"), IoContext -> reqType);
  48. _ASSERTE(0);
  49. break;
  50. }
  51. CallBridge.Release ();
  52. }
  53. /*++
  54. Routine Description:
  55. Designates a routine to be called when asynchrounous send, receive or accept completes
  56. Arguments:
  57. sock - socket handle to which a routine is being bound
  58. Return Values:
  59. Win32 error code
  60. Notes:
  61. Callback
  62. --*/
  63. HRESULT EventMgrBindIoHandle (SOCKET sock)
  64. {
  65. DWORD Result;
  66. if (BindIoCompletionCallback ((HANDLE) sock, EventMgrIoCompletionCallback, 0))
  67. return S_OK;
  68. else {
  69. Result = GetLastError ();
  70. DebugF (_T("H323: Failed to bind i/o completion callback.\n"));
  71. return HRESULT_FROM_WIN32 (Result);
  72. }
  73. }