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.

158 lines
2.9 KiB

  1. /*++
  2. Copyright (c) 1998-2002 Microsoft Corporation
  3. Module Name:
  4. HHandle.c
  5. Abstract:
  6. User-mode interface to HTTP.SYS: Public Listener API
  7. Author:
  8. Eric Stenson (ericsten) 16-July-2001
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. //
  13. // Private macros.
  14. //
  15. //
  16. // Private prototypes.
  17. //
  18. //
  19. // Public functions.
  20. //
  21. /***************************************************************************++
  22. Routine Description:
  23. Creates a new Request Queue (actually an Application Pool).
  24. Arguments:
  25. pAppPoolHandle - Receives a handle to the new application pool.
  26. Options - Supplies creation options.
  27. Return Value:
  28. ULONG - Completion status.
  29. --***************************************************************************/
  30. HTTPAPI_LINKAGE
  31. ULONG
  32. WINAPI
  33. HttpCreateHttpHandle(
  34. OUT PHANDLE pReqQueueHandle,
  35. IN ULONG Options
  36. )
  37. {
  38. ULONG result;
  39. HANDLE appPool = NULL;
  40. HTTP_APP_POOL_ENABLED_STATE AppPoolState;
  41. //
  42. // Sanity check
  43. //
  44. if (NULL == pReqQueueHandle )
  45. {
  46. return ERROR_INVALID_PARAMETER;
  47. }
  48. //
  49. // Init OUT parameter
  50. //
  51. *pReqQueueHandle = NULL;
  52. //
  53. // Verify we've been init'd.
  54. //
  55. if ( !HttpIsInitialized(HTTP_INITIALIZE_SERVER) )
  56. {
  57. return ERROR_DLL_INIT_FAILED;
  58. }
  59. //
  60. // Create an application pool.
  61. // REVIEW: Do we need to set up default Security Attributes on the App Pool?
  62. //
  63. result = HttpCreateAppPool(
  64. &appPool,
  65. NULL, // Generic App Pool Name
  66. NULL , // PSECURITY_ATTRIBUTES
  67. Options
  68. );
  69. if (result != NO_ERROR)
  70. {
  71. HttpTrace1( "HttpCreateAppPool() failed, error %lu\n", result );
  72. goto cleanup;
  73. }
  74. //
  75. // Turn on AppPool
  76. // CODEWORK: Leave AppPool off, create another API for switching App Pool on & off.
  77. //
  78. AppPoolState = HttpAppPoolEnabled;
  79. result = HttpSetAppPoolInformation(
  80. appPool,
  81. HttpAppPoolStateInformation,
  82. &AppPoolState,
  83. sizeof(AppPoolState)
  84. );
  85. if (result != NO_ERROR)
  86. {
  87. HttpTrace1( "HttpSetAppPoolInformation: could not enable app pool %p\n", appPool );
  88. goto cleanup;
  89. }
  90. // CODEWORK: (DBG ONLY) Add to global Active App Pool list.
  91. //
  92. // Return App Pool to user in pReqQueueHandle.
  93. //
  94. *pReqQueueHandle = appPool;
  95. cleanup:
  96. if (NO_ERROR != result)
  97. {
  98. // Failed. cleanup.
  99. if ( appPool )
  100. {
  101. CloseHandle( appPool );
  102. }
  103. }
  104. return result;
  105. } // HttpCreateHttpHandle
  106. //
  107. // Private functions.
  108. //