Leaked source code of windows server 2003
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.

136 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name :
  4. generalhandler.cxx
  5. Abstract:
  6. A general purpose error sending handler. This cleans up some of the
  7. logic needed to allow DetermineHandler() to send HTTP errors.
  8. Author:
  9. Bilal Alam (balam) 7-Jan-2000
  10. Environment:
  11. Win32 - User Mode
  12. Project:
  13. ULW3.DLL
  14. --*/
  15. #include "precomp.hxx"
  16. #include "generalhandler.hxx"
  17. ALLOC_CACHE_HANDLER * W3_GENERAL_HANDLER::sm_pachGeneralHandlers;
  18. CONTEXT_STATUS
  19. W3_GENERAL_HANDLER::DoWork(
  20. VOID
  21. )
  22. /*++
  23. Routine Description:
  24. Send the configured error response to the client
  25. Return Value:
  26. HRESULT
  27. --*/
  28. {
  29. HRESULT hr;
  30. W3_CONTEXT *pW3Context = QueryW3Context();
  31. DBG_ASSERT( pW3Context != NULL );
  32. //
  33. // Setup the error response and send it
  34. //
  35. pW3Context->QueryResponse()->SetStatus( _httpStatus, _httpSubError );
  36. hr = pW3Context->SendResponse( W3_FLAG_ASYNC );
  37. if ( FAILED( hr ) )
  38. {
  39. pW3Context->SetErrorStatus( hr );
  40. pW3Context->QueryResponse()->SetStatus( HttpStatusServerError );
  41. return CONTEXT_STATUS_CONTINUE;
  42. }
  43. return CONTEXT_STATUS_PENDING;
  44. }
  45. // static
  46. HRESULT
  47. W3_GENERAL_HANDLER::Initialize(
  48. VOID
  49. )
  50. /*++
  51. Routine Description:
  52. Global initialization routine for W3_GENERAL_HANDLERs
  53. Arguments:
  54. None
  55. Return Value:
  56. HRESULT
  57. --*/
  58. {
  59. ALLOC_CACHE_CONFIGURATION acConfig;
  60. HRESULT hr = NO_ERROR;
  61. //
  62. // Setup allocation lookaside
  63. //
  64. acConfig.nConcurrency = 1;
  65. acConfig.nThreshold = 100;
  66. acConfig.cbSize = sizeof( W3_GENERAL_HANDLER );
  67. DBG_ASSERT( sm_pachGeneralHandlers == NULL );
  68. sm_pachGeneralHandlers = new ALLOC_CACHE_HANDLER( "W3_GENERAL_HANDLER",
  69. &acConfig );
  70. if ( sm_pachGeneralHandlers == NULL )
  71. {
  72. return HRESULT_FROM_WIN32( ERROR_NOT_ENOUGH_MEMORY );
  73. }
  74. return NO_ERROR;
  75. }
  76. // static
  77. VOID
  78. W3_GENERAL_HANDLER::Terminate(
  79. VOID
  80. )
  81. /*++
  82. Routine Description:
  83. Terminate MAIN_CONTEXT globals
  84. Arguments:
  85. None
  86. Return Value:
  87. None
  88. --*/
  89. {
  90. if ( sm_pachGeneralHandlers != NULL )
  91. {
  92. delete sm_pachGeneralHandlers;
  93. sm_pachGeneralHandlers = NULL;
  94. }
  95. }