diff options
Diffstat (limited to 'src/win32')
-rw-r--r-- | src/win32/signalHandler.hpp | 6 | ||||
-rw-r--r-- | src/win32/signalServiceHandler.hpp | 19 | ||||
-rw-r--r-- | src/win32/winService.cpp | 4 | ||||
-rw-r--r-- | src/win32/winService.h | 2 |
4 files changed, 14 insertions, 17 deletions
diff --git a/src/win32/signalHandler.hpp b/src/win32/signalHandler.hpp index fb0c7e6..23872a6 100644 --- a/src/win32/signalHandler.hpp +++ b/src/win32/signalHandler.hpp @@ -30,8 +30,8 @@ * along with anytun. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ANYTUN_signalHandler_h_INCLUDED -#define ANYTUN_signalHandler_h_INCLUDED +#ifndef ANYTUN_signalHandler_hpp_INCLUDED +#define ANYTUN_signalHandler_hpp_INCLUDED #include <windows.h> @@ -71,7 +71,7 @@ bool handleSignal(DWORD ctrlType) return true; } -void registerSignalHandler(SignalController& ctrl, DaemonService* /*service*/) +void registerSignalHandler(SignalController& ctrl, DaemonService& /*service*/) { if(!SetConsoleCtrlHandler((PHANDLER_ROUTINE)handleSignal, true)) AnytunError::throwErr() << "Error on SetConsoleCtrlhandler: " << AnytunErrno(GetLastError()); diff --git a/src/win32/signalServiceHandler.hpp b/src/win32/signalServiceHandler.hpp index 28121f4..da16de5 100644 --- a/src/win32/signalServiceHandler.hpp +++ b/src/win32/signalServiceHandler.hpp @@ -30,22 +30,19 @@ * along with anytun. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef ANYTUN_signalServiceHandler_h_INCLUDED -#define ANYTUN_signalServiceHandler_h_INCLUDED +#ifndef ANYTUN_signalServiceHandler_hpp_INCLUDED +#define ANYTUN_signalServiceHandler_hpp_INCLUDED #include "winService.h" -void registerSignalHandler(SignalController& ctrl, WinService* service) +void registerSignalHandler(SignalController& ctrl, WinService& service) { - if(!service) - return; + ctrl.handler[SERVICE_CONTROL_STOP] = boost::bind(&WinService::handleCtrlSignal, &service, _1, _2); + ctrl.handler[SERVICE_CONTROL_INTERROGATE] = boost::bind(&WinService::handleCtrlSignal, &service, _1, _2); + ctrl.handler[SIGUNKNOWN] = boost::bind(&WinService::handleCtrlSignal, &service, _1, _2); - ctrl.handler[SERVICE_CONTROL_STOP] = boost::bind(&WinService::handleCtrlSignal, service, _1, _2); - ctrl.handler[SERVICE_CONTROL_INTERROGATE] = boost::bind(&WinService::handleCtrlSignal, service, _1, _2); - ctrl.handler[SIGUNKNOWN] = boost::bind(&WinService::handleCtrlSignal, service, _1, _2); - - ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_RUNNING, boost::bind(&WinService::reportStatus, service, SERVICE_RUNNING, NO_ERROR))); - ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_STOPPING, boost::bind(&WinService::reportStatus, service, SERVICE_STOP_PENDING, NO_ERROR))); + ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_RUNNING, boost::bind(&WinService::reportStatus, &service, SERVICE_RUNNING, NO_ERROR))); + ctrl.callbacks.insert(SignalController::CallbackMap::value_type(CALLB_STOPPING, boost::bind(&WinService::reportStatus, &service, SERVICE_STOP_PENDING, NO_ERROR))); } #endif diff --git a/src/win32/winService.cpp b/src/win32/winService.cpp index e39fe56..8c17420 100644 --- a/src/win32/winService.cpp +++ b/src/win32/winService.cpp @@ -105,7 +105,7 @@ void WinService::start() AnytunError::throwErr() << "Error on StartServiceCtrlDispatcher: " << AnytunErrno(GetLastError());
}
-int real_main(int argc, char* argv[], WinService* service);
+int real_main(int argc, char* argv[], WinService& service);
VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv)
{
@@ -120,7 +120,7 @@ VOID WINAPI WinService::main(DWORD dwArgc, LPTSTR *lpszArgv) service.status_.dwServiceSpecificExitCode = 0;
service.reportStatus(SERVICE_START_PENDING, NO_ERROR);
- real_main(dwArgc, lpszArgv, &service);
+ real_main(dwArgc, lpszArgv, service);
service.reportStatus(SERVICE_STOPPED, NO_ERROR);
}
diff --git a/src/win32/winService.h b/src/win32/winService.h index ecba55d..9c95400 100644 --- a/src/win32/winService.h +++ b/src/win32/winService.h @@ -68,7 +68,7 @@ private: SERVICE_STATUS_HANDLE status_handle_; }; -typedef class WinService DaemonService; +typedef WinService DaemonService; #endif |