Merge branch 'refs/heads/master' into cygwin

This commit is contained in:
Friedrich Schöller 2013-05-22 01:16:03 +02:00
commit 308e87270a
3 changed files with 18 additions and 2 deletions

View File

@ -36,14 +36,20 @@
#include <sys/socket.h>
#include <signal.h>
static Worker *worker = NULL;
static void sig_term_handler(int)
{
syslog(LOG_INFO, "SIGTERM received");
if (worker)
worker->stop();
}
static void sig_int_handler(int)
{
syslog(LOG_INFO, "SIGINT received");
if (worker)
worker->stop();
}
static void usage()
@ -93,7 +99,6 @@ int main(int argc, char *argv[])
bool changeEchoId = false;
bool changeEchoSeq = false;
bool verbose = false;
Worker *worker = NULL;
openlog(argv[0], LOG_PERROR, LOG_DAEMON);

View File

@ -127,7 +127,12 @@ void Worker::run()
// wait for data or timeout
int result = select(maxFd + 1 , &fs, NULL, NULL, nextTimeout != Time::ZERO ? &timeout.getTimeval() : NULL);
if (result == -1)
throw Exception("select", true);
{
if (alive)
throw Exception("select", true);
else
return;
}
now = Time::now();
// timeout
@ -183,6 +188,11 @@ void Worker::run()
}
}
void Worker::stop()
{
alive = false;
}
void Worker::dropPrivileges()
{
#ifndef WIN32

View File

@ -34,6 +34,7 @@ public:
virtual ~Worker();
virtual void run();
virtual void stop();
static int headerSize() { return sizeof(TunnelHeader); }