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.

257 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. scavthrd.c
  5. Abstract:
  6. This module implements the scavenger thread and its dispatch.
  7. Author:
  8. Joe Linn [JoeLinn] 19-aug-1994
  9. Revision History:
  10. --*/
  11. #include "precomp.h"
  12. #pragma hdrstop
  13. #include "scavthrd.h"
  14. //
  15. // The Bug check file id for this module
  16. //
  17. #define BugCheckFileId (RDBSS_BUG_CHECK_SCAVTHRD)
  18. //
  19. // The local debug trace level
  20. //
  21. #define Dbg (DEBUG_TRACE_SCAVTHRD)
  22. //
  23. // This counter is used to control kicking the scavenger thread.
  24. //
  25. LONG RxTimerCounter;
  26. ULONG RxTimerCounterPeriod = RX_TIMER_COUNTER_PERIOD;
  27. //WORK_QUEUE_ITEM CancelWorkItem;
  28. WORK_QUEUE_ITEM TimerWorkItem;
  29. #ifdef ALLOC_PRAGMA
  30. #pragma alloc_text(PAGE,RxTimer)
  31. #endif
  32. VOID
  33. RxTimer (
  34. IN PVOID Context
  35. )
  36. /*++
  37. Routine Description:
  38. This function implements the NT redirector's scavenger thread. It performs idle time operations
  39. such as closing out dormant connections etc. It is run on an executive worker thread from the
  40. delayed queue as can be seen below.
  41. Arguments:
  42. None.
  43. Return Value:
  44. None.
  45. --*/
  46. {
  47. PAGED_CODE();
  48. RxDbgTrace(0, (DEBUG_TRACE_SHUTDOWN), ("RxTimer\n", 0)); //joejoe shutdown may be a bad choice
  49. TimerWorkItem.List.Flink = NULL; // this is used to specifically signal a requeueable state
  50. /* this is larry's old code
  51. //
  52. // First scan for dormant connections to remove.
  53. //
  54. RxScanForDormantConnections(0, NULL);
  55. //RxScanForDormantSecurityEntries();
  56. //
  57. // Now check the list of open outstanding files and remove any that are
  58. // "too old" from the cache.
  59. //
  60. RxPurgeDormantCachedFiles();
  61. //
  62. // Request updated throughput, delay and reliability information from the
  63. // transport for each connection.
  64. //
  65. RxEvaluateTimeouts();
  66. //
  67. // Now "PING" remote servers for longterm requests that have been active
  68. // for more than the timeout period.
  69. //
  70. RxPingLongtermOperations();
  71. */
  72. UNREFERENCED_PARAMETER(Context);
  73. }
  74. VOID
  75. RxIdleTimer (
  76. IN PDEVICE_OBJECT DeviceObject,
  77. IN PVOID Context
  78. )
  79. /*++
  80. Routine Description:
  81. This routine is the Timer DPC for the scavenger timer. What happens is that it down to the period value
  82. and then queues an executive work item to the delayed queue.
  83. Arguments:
  84. IN PDEVICE_OBJECT DeviceObject - Supplies the device object for the timer
  85. IN PVOID Context - Ignored in this routine.
  86. Return Value:
  87. None.
  88. --*/
  89. {
  90. RxElapsedSecondsSinceStart++; //keep running count of the elapsed time
  91. //
  92. // Check to see if it's time ttime to do anything
  93. //joejoe we should specifically have something to do before we trot off but not now
  94. if (--RxTimerCounter <= 0) {
  95. RxTimerCounter = RxTimerCounterPeriod;
  96. // / //
  97. // / // If there are any outstanding commands, check to see if they've
  98. // / // timed out.
  99. // / //
  100. // / if (RxStatistics.CurrentCommands != 0) {
  101. // / //
  102. // / // Please note that we use the kernel work queue routines directly for
  103. // / // this instead of going through the normal redirector work queue
  104. // / // routines. We do this because the redirector work queue routines will
  105. // / // only allow a limited number of requests through to the worker threads,
  106. // / // and it is critical that this request run (if it didn't, there could be
  107. // / // a worker thread that was blocked waiting on the request to be canceled
  108. // / // could never happen because the cancelation routine was behind it on
  109. // / // the work queue.
  110. // / //
  111. // / if (CancelWorkItem.List.Flink == NULL) {
  112. // / RxQueueWorkItem(&CancelWorkItem, CriticalWorkQueue);
  113. // / }
  114. // / }
  115. //
  116. // Queue up a scavenger request to a worker thread if the quy is not already enqueued.
  117. //
  118. if (TimerWorkItem.List.Flink == NULL) {
  119. // RxQueueWorkItem(&TimerWorkItem, DelayedWorkQueue);
  120. RxQueueWorkItem( &TimerWorkItem, DelayedWorkQueue );
  121. }
  122. }
  123. return;
  124. UNREFERENCED_PARAMETER(DeviceObject);
  125. UNREFERENCED_PARAMETER(Context);
  126. }
  127. VOID
  128. RxInitializeScavenger (
  129. VOID
  130. )
  131. /*++
  132. Routine Description:
  133. Initialize workitems, timers, counters to implement the dispatch to the RxTimer routine.
  134. Arguments:
  135. None.
  136. Return Value:
  137. None.
  138. --*/
  139. {
  140. RxInitializeWorkItem( &TimerWorkItem, RxTimer, NULL );
  141. // RxInitializeWorkItem( &CancelWorkItem, RxCancelOutstandingRequests, NULL );
  142. //
  143. // Set the timer up for the idle timer.
  144. //
  145. RxElapsedSecondsSinceStart = 0;
  146. RxTimerCounter = RxTimerCounterPeriod;
  147. IoInitializeTimer((PDEVICE_OBJECT)RxFileSystemDeviceObject, RxIdleTimer, NULL);
  148. IoStartTimer((PDEVICE_OBJECT)RxFileSystemDeviceObject);
  149. return;
  150. }
  151. VOID
  152. RxUninitializeScavenger (
  153. VOID
  154. )
  155. /*++
  156. Routine Description:
  157. Stops the timer used to dispatch to the RxTimer routine.
  158. Arguments:
  159. None.
  160. Return Value:
  161. None.
  162. --*/
  163. {
  164. IoStopTimer((PDEVICE_OBJECT)RxFileSystemDeviceObject);
  165. return;
  166. }
  167.