[Spice-devel] [PATCH spice] Use SPICE_FOREIGN_MENU_SOCKET if it's available

Christophe Fergeau cfergeau at redhat.com
Mon Mar 5 14:21:16 PST 2012


On Mon, Mar 05, 2012 at 10:52:34PM +0100, Marc-André Lureau wrote:
> If specified, use SPICE_FOREIGN_MENU_SOCKET environment variable over
> snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME,
> Platform::get_process_id()); since it's impossible to guess the client
> pid when spice-xpi launches the client as a grand-child (via script
> etc).

If said script does "exec spicec $@", the client pid guessing should
work fine.
ACK.

Christophe

> 
> This is also more aligned with the way we handle SPICE_XPI_SOCKET
> location.
> ---
>  client/controller.cpp   |    2 +-
>  client/foreign_menu.cpp |    8 +++++++-
>  2 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/client/controller.cpp b/client/controller.cpp
> index e0b7fe7..514bf68 100644
> --- a/client/controller.cpp
> +++ b/client/controller.cpp
> @@ -44,7 +44,7 @@ Controller::Controller(ControllerInterface *handler)
>  #ifdef WIN32
>      snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id());
>  #else
> -    char *p_socket = getenv("SPICE_XPI_SOCKET");
> +    const char *p_socket = getenv("SPICE_XPI_SOCKET");
>      if (!p_socket) {
>          LOG_ERROR("Failed to get a controller connection (SPICE_XPI_SOCKET)");
>          throw Exception("Failed to get a controller connection (SPICE_XPI_SOCKET)");
> diff --git a/client/foreign_menu.cpp b/client/foreign_menu.cpp
> index faef4c2..1010bfb 100644
> --- a/client/foreign_menu.cpp
> +++ b/client/foreign_menu.cpp
> @@ -44,7 +44,13 @@ ForeignMenu::ForeignMenu(ForeignMenuInterface *handler, bool active)
>      char pipe_name[PIPE_NAME_MAX_LEN];
>  
>      ASSERT(_handler != NULL);
> -    snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id());
> +#ifndef WIN32
> +    const char *p_socket = getenv("SPICE_FOREIGN_MENU_SOCKET");
> +    if (p_socket)
> +        strncpy(pipe_name, p_socket, sizeof(pipe_name));
> +    else
> +#endif
> +        snprintf(pipe_name, PIPE_NAME_MAX_LEN, PIPE_NAME, Platform::get_process_id());
>      LOG_INFO("Creating a foreign menu connection %s", pipe_name);
>      _foreign_menu = NamedPipe::create(pipe_name, *this);
>      if (!_foreign_menu) {
> -- 
> 1.7.7.6
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120305/24f9b325/attachment.pgp>


More information about the Spice-devel mailing list