[Spice-devel] [PATCH v3 2/3] vdagent: move file xfer finalize to a function

Christophe Fergeau cfergeau at redhat.com
Mon May 29 11:31:42 UTC 2017


Acked-by: Christophe Fergeau <cfergeau at redhat.com>

On Thu, May 18, 2017 at 12:21:56PM +0200, Victor Toso wrote:
> From: Victor Toso <me at victortoso.com>
> 
> 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 at redhat.com>
> ---
>  src/vdagent/vdagent.c | 25 ++++++++++++++-----------
>  1 file changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
> index 03f8021..98cd659 100644
> --- a/src/vdagent/vdagent.c
> +++ b/src/vdagent/vdagent.c
> @@ -106,6 +106,16 @@ static bool vdagent_init_file_xfer(void)
>      return (vdagent_file_xfers != NULL);
>  }
>  
> +static bool vdagent_finalize_file_xfer(void)
> +{
> +    if (vdagent_file_xfers == NULL)
> +        return false;
> +
> +    vdagent_file_xfers_destroy(vdagent_file_xfers);
> +    vdagent_file_xfers = NULL;
> +    return true;
> +}
> +
>  static void daemon_read_complete(struct udscs_connection **connp,
>      struct udscs_message_header *header, uint8_t *data)
>  {
> @@ -157,10 +167,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;
> @@ -182,10 +189,8 @@ 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 = vdagent_file_xfers_create(client, fx_dir,
> -                                                           fx_open_dir, debug);
> +        if (vdagent_finalize_file_xfer()) {
> +            vdagent_init_file_xfer();
>          }
>          break;
>      default:
> @@ -397,9 +402,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)
> -- 
> 2.13.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170529/df66be91/attachment.sig>


More information about the Spice-devel mailing list