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.

166 lines
5.3 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. //
  4. // File: ConnMgr.h
  5. //
  6. // Description: Definition CConnMgr, class that implements IConnectionManager
  7. //
  8. // Author: mikeswa
  9. //
  10. // Copyright (C) 1997 Microsoft Corporation
  11. //
  12. //-----------------------------------------------------------------------------
  13. #ifndef __CONNMGR_H_
  14. #define __CONNMGR_H_
  15. #include "aqinst.h"
  16. #include <aqueue.h>
  17. #include "aqnotify.h"
  18. #include <fifoq.h>
  19. #include "shutdown.h"
  20. #include <baseobj.h>
  21. #include <mailmsg.h>
  22. #include "retrsink.h"
  23. class CLinkMsgQueue;
  24. class CDomainMappingTable;
  25. class CSMTPConn;
  26. typedef CFifoQueue<CLinkMsgQueue *> QueueOfLinks;
  27. //We will only allow one @command to ETRN maximum 'X' domains
  28. //Anything more will be denied
  29. #define MAX_ETRNDOMAIN_PER_COMMAND 50
  30. typedef struct etrncontext
  31. {
  32. HRESULT hr;
  33. DWORD cMessages;
  34. CAQSvrInst *paqinst;
  35. CInternalDomainInfo* rIDIList[MAX_ETRNDOMAIN_PER_COMMAND];
  36. DWORD cIDICount;
  37. } ETRNCTX, *PETRNCTX;
  38. //---[ CConnMgr ]--------------------------------------------------------------
  39. //
  40. //
  41. // Hungarian: connmgr, pconnmgr
  42. //
  43. //
  44. //-----------------------------------------------------------------------------
  45. class CConnMgr :
  46. public IConnectionManager,
  47. public IConnectionRetryManager,
  48. public CBaseObject,
  49. public IAQNotify,
  50. protected CSyncShutdown
  51. {
  52. private:
  53. CAQSvrInst *m_paqinst;
  54. QueueOfLinks *m_pqol;
  55. CSMTP_RETRY_HANDLER *m_pDefaultRetryHandler;
  56. HANDLE m_hNextConnectionEvent;
  57. HANDLE m_hShutdownEvent;
  58. HANDLE m_hReleaseAllEvent;
  59. DWORD m_cConnections;
  60. //config stuff
  61. CShareLockNH m_slPrivateData;
  62. DWORD m_dwConfigVersion; //updated every time config is updated
  63. DWORD m_cMinMessagesPerConnection; //will be per-domain
  64. DWORD m_cMaxLinkConnections; //will be per-domain
  65. DWORD m_cMaxMessagesPerConnection;
  66. DWORD m_cMaxConnections;
  67. DWORD m_cGetNextConnectionWaitTime;
  68. BOOL m_fStoppedByAdmin;
  69. private :
  70. HRESULT CConnMgr::ETRNDomainList(ETRNCTX *pETRNCtx);
  71. HRESULT CConnMgr::StartETRNQueue(IN DWORD cbSMTPDomain,
  72. IN char szSMTPDomain[],
  73. ETRNCTX *pETRNCtx);
  74. public:
  75. CConnMgr();
  76. ~CConnMgr();
  77. HRESULT HrInitialize(CAQSvrInst *paqinst);
  78. HRESULT HrDeinitialize();
  79. HRESULT HrNotify(IN CAQStats *paqstats, BOOL fAdd);
  80. //Keep track of the number of connections
  81. void ReleaseConnection(CSMTPConn *pSMTPConn,
  82. BOOL *pfForceCheckForDSNGeneration);
  83. void LogConnectionFailedEvent(CSMTPConn *pSMTPConn,
  84. CLinkMsgQueue *plmq,
  85. LPSTR szDomain);
  86. //Will be used by catmsgq to update the metabase changes
  87. void UpdateConfigData(IN AQConfigInfo *pAQConfigInfo);
  88. //Used by CAQSvrInst to signal local delivery retry
  89. HRESULT SetCallbackTime(IN RETRFN pCallbackFn,
  90. IN PVOID pvContext,
  91. IN DWORD dwCallbackMinutes)
  92. {
  93. HRESULT hr = S_OK;
  94. if (m_pDefaultRetryHandler)
  95. {
  96. hr = m_pDefaultRetryHandler->SetCallbackTime(pCallbackFn,
  97. pvContext, dwCallbackMinutes);
  98. }
  99. else
  100. {
  101. hr = E_FAIL;
  102. }
  103. return hr;
  104. }
  105. //Can be used to make an otherwise idle system re-evaluate the
  106. //need for connections
  107. void KickConnections()
  108. {
  109. if (!m_fStoppedByAdmin)
  110. _VERIFY(SetEvent(m_hNextConnectionEvent));
  111. };
  112. void QueueAdminStopConnections() {m_fStoppedByAdmin = TRUE;};
  113. void QueueAdminStartConnections() {m_fStoppedByAdmin = FALSE;KickConnections();};
  114. BOOL fConnectionsStoppedByAdmin() {return m_fStoppedByAdmin;};
  115. HRESULT ModifyLinkState(
  116. IN DWORD cbDomainName,
  117. IN char szDomainName[],
  118. IN DWORD dwScheduleID,
  119. IN GUID rguidTransportSink,
  120. IN DWORD dwFlagsToSet,
  121. IN DWORD dwFlagsToUnset);
  122. public: //IUnknown
  123. STDMETHOD(QueryInterface)(REFIID riid, LPVOID * ppvObj);
  124. STDMETHOD_(ULONG, AddRef)(void) {return CBaseObject::AddRef();};
  125. STDMETHOD_(ULONG, Release)(void) {return CBaseObject::Release();};
  126. public: // IConnectionManager - private interface with SMTP
  127. STDMETHOD(GetNextConnection)(OUT ISMTPConnection **ppISMTPConnection);
  128. STDMETHOD(GetNamedConnection)(IN DWORD cbSMTPDomain,
  129. IN char szSMTPDomain[],
  130. OUT ISMTPConnection **ppISMTPConnection);
  131. STDMETHOD(ReleaseWaitingThreads)();
  132. STDMETHOD(ETRNDomain)(IN DWORD cbSMTPDomain,
  133. IN char szSMTPDomain[],
  134. OUT DWORD *pcMessages);
  135. public: //IConnectionRetryManager - interface with routing
  136. STDMETHOD(RetryLink)(
  137. IN DWORD cbDomainName,
  138. IN char szDomainName[],
  139. IN DWORD dwScheduleID,
  140. IN GUID rguidTransportSink);
  141. };
  142. #endif //__CONNMGR_H_