瀏覽代碼

Replace SNFMilterContext::SkipReturn with global variable SkipReturn

(in file SNFMilter.cpp).  Implemented assignContextToCtx to assign a
SNFMilterContext object.


git-svn-id: https://svn.microneil.com/svn/SNFMilter/trunk@7 2c985dca-31e6-41a4-b4a2-d8f5b7f8e074
master
adeniz 15 年之前
父節點
當前提交
594aee75e5
共有 3 個文件被更改,包括 38 次插入30 次删除
  1. 11
    0
      ChangeLog
  2. 27
    27
      SNFMilter.cpp
  3. 0
    3
      SNFMilter.hpp

+ 11
- 0
ChangeLog 查看文件

@@ -1,3 +1,14 @@
2009-06-03 Alban Deniz <adeniz@skidmark.localdomain>

* SNFMilter.cpp: Added global variable SkipReturn. This replaces
SNFMilterContext::SkipReturn.
(assignContextToCtx): Implemented function.
(mlfi_connect): Invoke assignContextToCtx().
(mlfi_negotiate): Do not assign a SNFMilterContext object.

* SNFMilter.hpp (class SNFMilterContext): Removed member
SkipReturn.

2009-05-27 Alban Deniz <adeniz@skidmark.localdomain>

* Makefile.am (EXTRA_DIST): Include ChangeLog.

+ 27
- 27
SNFMilter.cpp 查看文件

@@ -25,6 +25,8 @@
SNFMilterContextPool* MilterContexts = 0; // The global contexts handle.
bool MilterDebugMode; // True if debug mode is on.
sfsistat SkipReturn = SMFIS_CONTINUE; // libmilter return value when further
// callbacks of the same type are to be skipped.
/// Get the connection context object.
//
@@ -41,6 +43,24 @@ getContextFromCtx(SMFICTX* Ctx) {
return Context;
}
/// Get a new connection object and assign it to the context.
//
// \param[in] Ctx is the libmilter context object.
//
// \returns the pointer to the connection context object.
//
// \throws runtime_error if the obtained pointer is 0.
//
SNFMilterContext *
assignContextToCtx(SMFICTX* Ctx) {
SNFMilterContext *Context = MilterContexts->grab(); // Get any existing context object.
if(0 == Context) // Check address.
throw runtime_error("Got NULL from MilterContexts->grab()");
smfi_setpriv(Ctx, Context); // Save the context object.
Context->ConnectionData.clear(); // Clear the connection context object.
return Context;
}
// Function to output an info message.
void logInfo(const string ContextName, int Code, std::string Message) {
cout << ContextName << " (code " << Code << "): " << Message << endl;
@@ -238,7 +258,6 @@ string SNFMilterEngine::XHeaders() {
//// SNFMilterContext
SNFMilterContext::SNFMilterContext(snf_RulebaseHandler *myRulebase) :
SkipReturn(SMFIS_CONTINUE),
milterEngine(myRulebase),
MessageData(MailBufferReserveSize) {}
@@ -461,18 +480,8 @@ extern "C" {
sfsistat CallbackResult = FailSafeMilterResponse;
try {
#ifdef NEW_SNFMILTER
SNFMilterContext *Context = getContextFromCtx(Ctx); // Get the existing context object.
#else
SNFMilterContext *Context = (SNFMilterContext *) smfi_getpriv(Ctx); // Get the context object.
if (0 == Context) {
Context = MilterContexts->grab(); // Get a context object.
if(0 == Context) // Check address.
throw runtime_error("Got NULL from MilterContexts->grab()");
smfi_setpriv(Ctx, Context); // Save the context object.
Context->ConnectionData.clear(); // Clear the connection context object.
}
#endif
SNFMilterContext *Context = assignContextToCtx(Ctx); // Get the existing context object,
// or assign a new context object.
Context->State = SNFMilterContext::Connect; // Update context state.
@@ -754,8 +763,8 @@ extern "C" {
// is scanned.
//
// Returns: SMFIS_CONTINUE if more of the message body is needed,
// Context->SkipReturn if more of the message body is not needed,
// or FailSafeMilterResponse if an error occurs. Context is the
// SkipReturn if more of the message body is not needed, or
// FailSafeMilterResponse if an error occurs. Context is the
// connection context object.
//
sfsistat
@@ -775,7 +784,7 @@ extern "C" {
if (Context->MessageData.MessageBuffer.size() >= // Return if there is enough in the
MailBufferReserveSize) { // message buffer.
return Context->SkipReturn;
return SkipReturn;
}
@@ -1167,20 +1176,11 @@ extern "C" {
sfsistat CallbackResult = SMFIS_ALL_OPTS;
try {
SNFMilterContext *Context = (SNFMilterContext *) smfi_getpriv(Ctx); // Get the context object.
if (0 == Context) {
Context = MilterContexts->grab(); // Get a context object.
if(0 == Context) // Check address.
throw runtime_error("Got NULL from MilterContexts->grab()");
smfi_setpriv(Ctx, Context); // Save the context object.
Context->ConnectionData.clear(); // Clear the connection context object.
}
bool AcceptsSkip = F1 & SMFIP_SKIP;
if (AcceptsSkip) { // MTA accepts SMFIS_SKIP return?
Context->SkipReturn = SMFIS_SKIP; // Yes. Use SMFIS_SKIP.
SkipReturn = SMFIS_SKIP; // Yes. Use SMFIS_SKIP.
} else {
Context->SkipReturn = SMFIS_CONTINUE; // No. Use SMFIS_CONTINUE.
SkipReturn = SMFIS_CONTINUE; // No. Use SMFIS_CONTINUE.
}
if (MilterDebugMode) {

+ 0
- 3
SNFMilter.hpp 查看文件

@@ -152,9 +152,6 @@ public:
SNFMilterContext(snf_RulebaseHandler *);
~SNFMilterContext();
sfsistat SkipReturn; // libmilter return value when further
// callbacks of the same type are to be skipped.
// Map the scan result to the libmilter return value.
sfsistat
smfisReturn(SNFMilterAction);

Loading…
取消
儲存