mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-27 15:45:54 +00:00
Replace now() with get_mononotonic_time()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
93414b23fa
commit
39b7e55ec7
@ -103,7 +103,6 @@ libspice_server_la_SOURCES = \
|
||||
red_replay_qxl.c \
|
||||
red_replay_qxl.h \
|
||||
red_parse_qxl.h \
|
||||
red_time.h \
|
||||
red_worker.c \
|
||||
red_worker.h \
|
||||
display-channel.h \
|
||||
|
||||
@ -21,8 +21,7 @@
|
||||
#include "red_worker.h"
|
||||
#include "cache-item.h"
|
||||
#include "pixmap-cache.h"
|
||||
|
||||
typedef int64_t red_time_t;
|
||||
#include "utils.h"
|
||||
|
||||
typedef struct Drawable Drawable;
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
#include "reds.h"
|
||||
#include "reds_stream.h"
|
||||
#include "main_dispatcher.h"
|
||||
#include "red_time.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef struct EmptyMsgPipeItem {
|
||||
PipeItem base;
|
||||
@ -2332,7 +2332,7 @@ int red_channel_client_wait_outgoing_item(RedChannelClient *rcc,
|
||||
return TRUE;
|
||||
}
|
||||
if (timeout != -1) {
|
||||
end_time = red_now() + timeout;
|
||||
end_time = red_get_monotonic_time() + timeout;
|
||||
} else {
|
||||
end_time = UINT64_MAX;
|
||||
}
|
||||
@ -2343,7 +2343,7 @@ int red_channel_client_wait_outgoing_item(RedChannelClient *rcc,
|
||||
red_channel_client_receive(rcc);
|
||||
red_channel_client_send(rcc);
|
||||
} while ((blocked = red_channel_client_blocked(rcc)) &&
|
||||
(timeout == -1 || red_now() < end_time));
|
||||
(timeout == -1 || red_get_monotonic_time() < end_time));
|
||||
|
||||
if (blocked) {
|
||||
spice_warning("timeout");
|
||||
@ -2365,7 +2365,7 @@ int red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc,
|
||||
spice_info(NULL);
|
||||
|
||||
if (timeout != -1) {
|
||||
end_time = red_now() + timeout;
|
||||
end_time = red_get_monotonic_time() + timeout;
|
||||
} else {
|
||||
end_time = UINT64_MAX;
|
||||
}
|
||||
@ -2379,7 +2379,7 @@ int red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc,
|
||||
red_channel_client_push(rcc);
|
||||
|
||||
while((item_in_pipe = ring_item_is_linked(&item->link)) &&
|
||||
(timeout == -1 || red_now() < end_time)) {
|
||||
(timeout == -1 || red_get_monotonic_time() < end_time)) {
|
||||
usleep(CHANNEL_BLOCKED_SLEEP_DURATION);
|
||||
red_channel_client_receive(rcc);
|
||||
red_channel_client_send(rcc);
|
||||
@ -2392,7 +2392,7 @@ int red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc,
|
||||
return FALSE;
|
||||
} else {
|
||||
return red_channel_client_wait_outgoing_item(rcc,
|
||||
timeout == -1 ? -1 : end_time - red_now());
|
||||
timeout == -1 ? -1 : end_time - red_get_monotonic_time());
|
||||
}
|
||||
}
|
||||
|
||||
@ -2404,7 +2404,7 @@ int red_channel_wait_all_sent(RedChannel *channel,
|
||||
int blocked = FALSE;
|
||||
|
||||
if (timeout != -1) {
|
||||
end_time = red_now() + timeout;
|
||||
end_time = red_get_monotonic_time() + timeout;
|
||||
} else {
|
||||
end_time = UINT64_MAX;
|
||||
}
|
||||
@ -2412,7 +2412,7 @@ int red_channel_wait_all_sent(RedChannel *channel,
|
||||
red_channel_push(channel);
|
||||
while (((max_pipe_size = red_channel_max_pipe_size(channel)) ||
|
||||
(blocked = red_channel_any_blocked(channel))) &&
|
||||
(timeout == -1 || red_now() < end_time)) {
|
||||
(timeout == -1 || red_get_monotonic_time() < end_time)) {
|
||||
spice_debug("pipe-size %u blocked %d", max_pipe_size, blocked);
|
||||
usleep(CHANNEL_BLOCKED_SLEEP_DURATION);
|
||||
red_channel_receive(channel);
|
||||
|
||||
@ -1,32 +0,0 @@
|
||||
/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||
/*
|
||||
Copyright (C) 2009-2015 Red Hat, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef H_RED_TIME
|
||||
#define H_RED_TIME
|
||||
|
||||
#include <time.h>
|
||||
|
||||
static inline uint64_t red_now(void)
|
||||
{
|
||||
struct timespec time;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
|
||||
return ((uint64_t) time.tv_sec) * 1000000000 + time.tv_nsec;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -89,13 +89,11 @@
|
||||
#include "spice_timer_queue.h"
|
||||
#include "main_dispatcher.h"
|
||||
#include "spice_server_utils.h"
|
||||
#include "red_time.h"
|
||||
#include "spice_bitmap_utils.h"
|
||||
#include "spice_image_cache.h"
|
||||
#include "pixmap-cache.h"
|
||||
#include "display-channel.h"
|
||||
#include "cursor-channel.h"
|
||||
#include "utils.h"
|
||||
|
||||
//#define COMPRESS_STAT
|
||||
//#define DUMP_BITMAP
|
||||
@ -4208,7 +4206,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
|
||||
{
|
||||
QXLCommandExt ext_cmd;
|
||||
int n = 0;
|
||||
uint64_t start = red_now();
|
||||
uint64_t start = red_get_monotonic_time();
|
||||
|
||||
if (!worker->running) {
|
||||
*ring_is_empty = TRUE;
|
||||
@ -4308,7 +4306,7 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
|
||||
n++;
|
||||
if ((worker->display_channel &&
|
||||
red_channel_all_blocked(&worker->display_channel->common.base))
|
||||
|| red_now() - start > 10 * 1000 * 1000) {
|
||||
|| red_get_monotonic_time() - start > 10 * 1000 * 1000) {
|
||||
worker->event_timeout = 0;
|
||||
return n;
|
||||
}
|
||||
@ -7806,7 +7804,7 @@ static inline int red_marshall_stream_data(RedChannelClient *rcc,
|
||||
}
|
||||
|
||||
StreamAgent *agent = &dcc->stream_agents[get_stream_id(worker, stream)];
|
||||
uint64_t time_now = red_now();
|
||||
uint64_t time_now = red_get_monotonic_time();
|
||||
size_t outbuf_size;
|
||||
|
||||
if (!dcc->use_mjpeg_encoder_rate_control) {
|
||||
@ -8841,7 +8839,7 @@ static inline void flush_display_commands(RedWorker *worker)
|
||||
if (ring_is_empty) {
|
||||
break;
|
||||
}
|
||||
end_time = red_now() + DISPLAY_CLIENT_TIMEOUT;
|
||||
end_time = red_get_monotonic_time() + DISPLAY_CLIENT_TIMEOUT;
|
||||
int sleep_count = 0;
|
||||
for (;;) {
|
||||
red_channel_push(&worker->display_channel->common.base);
|
||||
@ -8854,7 +8852,7 @@ static inline void flush_display_commands(RedWorker *worker)
|
||||
red_channel_send(channel);
|
||||
// TODO: MC: the whole timeout will break since it takes lowest timeout, should
|
||||
// do it client by client.
|
||||
if (red_now() >= end_time) {
|
||||
if (red_get_monotonic_time() >= end_time) {
|
||||
spice_warning("update timeout");
|
||||
red_disconnect_all_display_TODO_remove_me(channel);
|
||||
} else {
|
||||
@ -8885,7 +8883,7 @@ static inline void flush_cursor_commands(RedWorker *worker)
|
||||
if (ring_is_empty) {
|
||||
break;
|
||||
}
|
||||
end_time = red_now() + DISPLAY_CLIENT_TIMEOUT;
|
||||
end_time = red_get_monotonic_time() + DISPLAY_CLIENT_TIMEOUT;
|
||||
int sleep_count = 0;
|
||||
for (;;) {
|
||||
red_channel_push(&worker->cursor_channel->common.base);
|
||||
@ -8896,7 +8894,7 @@ static inline void flush_cursor_commands(RedWorker *worker)
|
||||
RedChannel *channel = (RedChannel *)worker->cursor_channel;
|
||||
red_channel_receive(channel);
|
||||
red_channel_send(channel);
|
||||
if (red_now() >= end_time) {
|
||||
if (red_get_monotonic_time() >= end_time) {
|
||||
spice_warning("flush cursor timeout");
|
||||
cursor_channel_disconnect(channel);
|
||||
worker->cursor_channel = NULL;
|
||||
@ -8930,7 +8928,7 @@ static void push_new_primary_surface(DisplayChannelClient *dcc)
|
||||
static int display_channel_client_wait_for_init(DisplayChannelClient *dcc)
|
||||
{
|
||||
dcc->expect_init = TRUE;
|
||||
uint64_t end_time = red_now() + DISPLAY_CLIENT_TIMEOUT;
|
||||
uint64_t end_time = red_get_monotonic_time() + DISPLAY_CLIENT_TIMEOUT;
|
||||
for (;;) {
|
||||
red_channel_client_receive(&dcc->common.base);
|
||||
if (!red_channel_client_is_connected(&dcc->common.base)) {
|
||||
@ -8946,7 +8944,7 @@ static int display_channel_client_wait_for_init(DisplayChannelClient *dcc)
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if (red_now() > end_time) {
|
||||
if (red_get_monotonic_time() > end_time) {
|
||||
spice_warning("timeout");
|
||||
red_channel_client_disconnect(&dcc->common.base);
|
||||
break;
|
||||
@ -10398,7 +10396,7 @@ void handle_dev_stop(void *opaque, void *payload)
|
||||
|
||||
static int display_channel_wait_for_migrate_data(DisplayChannel *display)
|
||||
{
|
||||
uint64_t end_time = red_now() + DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT;
|
||||
uint64_t end_time = red_get_monotonic_time() + DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT;
|
||||
RedChannel *channel = &display->common.base;
|
||||
RedChannelClient *rcc;
|
||||
|
||||
@ -10417,7 +10415,7 @@ static int display_channel_wait_for_migrate_data(DisplayChannel *display)
|
||||
if (!red_channel_client_waits_for_migrate_data(rcc)) {
|
||||
return TRUE;
|
||||
}
|
||||
if (red_now() > end_time) {
|
||||
if (red_get_monotonic_time() > end_time) {
|
||||
spice_warning("timeout");
|
||||
red_channel_client_disconnect(rcc);
|
||||
break;
|
||||
|
||||
@ -20,6 +20,8 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
typedef int64_t red_time_t;
|
||||
|
||||
/* FIXME: consider g_get_monotonic_time (), but in microseconds */
|
||||
static inline red_time_t red_get_monotonic_time(void)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user