From 65b60250d0c0818eed30c59e70120ca40d72f33e Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Fri, 11 Dec 2015 12:21:34 +0100 Subject: [PATCH] server: Rename red_get_monotonic_time() to spice_get_monotonic_time_ns() This is a generic function not tied to the red_xxx functionality and the new name clarifies that it returns the time in nanoseconds (unlike g_get_monotonic_time()). Signed-off-by: Francois Gouget Acked-by: Frediano Ziglio --- server/dcc-send.c | 2 +- server/dcc.c | 4 ++-- server/display-channel.c | 8 ++++---- server/main-channel.c | 2 +- server/mjpeg-encoder.c | 6 +++--- server/red-channel.c | 20 ++++++++++---------- server/red-worker.c | 12 ++++++------ server/stream.c | 2 +- server/utils.h | 2 +- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/server/dcc-send.c b/server/dcc-send.c index 30303e77..a8f42db1 100644 --- a/server/dcc-send.c +++ b/server/dcc-send.c @@ -1689,7 +1689,7 @@ static int red_marshall_stream_data(RedChannelClient *rcc, } StreamAgent *agent = &dcc->stream_agents[get_stream_id(display, stream)]; - uint64_t time_now = red_get_monotonic_time(); + uint64_t time_now = spice_get_monotonic_time_ns(); size_t outbuf_size; if (!dcc->use_mjpeg_encoder_rate_control) { diff --git a/server/dcc.c b/server/dcc.c index a893ea48..f47cbec3 100644 --- a/server/dcc.c +++ b/server/dcc.c @@ -415,7 +415,7 @@ static void dcc_create_all_streams(DisplayChannelClient *dcc) static int display_channel_client_wait_for_init(DisplayChannelClient *dcc) { dcc->expect_init = TRUE; - uint64_t end_time = red_get_monotonic_time() + DISPLAY_CLIENT_TIMEOUT; + uint64_t end_time = spice_get_monotonic_time_ns() + DISPLAY_CLIENT_TIMEOUT; for (;;) { red_channel_client_receive(RED_CHANNEL_CLIENT(dcc)); if (!red_channel_client_is_connected(RED_CHANNEL_CLIENT(dcc))) { @@ -431,7 +431,7 @@ static int display_channel_client_wait_for_init(DisplayChannelClient *dcc) } return TRUE; } - if (red_get_monotonic_time() > end_time) { + if (spice_get_monotonic_time_ns() > end_time) { spice_warning("timeout"); red_channel_client_disconnect(RED_CHANNEL_CLIENT(dcc)); break; diff --git a/server/display-channel.c b/server/display-channel.c index 80d7335c..ec4ca10f 100644 --- a/server/display-channel.c +++ b/server/display-channel.c @@ -181,7 +181,7 @@ int display_channel_get_streams_timeout(DisplayChannel *display) Ring *ring = &display->streams; RingItem *item = ring; - red_time_t now = red_get_monotonic_time(); + red_time_t now = spice_get_monotonic_time_ns(); while ((item = ring_next(ring, item))) { Stream *stream; @@ -1187,7 +1187,7 @@ void display_channel_process_draw(DisplayChannel *display, RedDrawable *red_draw int display_channel_wait_for_migrate_data(DisplayChannel *display) { - uint64_t end_time = red_get_monotonic_time() + DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT; + uint64_t end_time = spice_get_monotonic_time_ns() + DISPLAY_CLIENT_MIGRATE_DATA_TIMEOUT; RedChannel *channel = &display->common.base; RedChannelClient *rcc; int ret = FALSE; @@ -1212,7 +1212,7 @@ int display_channel_wait_for_migrate_data(DisplayChannel *display) ret = TRUE; break; } - if (red_get_monotonic_time() > end_time) { + if (spice_get_monotonic_time_ns() > end_time) { spice_warning("timeout"); red_channel_client_disconnect(rcc); break; @@ -1371,7 +1371,7 @@ Drawable *display_channel_drawable_try_new(DisplayChannel *display, bzero(drawable, sizeof(Drawable)); drawable->refs = 1; - drawable->creation_time = drawable->first_frame_time = red_get_monotonic_time(); + drawable->creation_time = drawable->first_frame_time = spice_get_monotonic_time_ns(); ring_item_init(&drawable->list_link); ring_item_init(&drawable->surface_list_link); ring_item_init(&drawable->tree_item.base.siblings_link); diff --git a/server/main-channel.c b/server/main-channel.c index e74ba767..6cd2e596 100644 --- a/server/main-channel.c +++ b/server/main-channel.c @@ -588,7 +588,7 @@ static void main_channel_marshall_notify(RedChannelClient *rcc, SpiceMsgNotify notify; red_channel_client_init_send_data(rcc, SPICE_MSG_NOTIFY, &item->base); - notify.time_stamp = red_get_monotonic_time(); // TODO - move to main_new_notify_item + notify.time_stamp = spice_get_monotonic_time_ns(); // TODO - move to main_new_notify_item notify.severity = SPICE_NOTIFY_SEVERITY_WARN; notify.visibilty = SPICE_NOTIFY_VISIBILITY_HIGH; notify.what = SPICE_WARN_GENERAL; diff --git a/server/mjpeg-encoder.c b/server/mjpeg-encoder.c index 08af1eb9..9c51f7b6 100644 --- a/server/mjpeg-encoder.c +++ b/server/mjpeg-encoder.c @@ -716,7 +716,7 @@ static int mjpeg_encoder_start_frame(MJpegEncoder *encoder, uint64_t now; uint64_t interval; - now = red_get_monotonic_time(); + now = spice_get_monotonic_time_ns(); if (!rate_control->adjusted_fps_start_time) { rate_control->adjusted_fps_start_time = now; @@ -995,7 +995,7 @@ static void mjpeg_encoder_decrease_bit_rate(MJpegEncoder *encoder) if (rate_control->warmup_start_time) { uint64_t now; - now = red_get_monotonic_time(); + now = spice_get_monotonic_time_ns(); if (now - rate_control->warmup_start_time < MJPEG_WARMUP_TIME) { spice_debug("during warmup. ignoring"); return; @@ -1351,7 +1351,7 @@ MJpegEncoder *mjpeg_encoder_new(uint64_t starting_bit_rate, encoder->rate_control.during_quality_eval = TRUE; encoder->rate_control.quality_eval_data.type = MJPEG_QUALITY_EVAL_TYPE_SET; encoder->rate_control.quality_eval_data.reason = MJPEG_QUALITY_EVAL_REASON_RATE_CHANGE; - encoder->rate_control.warmup_start_time = red_get_monotonic_time(); + encoder->rate_control.warmup_start_time = spice_get_monotonic_time_ns(); } else { encoder->cbs.get_roundtrip_ms = NULL; mjpeg_encoder_reset_quality(encoder, MJPEG_LEGACY_STATIC_QUALITY_ID, MJPEG_MAX_FPS, 0); diff --git a/server/red-channel.c b/server/red-channel.c index 7dfb9bf6..361f1a56 100644 --- a/server/red-channel.c +++ b/server/red-channel.c @@ -553,7 +553,7 @@ static void red_channel_client_send_ping(RedChannelClient *rcc) red_channel_client_init_send_data(rcc, SPICE_MSG_PING, NULL); ping.id = rcc->latency_monitor.id; - ping.timestamp = red_get_monotonic_time(); + ping.timestamp = spice_get_monotonic_time_ns(); spice_marshall_msg_ping(rcc->send_data.marshaller, &ping); red_channel_client_begin_send_message(rcc); } @@ -1432,7 +1432,7 @@ static void red_channel_client_restart_ping_timer(RedChannelClient *rcc) { uint64_t passed, timeout; - passed = red_get_monotonic_time(); + passed = spice_get_monotonic_time_ns(); passed = passed - rcc->latency_monitor.last_pong_time; passed /= 1000*1000; timeout = PING_TEST_IDLE_NET_TIMEOUT_MS; @@ -1480,7 +1480,7 @@ static void red_channel_client_handle_pong(RedChannelClient *rcc, SpiceMsgPing * return; } - now = red_get_monotonic_time(); + now = spice_get_monotonic_time_ns(); if (rcc->latency_monitor.state == PING_STATE_WARMUP) { rcc->latency_monitor.state = PING_STATE_LATENCY; @@ -2318,7 +2318,7 @@ int red_channel_client_wait_outgoing_item(RedChannelClient *rcc, return TRUE; } if (timeout != -1) { - end_time = red_get_monotonic_time() + timeout; + end_time = spice_get_monotonic_time_ns() + timeout; } else { end_time = UINT64_MAX; } @@ -2329,7 +2329,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_get_monotonic_time() < end_time)); + (timeout == -1 || spice_get_monotonic_time_ns() < end_time)); if (blocked) { spice_warning("timeout"); @@ -2351,7 +2351,7 @@ int red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc, spice_info(NULL); if (timeout != -1) { - end_time = red_get_monotonic_time() + timeout; + end_time = spice_get_monotonic_time_ns() + timeout; } else { end_time = UINT64_MAX; } @@ -2365,7 +2365,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_get_monotonic_time() < end_time)) { + (timeout == -1 || spice_get_monotonic_time_ns() < end_time)) { usleep(CHANNEL_BLOCKED_SLEEP_DURATION); red_channel_client_receive(rcc); red_channel_client_send(rcc); @@ -2378,7 +2378,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_get_monotonic_time()); + timeout == -1 ? -1 : end_time - spice_get_monotonic_time_ns()); } } @@ -2390,7 +2390,7 @@ int red_channel_wait_all_sent(RedChannel *channel, int blocked = FALSE; if (timeout != -1) { - end_time = red_get_monotonic_time() + timeout; + end_time = spice_get_monotonic_time_ns() + timeout; } else { end_time = UINT64_MAX; } @@ -2398,7 +2398,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_get_monotonic_time() < end_time)) { + (timeout == -1 || spice_get_monotonic_time_ns() < end_time)) { spice_debug("pipe-size %u blocked %d", max_pipe_size, blocked); usleep(CHANNEL_BLOCKED_SLEEP_DURATION); red_channel_receive(channel); diff --git a/server/red-worker.c b/server/red-worker.c index baa84587..15e7d127 100644 --- a/server/red-worker.c +++ b/server/red-worker.c @@ -228,7 +228,7 @@ static int red_process_display(RedWorker *worker, uint32_t max_pipe_size, int *r { QXLCommandExt ext_cmd; int n = 0; - uint64_t start = red_get_monotonic_time(); + uint64_t start = spice_get_monotonic_time_ns(); if (!worker->running) { *ring_is_empty = TRUE; @@ -330,7 +330,7 @@ static int red_process_display(RedWorker *worker, uint32_t max_pipe_size, int *r n++; if ((worker->display_channel && red_channel_all_blocked(&worker->display_channel->common.base)) - || red_get_monotonic_time() - start > 10 * 1000 * 1000) { + || spice_get_monotonic_time_ns() - start > 10 * 1000 * 1000) { worker->event_timeout = 0; return n; } @@ -397,7 +397,7 @@ static void flush_display_commands(RedWorker *worker) if (ring_is_empty) { break; } - end_time = red_get_monotonic_time() + DISPLAY_CLIENT_TIMEOUT; + end_time = spice_get_monotonic_time_ns() + DISPLAY_CLIENT_TIMEOUT; int sleep_count = 0; for (;;) { red_channel_push(RED_CHANNEL(worker->display_channel)); @@ -410,7 +410,7 @@ static 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_get_monotonic_time() >= end_time) { + if (spice_get_monotonic_time_ns() >= end_time) { spice_warning("update timeout"); red_disconnect_all_display_TODO_remove_me(channel); } else { @@ -441,7 +441,7 @@ static void flush_cursor_commands(RedWorker *worker) if (ring_is_empty) { break; } - end_time = red_get_monotonic_time() + DISPLAY_CLIENT_TIMEOUT; + end_time = spice_get_monotonic_time_ns() + DISPLAY_CLIENT_TIMEOUT; int sleep_count = 0; for (;;) { red_channel_push(RED_CHANNEL(worker->cursor_channel)); @@ -452,7 +452,7 @@ static void flush_cursor_commands(RedWorker *worker) RedChannel *channel = (RedChannel *)worker->cursor_channel; red_channel_receive(channel); red_channel_send(channel); - if (red_get_monotonic_time() >= end_time) { + if (spice_get_monotonic_time_ns() >= end_time) { spice_warning("flush cursor timeout"); cursor_channel_disconnect(worker->cursor_channel); worker->cursor_channel = NULL; diff --git a/server/stream.c b/server/stream.c index b65d4306..ae702963 100644 --- a/server/stream.c +++ b/server/stream.c @@ -902,7 +902,7 @@ void stream_timeout(DisplayChannel *display) Ring *ring = &display->streams; RingItem *item; - red_time_t now = red_get_monotonic_time(); + red_time_t now = spice_get_monotonic_time_ns(); item = ring_get_head(ring); while (item) { Stream *stream = SPICE_CONTAINEROF(item, Stream, link); diff --git a/server/utils.h b/server/utils.h index d7b9e405..7c948805 100644 --- a/server/utils.h +++ b/server/utils.h @@ -51,7 +51,7 @@ static inline int test_bit(int index, uint32_t val) 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) +static inline red_time_t spice_get_monotonic_time_ns(void) { struct timespec time;