summaryrefslogtreecommitdiff
path: root/vdagent/vdagent.cpp
diff options
context:
space:
mode:
authorArnon Gilboa <agilboa@redhat.com>2013-03-18 14:13:04 +0200
committerArnon Gilboa <agilboa@redhat.com>2013-03-18 14:13:04 +0200
commit136c8d3c9467326b5cd47bfb47241e065a7c72d2 (patch)
tree273eab3b35cefb7fb65e457407df4b190753e670 /vdagent/vdagent.cpp
parente364fa7799933c2b31b5755b7f2e881a681c83ff (diff)
vdagent: don't terminate if stop event cannot be opened
so vdagent can keep running as standalone without dependency on vdservice. Regression was due to commit c1807e. rhbz #903379
Diffstat (limited to 'vdagent/vdagent.cpp')
-rw-r--r--vdagent/vdagent.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index e20c830..f254d55 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -295,11 +295,6 @@ bool VDAgent::run()
return false;
}
_stop_event = OpenEvent(SYNCHRONIZE, FALSE, VD_AGENT_STOP_EVENT);
- if (!_stop_event) {
- vd_printf("OpenEvent() failed: %lu", GetLastError());
- cleanup();
- return false;
- }
memset(&wcls, 0, sizeof(wcls));
wcls.lpfnWndProc = &VDAgent::wnd_proc;
wcls.lpszClassName = VD_AGENT_WINCLASS_NAME;
@@ -472,12 +467,19 @@ void VDAgent::input_desktop_message_loop()
void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask)
{
- HANDLE events[] = {_control_event, _stop_event};
- const DWORD event_count = sizeof(events) / sizeof(events[0]);
+ HANDLE events[] = {_control_event, _stop_event};
+ DWORD event_count = _stop_event ? 2 : 1;
DWORD wait_ret;
MSG msg;
wait_ret = MsgWaitForMultipleObjectsEx(event_count, events, timeout, wake_mask, MWMO_ALERTABLE);
+ if (wait_ret == WAIT_OBJECT_0 + event_count) {
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ return;
+ }
switch (wait_ret) {
case WAIT_OBJECT_0:
handle_control_event();
@@ -485,12 +487,6 @@ void VDAgent::event_dispatcher(DWORD timeout, DWORD wake_mask)
case WAIT_OBJECT_0 + 1:
_running = false;
break;
- case WAIT_OBJECT_0 + event_count:
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- break;
case WAIT_IO_COMPLETION:
case WAIT_TIMEOUT:
break;