Hi, On Mon, Dec 12, 2016 at 10:42:43PM +0100, Victor Toso wrote: > From: Frediano Ziglio <fziglio@xxxxxxxxxx> > > Would be something like this (not tested) I would just add the commit log from: https://lists.freedesktop.org/archives/spice-devel/2016-August/031381.html > --- > common/vdcommon.h | 1 + > vdagent/vdagent.cpp | 12 ++++++++++++ > vdservice/vdservice.cpp | 7 +++++++ > 3 files changed, 20 insertions(+) > > diff --git a/common/vdcommon.h b/common/vdcommon.h > index c1920e9..6b53327 100644 > --- a/common/vdcommon.h > +++ b/common/vdcommon.h > @@ -66,6 +66,7 @@ typedef Mutex mutex_t; > > #define VD_AGENT_REGISTRY_KEY "SOFTWARE\\Red Hat\\Spice\\vdagent\\" > #define VD_AGENT_STOP_EVENT TEXT("Global\\vdagent_stop_event") > +#define VD_AGENT_SESSION_UNLOCKED_EVENT TEXT("Global\\vdagent_session_unlocked_event") > > #if defined __GNUC__ > #define ALIGN_GCC __attribute__ ((packed)) > diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp > index e3ba14b..0396a11 100644 > --- a/vdagent/vdagent.cpp > +++ b/vdagent/vdagent.cpp > @@ -236,6 +236,18 @@ VDAgent::VDAgent() > ZeroMemory(&_write_overlapped, sizeof(_write_overlapped)); > ZeroMemory(_read_buf, sizeof(_read_buf)); > > + HANDLE _session_unlocked_event = OpenEvent(SYNCHRONIZE, FALSE, VD_AGENT_SESSION_UNLOCKED_EVENT); and maybe move the variable definition to the top? Acked-by: Victor Toso <victortoso@xxxxxxxxxx> toso > + switch (WaitForSingleObject(_session_unlocked_event, 0)) { > + case WAIT_OBJECT_0: > + _session_is_locked = false; > + break; > + default: > + case WAIT_TIMEOUT: > + _session_is_locked = true; > + break; > + } > + CloseHandle(_session_unlocked_event); > + > _singleton = this; > } > > diff --git a/vdservice/vdservice.cpp b/vdservice/vdservice.cpp > index 1892b72..65adf72 100644 > --- a/vdservice/vdservice.cpp > +++ b/vdservice/vdservice.cpp > @@ -91,6 +91,7 @@ private: > PROCESS_INFORMATION _agent_proc_info; > HANDLE _control_event; > HANDLE _agent_stop_event; > + HANDLE _session_unlocked_event; > HANDLE* _events; > TCHAR _agent_path[MAX_PATH]; > VDControlQueue _control_queue; > @@ -123,11 +124,13 @@ VDService::VDService() > _system_version = supported_system_version(); > _control_event = CreateEvent(NULL, FALSE, FALSE, NULL); > _agent_stop_event = CreateEvent(NULL, FALSE, FALSE, VD_AGENT_STOP_EVENT); > + _session_unlocked_event = CreateEvent(NULL, TRUE, TRUE, VD_AGENT_SESSION_UNLOCKED_EVENT); > _agent_path[0] = wchar_t('\0'); > } > > VDService::~VDService() > { > + CloseHandle(_session_unlocked_event); > CloseHandle(_agent_stop_event); > CloseHandle(_control_event); > delete[] _events; > @@ -290,6 +293,10 @@ DWORD WINAPI VDService::control_handler(DWORD control, DWORD event_type, LPVOID > if (event_type == WTS_CONSOLE_CONNECT) { > s->_session_id = session_id; > s->set_control_event(VD_CONTROL_RESTART_AGENT); > + } else if (event_type == WTS_SESSION_LOCK) { > + ResetEvent(s->_session_unlocked_event); > + } else if (event_type == WTS_SESSION_UNLOCK) { > + SetEvent(s->_session_unlocked_event); > } > break; > } > -- > 2.9.3 > > _______________________________________________ > Spice-devel mailing list > Spice-devel@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/spice-devel
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel