[Spice-devel] server: Use g_get_monotonic_time() to get the time in microseconds

Fabiano FidĂȘncio fidencio at redhat.com
Sun Dec 6 04:35:24 PST 2015


On Sat, Dec 5, 2015 at 1:07 PM, Francois Gouget <fgouget at codeweavers.com> wrote:
> Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
> ---
>  server/main-channel.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/server/main-channel.c b/server/main-channel.c
> index 25e3868..75fea82 100644
> --- a/server/main-channel.c
> +++ b/server/main-channel.c
> @@ -372,14 +372,12 @@ static void main_channel_marshall_ping(RedChannelClient *rcc,
>                                         PingPipeItem *item)
>  {
>      MainChannelClient *mcc = SPICE_CONTAINEROF(rcc, MainChannelClient, base);
> -    struct timespec time_space;
>      SpiceMsgPing ping;
>      int size_left = item->size;
>
>      red_channel_client_init_send_data(rcc, SPICE_MSG_PING, &item->base);
>      ping.id = ++(mcc->ping_id);
> -    clock_gettime(CLOCK_MONOTONIC, &time_space);
> -    ping.timestamp = time_space.tv_sec * 1000000LL + time_space.tv_nsec / 1000LL;
> +    ping.timestamp = g_get_monotonic_time();
>      spice_marshall_msg_ping(m, &ping);
>
>      while (size_left > 0) {
> @@ -934,10 +932,8 @@ static int main_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint
>      case SPICE_MSGC_PONG: {
>          SpiceMsgPing *ping = (SpiceMsgPing *)message;
>          uint64_t roundtrip;
> -        struct timespec ts;
>
> -        clock_gettime(CLOCK_MONOTONIC, &ts);
> -        roundtrip = ts.tv_sec * 1000000LL + ts.tv_nsec / 1000LL - ping->timestamp;
> +        roundtrip = g_get_monotonic_time() - ping->timestamp;
>
>          if (ping->id == mcc->net_test_id) {
>              switch (mcc->net_test_stage) {
> --
> 2.6.2
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel

Acked-by: Fabiano FidĂȘncio <fidencio at redhat.com>


More information about the Spice-devel mailing list