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.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. #include "precomp.h"
  21. #include "splsvr.h"
  22. #include "server.h"
  23. HANDLE TerminateEvent = NULL;
  24. VOID
  25. SPOOLER_main (
  26. IN DWORD argc,
  27. IN LPTSTR *argv
  28. )
  29. /*++
  30. Routine Description:
  31. This is the main routine for the Spooler Service
  32. Arguments:
  33. Return Value:
  34. None.
  35. Note:
  36. --*/
  37. {
  38. if(TerminateEvent = CreateEvent (0, TRUE, FALSE,0))
  39. {
  40. SpoolerState = SpoolerInitializeSpooler(argc, argv);
  41. if (SpoolerState != RUNNING) {
  42. DBGMSG(DBG_WARN,("Spooler Shutdown during initialization\n"));
  43. }
  44. if (SpoolerState == STOPPING) {
  45. SpoolerShutdown();
  46. }
  47. DBGMSG(DBG_TRACE,("SPOOLER_main: Exiting Spooler Thread\n"));
  48. WaitForSingleObject(TerminateEvent,INFINITE);
  49. CloseHandle(TerminateEvent);
  50. if(hPhase2Init)
  51. {
  52. CloseHandle(hPhase2Init);
  53. }
  54. SpoolerStatusUpdate (STOPPED);
  55. }
  56. else
  57. {
  58. DBGMSG(DBG_WARN,("Spooler unable to create Terminate event"));
  59. }
  60. ExitThread(0);
  61. return;
  62. }
  63. VOID
  64. SpoolerShutdown(VOID)
  65. /*++
  66. Routine Description:
  67. Arguments:
  68. none
  69. Return Value:
  70. none
  71. --*/
  72. {
  73. DBGMSG(DBG_TRACE,(" in SpoolerShutdown\n",0));
  74. // *** SHUTDOWN HINT ***
  75. SpoolerStatusUpdate (STOPPING);
  76. //
  77. // Shut down the router.
  78. //
  79. DBGMSG(DBG_TRACE,("SpoolerShutdown: Shut down router\n"));
  80. SplShutDownRouter();
  81. //
  82. // Shut down the RPC interface.
  83. //
  84. DBGMSG(DBG_TRACE,("SpoolerShutdown: Shut down RPC server\n"));
  85. //
  86. // If we've come here, then we've stopped accepting RPC calls
  87. //
  88. DBGMSG(DBG_TRACE, ("SpoolerShutdown: We've serviced all pending requests\n"));
  89. //
  90. // Shut down the Spooler
  91. DBGMSG(DBG_TRACE,("SpoolerShutdown: Done with shutdown\n"));
  92. return;
  93. }