[Spice-devel] [spice-gtk][PATCH v4] Added INFO messages about a file transfer

Fabiano Fidêncio fabiano at fidencio.org
Mon Oct 6 05:06:29 PDT 2014


On Thu, Sep 18, 2014 at 4:31 PM, Pavel Grunt <pgrunt at redhat.com> wrote:

> When a file transfer starts / finishes an information message is printed
> (in INFO log level).
> Also INFO messages about the transfer progress are periodically printed.
> ---
> changes since v4:
>   - logging is enabled when transferring more files simultaneously
>
>  gtk/channel-main.c | 42 +++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/gtk/channel-main.c b/gtk/channel-main.c
> index 1ad090f..1e0f940 100644
> --- a/gtk/channel-main.c
> +++ b/gtk/channel-main.c
> @@ -70,6 +70,8 @@ typedef struct SpiceFileXferTask {
>      char                           buffer[FILE_XFER_CHUNK_SIZE];
>      uint64_t                       read_bytes;
>      uint64_t                       file_size;
> +    GDateTime                      *start_time;
> +    GDateTime                      *last_update;
>      GError                         *error;
>  } SpiceFileXferTask;
>
> @@ -1529,15 +1531,31 @@ static void
> main_handle_agent_disconnected(SpiceChannel *channel, SpiceMsgIn *in
>  static void file_xfer_task_free(SpiceFileXferTask *task)
>  {
>      SpiceMainChannelPrivate *c;
> -
> +    gchar *basename;
> +    double seconds;
> +    GDateTime *now;
>      g_return_if_fail(task != NULL);
>
> +    if (task->read_bytes == task->file_size) {
> +        basename = g_file_get_basename(task->file);
> +        now = g_date_time_new_now_local();
> +        seconds = (double) g_date_time_difference(now, task->start_time)
> / G_TIME_SPAN_SECOND;
> +        g_date_time_unref(now);
> +        g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO,
> +              "transferred file %s of %.2f kB size in %.2f seconds (%.2f
> MB/s)",
> +              basename, task->file_size / 1000.0, seconds,
> +              (double) task->file_size / 1048576 / seconds);
>

What does "1048576" mean? If it's not something we already have defined in
glib, I'd go for a local define and a comment about the "1048576" value.

Best Regards,
-- 
Fabiano Fidêncio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141006/c32e747f/attachment-0001.html>


More information about the Spice-devel mailing list