mirror of
https://github.com/norohind/hans.git
synced 2025-04-14 21:50:33 +03:00
Merge branch 'refs/heads/master' into cygwin
This commit is contained in:
commit
308e87270a
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
virtual ~Worker();
|
||||
|
||||
virtual void run();
|
||||
virtual void stop();
|
||||
|
||||
static int headerSize() { return sizeof(TunnelHeader); }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user