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.

139 lines
3.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // File: postsrv.cpp
  6. //
  7. // Contents: Post service initialize routine
  8. //
  9. // History:
  10. //
  11. //---------------------------------------------------------------------------
  12. #include "pch.cpp"
  13. #include "postsrv.h"
  14. #include "tlsjob.h"
  15. #include "globals.h"
  16. #include "init.h"
  17. extern BOOL g_bReportToSCM;
  18. DWORD
  19. PostServiceInit()
  20. {
  21. DWORD dwStatus = ERROR_SUCCESS;
  22. FILETIME ftTime;
  23. HRESULT hrStatus = NULL;
  24. //
  25. // Initialize work manager
  26. //
  27. dwStatus = TLSWorkManagerInit();
  28. hrStatus = g_pWriter->Initialize (idWriter, // id of writer
  29. L"TermServLicensing", // name of writer
  30. true, // system service
  31. false, // bootable state
  32. L"", // files to include
  33. L""); // files to exclude
  34. if (FAILED (hrStatus))
  35. {
  36. DBGPrintf(
  37. DBG_INFORMATION,
  38. DBG_FACILITY_INIT,
  39. DBGLEVEL_FUNCTION_DETAILSIMPLE,
  40. _TEXT("CVssJetWriter::Initialize failed with error code %08x...\n"),
  41. hrStatus
  42. );
  43. }
  44. if(dwStatus != ERROR_SUCCESS)
  45. {
  46. TLSLogEvent(
  47. EVENTLOG_ERROR_TYPE,
  48. TLS_E_WORKMANAGERGENERAL,
  49. TLS_E_WORKMANAGER_STARTUP,
  50. dwStatus
  51. );
  52. dwStatus = TLS_E_SERVICE_STARTUP_WORKMANAGER;
  53. return dwStatus;
  54. }
  55. //
  56. // Initialize namedpipe for client to test connect
  57. //
  58. dwStatus = InitNamedPipeThread();
  59. if(dwStatus != ERROR_SUCCESS)
  60. {
  61. TLSLogErrorEvent(TLS_E_SERVICE_STARTUP_CREATE_THREAD);
  62. dwStatus = TLS_E_SERVICE_STARTUP_CREATE_THREAD;
  63. return dwStatus;
  64. }
  65. //
  66. // Initialize mailslot thread to receive broadcast
  67. //
  68. dwStatus = InitMailSlotThread();
  69. if(dwStatus != ERROR_SUCCESS)
  70. {
  71. TLSLogErrorEvent(TLS_E_SERVICE_STARTUP_CREATE_THREAD);
  72. dwStatus = TLS_E_SERVICE_STARTUP_CREATE_THREAD;
  73. return dwStatus;
  74. }
  75. //
  76. // Initialize thread to put expired permanent licenses back in pool
  77. //
  78. dwStatus = InitExpirePermanentThread();
  79. if(dwStatus != ERROR_SUCCESS)
  80. {
  81. TLSLogErrorEvent(TLS_E_SERVICE_STARTUP_CREATE_THREAD);
  82. dwStatus = TLS_E_SERVICE_STARTUP_CREATE_THREAD;
  83. return dwStatus;
  84. }
  85. DBGPrintf(
  86. DBG_INFORMATION,
  87. DBG_FACILITY_INIT,
  88. DBGLEVEL_FUNCTION_TRACE,
  89. _TEXT("Server is %s (0x%08x)\n"),
  90. (IS_ENFORCE_SERVER(TLS_CURRENT_VERSION)) ? _TEXT("Enforce") : _TEXT("Non-Enforce"),
  91. IS_ENFORCE_SERVER(TLS_CURRENT_VERSION)
  92. );
  93. // must be running as service and not in debug mode
  94. if(g_bReportToSCM == TRUE)
  95. {
  96. if(!(GetLicenseServerRole() & TLSERVER_ENTERPRISE_SERVER))
  97. {
  98. GetServiceLastShutdownTime(&ftTime);
  99. dwStatus = TLSStartAnnounceLicenseServerJob(
  100. g_pszServerPid,
  101. g_szScope,
  102. g_szComputerName,
  103. &ftTime
  104. );
  105. if(dwStatus != ERROR_SUCCESS)
  106. {
  107. return dwStatus;
  108. }
  109. }
  110. GetServiceLastShutdownTime(&ftTime);
  111. dwStatus = TLSStartAnnounceToEServerJob(
  112. g_pszServerPid,
  113. g_szScope,
  114. g_szComputerName,
  115. &ftTime
  116. );
  117. }
  118. ServiceInitPolicyModule();
  119. return dwStatus;
  120. }