[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [virt-tools-list] [PATCH virt-viewer 6/6] Use a mutex to check if VirtViewer running



I've already reviewed this one separately, is it any different?

Christophe

On Sat, Oct 20, 2012 at 12:57:31AM +0200, Marc-André Lureau wrote:
> We need to warn user that installer can't proceed if there is already
> a running instance of VirtViewer or of the installer.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=864033
> ---
>  data/virt-viewer.nsis.in | 10 ++++++++++
>  src/virt-viewer-util.c   |  9 +++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/data/virt-viewer.nsis.in b/data/virt-viewer.nsis.in
> index 45af104..d73fd73 100644
> --- a/data/virt-viewer.nsis.in
> +++ b/data/virt-viewer.nsis.in
> @@ -45,6 +45,16 @@ Function RegisterApplication
>      WriteRegDWord HKCU "${REG_IEPOLICY}" "Policy" 3
>  FunctionEnd
>  
> +Function .onInit
> +retry:
> + System::Call 'kernel32::CreateMutexA(i 0, i 0, t "VirtViewerMutex") i .r1 ?e'
> + Pop $R0
> + StrCmp $R0 0 +3
> +   MessageBox MB_ICONEXCLAMATION|MB_RETRYCANCEL "VirtViewer is already running, quit any instance and retry." IDRETRY retry IDCANCEL cancel
> +cancel:
> +   Abort
> +FunctionEnd
> +
>  Section "VirtViewer"
>    SectionIn RO
>    WriteRegStr HKCU "Software\virt-viewer" "" $INSTDIR
> diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c
> index 556638c..e99b106 100644
> --- a/src/virt-viewer-util.c
> +++ b/src/virt-viewer-util.c
> @@ -263,6 +263,15 @@ gulong virt_viewer_signal_connect_object(gpointer instance,
>  void virt_viewer_util_init(const gchar *appname)
>  {
>  #ifdef G_OS_WIN32
> +    /*
> +     * This named mutex will be kept around by Windows until the
> +     * process terminates. This allows other instances to check if it
> +     * already exists, indicating already running instances. It is
> +     * used to warn the user that installer can't proceed in this
> +     * case.
> +     */
> +    CreateMutexA(0, 0, "VirtViewerMutex");
> +
>      if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
>          freopen("CONIN$", "r", stdin);
>          freopen("CONOUT$", "w", stdout);
> -- 
> 1.7.11.7
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list redhat com
> https://www.redhat.com/mailman/listinfo/virt-tools-list

Attachment: pgpL0J34i68Zz.pgp
Description: PGP signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]