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.

105 lines
3.2 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: failmsgq.h
  5. //
  6. // Description:
  7. // Header file for CFailedMsgQueue class with servers as a holding place
  8. // for messages that cannot be delivered due to out of memory and other
  9. // conditions.
  10. //
  11. // Author: Mike Swafford (MikeSwa)
  12. //
  13. // History:
  14. // 1/18/99 - MikeSwa Created
  15. //
  16. // Copyright (C) 1999 Microsoft Corporation
  17. //
  18. //-----------------------------------------------------------------------------
  19. #ifndef __FAILMSGQ_H__
  20. #define __FAILMSGQ_H__
  21. #include "aqincs.h"
  22. #include "rwnew.h"
  23. class CMsgRef;
  24. class CAQSvrInst;
  25. #define FAILEDMSGQUEUE_SIG ' QMF'
  26. //---[ CFailedMsgQueue ]-------------------------------------------------------
  27. //
  28. //
  29. // Description:
  30. // Class that abtracts handling of failed messages. There is no
  31. // additional memory allocation need during the processing of the
  32. // of these failed messages. The key design point is that none of these
  33. // API calls can fail.
  34. //
  35. // This class contains a single list entries for MailMsgs. MailMsgs that
  36. // have been dropped here must not be referenced by another other thread,
  37. // or we might break the threading-access restrictions of the mailmsg
  38. // interface. Once a MailMsg has been queued, it is encapsultated in a
  39. // CMsgRef object, which can be referenced by many threads. At this point
  40. // we must wait until all references to that CMsgRef are released.
  41. //
  42. // Hungarian:
  43. // fmq, pfmq
  44. //
  45. //-----------------------------------------------------------------------------
  46. class CFailedMsgQueue
  47. {
  48. private:
  49. DWORD m_dwSignature;
  50. DWORD m_dwFlags;
  51. DWORD m_cMsgs;
  52. CAQSvrInst *m_paqinst;
  53. LIST_ENTRY m_liHead;
  54. CShareLockNH m_slPrivateData;
  55. enum
  56. {
  57. FMQ_CALLBACK_REQUESTED = 0x00000001,
  58. };
  59. void InternalStartProcessingIfNecessary();
  60. public:
  61. CFailedMsgQueue();
  62. ~CFailedMsgQueue();
  63. void Initialize(CAQSvrInst *paqinst);
  64. void Deinitialize();
  65. //Functions called to handle a failure
  66. void HandleFailedMailMsg(IMailMsgProperties *pIMailMsgProperties);
  67. //Called on SubmitMessage to kick off processing if necessary
  68. inline void StartProcessingIfNecessary()
  69. {
  70. if (!(FMQ_CALLBACK_REQUESTED & m_dwFlags) && m_cMsgs)
  71. InternalStartProcessingIfNecessary();
  72. }
  73. //Member function and callback function to process entries.
  74. void ProcessEntries();
  75. static void ProcessEntriesCallback(PVOID pvContext);
  76. };
  77. //---[ AQueueFailedListEntry ]-------------------------------------------------
  78. //
  79. //
  80. // Description:
  81. // Actual in-memory representation of LIST_ENTRY ptr returned by mailmsg.
  82. // Memory after LIST_ENTRY is used to store original pointer.
  83. // Hungarian:
  84. // fli, pfli
  85. //
  86. //-----------------------------------------------------------------------------
  87. typedef struct tagAQueueFailedListEntry
  88. {
  89. LIST_ENTRY m_li;
  90. IMailMsgProperties *m_pIMailMsgProperties;
  91. } AQueueFailedListEntry;
  92. #endif //__FAILMSGQ_H__