Skip to content

Commit

Permalink
fix(ServerImpl): do finalization before exit process
Browse files Browse the repository at this point in the history
  • Loading branch information
nameoverflow committed Feb 26, 2018
1 parent ae2e3c4 commit b1bae01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion WeaselIPC/PipeChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace boost;

#define _ThrowLastError throw ::GetLastError()
#define _ThrowCode(__c) throw __c
#define _ThrowIfNot(__c) { DWORD err; if ((err = ::GetLastError()) != __c) throw __c; }
#define _ThrowIfNot(__c) { DWORD err; if ((err = ::GetLastError()) != __c) throw err; }

PipeChannelBase::PipeChannelBase(std::wstring &pn_cmd, size_t bs = 4 * 1024, SECURITY_ATTRIBUTES *s = NULL)
: pname(pn_cmd),
Expand Down
15 changes: 7 additions & 8 deletions WeaselIPCServer/WeaselServerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ ServerImpl::ServerImpl()
}

ServerImpl::~ServerImpl()
{
_Finailize();
}

void ServerImpl::_Finailize()
{
if (pipeThread != nullptr) {
pipeThread->interrupt();
Expand Down Expand Up @@ -120,14 +125,7 @@ int ServerImpl::Start()

int ServerImpl::Stop()
{
if (pipeThread != nullptr) {
pipeThread->interrupt();
}
if (IsWindow())
{
DestroyWindow();
}

_Finailize();
// quit the server
::ExitProcess(0);
return 0;
Expand Down Expand Up @@ -160,6 +158,7 @@ int ServerImpl::Run()
}



DWORD ServerImpl::OnEcho(WEASEL_IPC_COMMAND uMsg, DWORD wParam, DWORD lParam)
{
if (!m_pRequestHandler)
Expand Down
1 change: 1 addition & 0 deletions WeaselIPCServer/WeaselServerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ namespace weasel
}

private:
void _Finailize();
template<typename _Resp>
void HandlePipeMessage(PipeMessage pipe_msg, _Resp resp);

Expand Down

0 comments on commit b1bae01

Please sign in to comment.