[Spice-devel] [RFCv5 27/47] server/red_channel: add pipe_size helpers
Alon Levy
alevy at redhat.com
Sun May 8 06:11:23 PDT 2011
---
server/red_channel.c | 15 +++++++++++++++
server/red_channel.h | 7 +++++++
server/red_worker.c | 20 ++++++++++++--------
3 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/server/red_channel.c b/server/red_channel.c
index 01779c6..7f32c7c 100644
--- a/server/red_channel.c
+++ b/server/red_channel.c
@@ -1103,3 +1103,18 @@ void red_channel_pipes_new_add_tail(RedChannel *channel, new_pipe_item_t creator
red_channel_pipes_create_batch(channel, creator, data,
red_channel_client_pipe_add_tail_no_push);
}
+
+uint32_t red_channel_max_pipe_size(RedChannel *channel)
+{
+ return channel->rcc ? channel->rcc->pipe_size : 0;
+}
+
+uint32_t red_channel_min_pipe_size(RedChannel *channel)
+{
+ return channel->rcc ? channel->rcc->pipe_size : 0;
+}
+
+uint32_t red_channel_sum_pipes_size(RedChannel *channel)
+{
+ return channel->rcc ? channel->rcc->pipe_size : 0;
+}
diff --git a/server/red_channel.h b/server/red_channel.h
index a48d3a5..4b29b0c 100644
--- a/server/red_channel.h
+++ b/server/red_channel.h
@@ -365,6 +365,13 @@ RedClient *red_channel_client_get_client(RedChannelClient *rcc);
* not via the below accessor and direct header manipulation. */
SpiceDataHeader *red_channel_client_get_header(RedChannelClient *rcc);
+/* return the sum of all the rcc pipe size */
+uint32_t red_channel_max_pipe_size(RedChannel *channel);
+/* return the min size of all the rcc pipe */
+uint32_t red_channel_min_pipe_size(RedChannel *channel);
+/* return the max size of all the rcc pipe */
+uint32_t red_channel_sum_pipes_size(RedChannel *channel);
+
/* apply given function to all connected clients */
typedef void (*channel_client_callback)(RedChannelClient *rcc);
typedef void (*channel_client_callback_data)(RedChannelClient *rcc, void *data);
diff --git a/server/red_worker.c b/server/red_worker.c
index c2e1623..474e125 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4349,7 +4349,7 @@ static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ri
*ring_is_empty = FALSE;
while (!cursor_is_connected(worker) ||
- worker->cursor_channel->common.base.rcc->pipe_size <= max_pipe_size) {
+ red_channel_min_pipe_size(&worker->cursor_channel->common.base) <= max_pipe_size) {
if (!worker->qxl->st->qif->get_cursor_command(worker->qxl, &ext_cmd)) {
*ring_is_empty = TRUE;
if (worker->repoll_cursor_ring < CMD_RING_POLL_RETRIES) {
@@ -4387,10 +4387,10 @@ static int red_process_commands(RedWorker *worker, uint32_t max_pipe_size, int *
QXLCommandExt ext_cmd;
int n = 0;
uint64_t start = red_now();
-
+
*ring_is_empty = FALSE;
- while (!display_is_connected(worker)
- || worker->display_channel->common.base.rcc->pipe_size <= max_pipe_size) {
+ while (!display_is_connected(worker) ||
+ red_channel_min_pipe_size(&worker->display_channel->common.base) <= max_pipe_size) {
if (!worker->qxl->st->qif->get_command(worker->qxl, &ext_cmd)) {
*ring_is_empty = TRUE;;
if (worker->repoll_cmd_ring < CMD_RING_POLL_RETRIES) {
@@ -8707,6 +8707,8 @@ static void red_wait_outgoing_items(RedChannel *channel);
static inline void flush_display_commands(RedWorker *worker)
{
+ RedChannel *display_red_channel = &worker->display_channel->common.base;
+
for (;;) {
uint64_t end_time;
int ring_is_empty;
@@ -8728,7 +8730,7 @@ static inline void flush_display_commands(RedWorker *worker)
for (;;) {
red_channel_push(&worker->display_channel->common.base);
if (!display_is_connected(worker) ||
- worker->display_channel->common.base.rcc->pipe_size <= MAX_PIPE_SIZE) {
+ red_channel_min_pipe_size(display_red_channel) <= MAX_PIPE_SIZE) {
break;
}
RedChannel *channel = (RedChannel *)worker->display_channel;
@@ -8749,6 +8751,8 @@ static inline void flush_display_commands(RedWorker *worker)
static inline void flush_cursor_commands(RedWorker *worker)
{
+ RedChannel *cursor_red_channel = &worker->cursor_channel->common.base;
+
for (;;) {
uint64_t end_time;
int ring_is_empty = FALSE;
@@ -8770,7 +8774,7 @@ static inline void flush_cursor_commands(RedWorker *worker)
for (;;) {
red_channel_push(&worker->cursor_channel->common.base);
if (!cursor_is_connected(worker)
- || worker->cursor_channel->common.base.rcc->pipe_size <= MAX_PIPE_SIZE) {
+ || red_channel_min_pipe_size(cursor_red_channel) <= MAX_PIPE_SIZE) {
break;
}
RedChannel *channel = (RedChannel *)worker->cursor_channel;
@@ -10101,9 +10105,9 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
red_channel_push(&worker->display_channel->common.base);
}
if (worker->qxl->st->qif->flush_resources(worker->qxl) == 0) {
- red_printf("oom current %u pipe %u", worker->render.current_size,
+ red_printf("oom current %u pipes %u", worker->render.current_size,
worker->display_channel ?
- display_red_channel->rcc->pipe_size : 0);
+ red_channel_sum_pipes_size(display_red_channel) : 0);
red_free_some(worker);
worker->qxl->st->qif->flush_resources(worker->qxl);
}
--
1.7.5.1
More information about the Spice-devel
mailing list