[Spice-devel] [spice-server v3 5/8] reds: Close sockets when using spice_server_destroy()

Pavel Grunt pgrunt at redhat.com
Wed Feb 8 09:50:52 UTC 2017


On Mon, 2017-02-06 at 18:15 +0100, Christophe Fergeau wrote:
> Currently, the network sockets opened by reds_init_net() are not
> closed
> on destruction, in other words they are leaked.

Acked-by: Pavel Grunt <pgrunt at redhat.com>

> ---
>  server/reds.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/server/reds.c b/server/reds.c
> index 953a95a..ff0f0e2 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -3472,6 +3472,9 @@ SPICE_GNUC_VISIBLE SpiceServer
> *spice_server_new(void)
>  #ifdef RED_STATISTICS
>      reds->stat_file = stat_file_new(REDS_MAX_STAT_NODES);
>  #endif
> +    reds->listen_socket = -1;
> +    reds->secure_listen_socket = -1;
> +

so this init can be removed from do_spice_init

Pavel 

>      return reds;
>  }
>  
> @@ -3651,6 +3654,16 @@ SPICE_GNUC_VISIBLE void
> spice_server_destroy(SpiceServer *reds)
>      if (reds->main_dispatcher) {
>          g_object_unref(reds->main_dispatcher);
>      }
> +    if (reds->listen_socket != -1) {
> +       reds_core_watch_remove(reds, reds->listen_watch);
> +       if (reds->config->spice_listen_socket_fd != reds-
> >listen_socket) {
> +          close(reds->listen_socket);
> +       }
> +    }
> +    if (reds->secure_listen_socket != -1) {
> +       reds_core_watch_remove(reds, reds->secure_listen_watch);
> +       close(reds->secure_listen_socket);
> +    }
>  
>      reds_cleanup(reds);
>  #ifdef RED_STATISTICS


More information about the Spice-devel mailing list