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.

176 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. splmain.c
  5. Abstract:
  6. This is the main routine for the Windows NT Spooler Service.
  7. Functions in the file include:
  8. SPOOLER_main
  9. Author:
  10. Krishna Ganugapati (KrishnaG) 12-Oct-1993
  11. Environment:
  12. User Mode - Win32
  13. Revision History:
  14. 4-Jan-1999 Khaleds
  15. Added Code for optimiziting the load time of the spooler by decoupling
  16. the startup dependency between spoolsv and spoolss
  17. 12-Oct-1993 krishnaG
  18. Created
  19. --*/
  20. //
  21. // INCLUDES
  22. //
  23. #define NOMINMAX
  24. #include <nt.h>
  25. #include <ntrtl.h>
  26. #include <nturtl.h>
  27. #include <windows.h>
  28. #include <winspool.h>
  29. #include <winsplp.h>
  30. #include <rpc.h>
  31. #include "splsvr.h"
  32. #include "splr.h"
  33. #include "server.h"
  34. HANDLE TerminateEvent = NULL;
  35. VOID
  36. SPOOLER_main (
  37. IN DWORD argc,
  38. IN LPTSTR *argv
  39. )
  40. /*++
  41. Routine Description:
  42. This is the main routine for the Spooler Service
  43. Arguments:
  44. Return Value:
  45. None.
  46. Note:
  47. --*/
  48. {
  49. if(TerminateEvent = CreateEvent (0, TRUE, FALSE,0))
  50. {
  51. SpoolerState = SpoolerInitializeSpooler(argc, argv);
  52. if (SpoolerState != RUNNING) {
  53. DBGMSG(DBG_WARN,("Spooler Shutdown during initialization\n"));
  54. }
  55. if (SpoolerState == STOPPING) {
  56. SpoolerShutdown();
  57. }
  58. DBGMSG(DBG_TRACE,("SPOOLER_main: Exiting Spooler Thread\n"));
  59. WaitForSingleObject(TerminateEvent,INFINITE);
  60. CloseHandle(TerminateEvent);
  61. if(hPhase2Init)
  62. {
  63. CloseHandle(hPhase2Init);
  64. }
  65. SpoolerStatusUpdate (STOPPED);
  66. }
  67. else
  68. {
  69. DBGMSG(DBG_WARN,("Spooler unable to create Terminate event"));
  70. }
  71. ExitThread(0);
  72. return;
  73. }
  74. VOID
  75. SpoolerShutdown(VOID)
  76. /*++
  77. Routine Description:
  78. Arguments:
  79. none
  80. Return Value:
  81. none
  82. --*/
  83. {
  84. DBGMSG(DBG_TRACE,(" in SpoolerShutdown\n",0));
  85. // *** SHUTDOWN HINT ***
  86. SpoolerStatusUpdate (STOPPING);
  87. //
  88. // Shut down the router.
  89. //
  90. DBGMSG(DBG_TRACE,("SpoolerShutdown: Shut down router\n"));
  91. SplShutDownRouter();
  92. //
  93. // Shut down the RPC interface.
  94. //
  95. DBGMSG(DBG_TRACE,("SpoolerShutdown: Shut down RPC server\n"));
  96. // SpoolerStopRpcServer( /*nspool_ServerIfHandle*/ );
  97. // *** SHUTDOWN HINT ***
  98. // SpoolerStatusUpdate (STOPPING);
  99. //
  100. // If we've come here, then we've stopped accepting RPC calls
  101. //
  102. DBGMSG(DBG_TRACE, ("SpoolerShutdown: We've serviced all pending requests\n"));
  103. //
  104. // Shut down the Spooler
  105. DBGMSG(DBG_TRACE,("SpoolerShutdown: Done with shutdown\n"));
  106. return;
  107. }