浏览代码

Removed signal catching.


git-svn-id: https://svn.microneil.com/svn/SNFMilter/trunk@8 2c985dca-31e6-41a4-b4a2-d8f5b7f8e074
master
adeniz 15 年前
父节点
当前提交
8bfc0838be
共有 3 个文件被更改,包括 6 次插入64 次删除
  1. 6
    0
      ChangeLog
  2. 0
    4
      SNFMilter.hpp
  3. 0
    60
      main.cpp

+ 6
- 0
ChangeLog 查看文件

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

* SNFMilter.hpp: Removed signal catching.

* main.cpp (main): Removed signal catching.

2009-06-03 Alban Deniz <adeniz@skidmark.localdomain>

* SNFMilter.cpp: Added global variable SkipReturn. This replaces

+ 0
- 4
SNFMilter.hpp 查看文件

@@ -7,8 +7,6 @@
#ifndef SNFMilterhpp_included
#define SNFMilterhpp_included
#include <signal.h>
#include <libmilter/mfapi.h>
#include <vector>
@@ -72,8 +70,6 @@ const int ShutdownWaitPeriod_ms = 1000;
const string UnknownExceptionMessage = "Unknown exception occurred."; // Logged when an unknown exception occurs.
const int ShutdownSignal = SIGTERM; // Signal for shutdown.
//
// End of configuration.
//

+ 0
- 60
main.cpp 查看文件

@@ -48,30 +48,6 @@ class XCIShutdownWatcher : public snfXCIServerCommandHandler {
}
};
class SignalCatcher : public Thread { // Class to catch a signal.
private:
sigset_t *MySignalSet;
snf_RulebaseHandler *MyRulebase;
public:
SignalCatcher(sigset_t *Signal_Set, snf_RulebaseHandler* Rulebase) : // Construct.
MySignalSet(Signal_Set), // Set of signals to catch.
MyRulebase(Rulebase) { // Used for error logging.
run(); // Start the thread.
}
void myTask() {
int ReceivedSignal;
int Status = sigwait(MySignalSet, &ReceivedSignal);
if (0 != Status) {
// Log error.
ostringstream Temp;
Temp << "Error waiting for signal: " << strerror(Status) << ".";
MyRulebase->logThisError("Signal Catcher", 1, Temp.str());
return;
}
smfi_stop(); // Stop processing.
}
};
const int CorrectARGc = 2; // How many arguments we expect.
void displayHelp() { // Display some help.
@@ -102,28 +78,8 @@ int main(int argc, char* argv[]) {
cout << "Debug Mode" << endl; // watchers.
}
sigset_t SignalSet; // Set of signals to mask.
SignalCatcher *SigCatcher; // Object to catch signal.
try { // Catch anything that breaks loose.
int PthreadStatus;
if ( (0 != sigemptyset(&SignalSet)) || // Mask signal for this thread and
// all threads to be created.
(0 != sigaddset(&SignalSet, ShutdownSignal)) ) {
ostringstream Temp;
Temp << "Error masking signal on startup: " << strerror(errno) << ".";
throw runtime_error(Temp.str());
}
PthreadStatus = pthread_sigmask(SIG_BLOCK, &SignalSet, 0);
if (0 != PthreadStatus) {
ostringstream Temp;
Temp << "Error masking signal on startup (pthread_sigmask): " << strerror(PthreadStatus) << ".";
throw runtime_error(Temp.str());
}
snf_RulebaseHandler* MilterRulebase = new snf_RulebaseHandler(); // Allocate a rulebase handler.
MilterRulebase->PlatformVersion(SNF_MILTER_VERSION); // Record our version identification.
XCIShutdownWatcher ShutdownWatcher; // Make a server shutdown processor
@@ -133,29 +89,13 @@ int main(int argc, char* argv[]) {
SNFMilterContextPool* MilterContexts =
new SNFMilterContextPool(MilterRulebase); // Create the Milter Context Pool.
SigCatcher = new SignalCatcher(&SignalSet, MilterRulebase); // Create thread object to catch the signal.
runLibMilter(MilterContexts, DebugMode); // Run the milter.
ThreadState const &SigCatcherState = SigCatcher->MyState();
if (Thread::ThreadStarted.Name == SigCatcherState.Name) { // Is the signal catcher thread running?
PthreadStatus = pthread_kill(SigCatcher->getMyThread(), ShutdownSignal); // Yes. Send it a signal.
if (0 == PthreadStatus) {
SigCatcher->join(); // Wait for signal catcher to complete.
} else {
ostringstream Temp;
Temp << "Error terminating signal catcher: " << strerror(PthreadStatus) << ".";
throw runtime_error(Temp.str());
}
}
delete MilterContexts; // Destroy the context pool.
MilterContexts = 0; // Forget it.
MilterRulebase->close(); // Close down the rulebase handler.
delete MilterRulebase; // Destroy the rulebase.
MilterRulebase = 0; // Forget it.
delete SigCatcher; // Destroy the signal catcher.
SigCatcher = 0; // Forget it.
} // That's all folks.

正在加载...
取消
保存