Re: [PATCH vdagent v2 3/8] vdagent: move file xfer finalize to a function

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

 



> 
> From: Victor Toso <me@xxxxxxxxxxxxxx>
> 
> This patch creates vdagent_finalize_file_xfer() to finalize and stop
> file xfer. Moving this code to a function removes some duplication.
> 
> Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>

Acked-by: Frediano Ziglio <fziglio@xxxxxxxxxx>

Frediano

> ---
>  src/vdagent/vdagent.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
> index ac507c4..7a2a220 100644
> --- a/src/vdagent/vdagent.c
> +++ b/src/vdagent/vdagent.c
> @@ -109,6 +109,15 @@ static gboolean vdagent_init_file_xfer(void)
>      return (vdagent_file_xfers != NULL);
>  }
>  
> +static gboolean vdagent_finalize_file_xfer(void)
> +{
> +    if (vdagent_file_xfers == NULL)
> +        return FALSE;
> +
> +    g_clear_pointer(&vdagent_file_xfers, vdagent_file_xfers_destroy);
> +    return TRUE;
> +}
> +
>  static void daemon_read_complete(struct udscs_connection **connp,
>      struct udscs_message_header *header, uint8_t *data)
>  {
> @@ -160,10 +169,7 @@ static void daemon_read_complete(struct udscs_connection
> **connp,
>          if (debug)
>              syslog(LOG_DEBUG, "Disabling file-xfers");
>  
> -        if (vdagent_file_xfers != NULL) {
> -            vdagent_file_xfers_destroy(vdagent_file_xfers);
> -            vdagent_file_xfers = NULL;
> -        }
> +        vdagent_finalize_file_xfer();
>          break;
>      case VDAGENTD_AUDIO_VOLUME_SYNC: {
>          VDAgentAudioVolumeSync *avs = (VDAgentAudioVolumeSync *)data;
> @@ -185,9 +191,7 @@ static void daemon_read_complete(struct udscs_connection
> **connp,
>          break;
>      case VDAGENTD_CLIENT_DISCONNECTED:
>          vdagent_x11_client_disconnected(x11);
> -        if (vdagent_file_xfers != NULL) {
> -            vdagent_file_xfers_destroy(vdagent_file_xfers);
> -            vdagent_file_xfers = NULL;
> +        if (vdagent_finalize_file_xfer()) {
>              vdagent_init_file_xfer();
>          }
>          break;
> @@ -400,9 +404,7 @@ reconnect:
>          udscs_client_handle_fds(&client, &readfds, &writefds);
>      }
>  
> -    if (vdagent_file_xfers != NULL) {
> -        vdagent_file_xfers_destroy(vdagent_file_xfers);
> -    }
> +    vdagent_finalize_file_xfer();
>      vdagent_x11_destroy(x11, client == NULL);
>      udscs_destroy_connection(&client);
>      if (!quit && do_daemonize)
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]