summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2015-11-04 10:21:17 +0000
committerFrediano Ziglio <fziglio@redhat.com>2015-11-04 10:27:09 +0000
commitd8f89125fbcc61fd40517235cc85012076d87c51 (patch)
treefe25500e3fe099634c900e341e9ca12d5895c4ad
parentfae3f7a0627e47fdc4520715e92120a586d247a6 (diff)
downloadspice-d8f89125fbcc61fd40517235cc85012076d87c51.tar.gz
spice-d8f89125fbcc61fd40517235cc85012076d87c51.tar.xz
spice-d8f89125fbcc61fd40517235cc85012076d87c51.zip
Various changes in RedWorker and CursorChannel related to error and warning messages.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--server/cursor-channel.c28
-rw-r--r--server/red_worker.c17
-rw-r--r--server/red_worker.h1
3 files changed, 27 insertions, 19 deletions
diff --git a/server/cursor-channel.c b/server/cursor-channel.c
index ce360e12..5995aa5b 100644
--- a/server/cursor-channel.c
+++ b/server/cursor-channel.c
@@ -212,7 +212,8 @@ void cursor_channel_disconnect(CursorChannel *cursor_channel)
static void put_cursor_pipe_item(CursorChannelClient *ccc, CursorPipeItem *pipe_item)
{
- spice_assert(pipe_item);
+ spice_return_if_fail(pipe_item);
+ spice_return_if_fail(pipe_item->refs > 0);
if (--pipe_item->refs) {
return;
@@ -299,7 +300,7 @@ static void cursor_marshall(RedChannelClient *rcc,
PipeItem *pipe_item = &cursor_pipe_item->base;
RedCursorCmd *cmd;
- spice_assert(cursor_channel);
+ spice_return_if_fail(cursor_channel);
cmd = item->red_cursor;
switch (cmd->type) {
@@ -387,7 +388,9 @@ static void cursor_channel_send_item(RedChannelClient *rcc, PipeItem *pipe_item)
static CursorPipeItem *cursor_pipe_item_ref(CursorPipeItem *item)
{
- spice_assert(item);
+ spice_return_val_if_fail(item, NULL);
+ spice_return_val_if_fail(item->refs > 0, NULL);
+
item->refs++;
return item;
}
@@ -396,7 +399,9 @@ static CursorPipeItem *cursor_pipe_item_ref(CursorPipeItem *item)
static void cursor_channel_hold_pipe_item(RedChannelClient *rcc, PipeItem *item)
{
CursorPipeItem *cursor_pipe_item;
- spice_assert(item);
+
+ spice_return_if_fail(item);
+
cursor_pipe_item = SPICE_CONTAINEROF(item, CursorPipeItem, base);
cursor_pipe_item_ref(cursor_pipe_item);
}
@@ -454,6 +459,12 @@ CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor, RedClient
uint32_t *common_caps, int num_common_caps,
uint32_t *caps, int num_caps)
{
+ spice_return_val_if_fail(cursor, NULL);
+ spice_return_val_if_fail(client, NULL);
+ spice_return_val_if_fail(stream, NULL);
+ spice_return_val_if_fail(!num_common_caps || common_caps, NULL);
+ spice_return_val_if_fail(!num_caps || caps, NULL);
+
CursorChannelClient *ccc =
(CursorChannelClient*)common_channel_new_client(&cursor->common,
sizeof(CursorChannelClient),
@@ -464,11 +475,11 @@ CursorChannelClient* cursor_channel_client_new(CursorChannel *cursor, RedClient
num_common_caps,
caps,
num_caps);
- if (!ccc) {
- return NULL;
- }
+ spice_return_val_if_fail(ccc != NULL, NULL);
+
ring_init(&ccc->cursor_cache_lru);
ccc->cursor_cache_available = CLIENT_CURSOR_CACHE_SIZE;
+
return ccc;
}
@@ -502,7 +513,8 @@ void cursor_channel_process_cmd(CursorChannel *cursor, RedCursorCmd *cursor_cmd,
cursor->cursor_trail_frequency = cursor_cmd->u.trail.frequency;
break;
default:
- spice_error("invalid cursor command %u", cursor_cmd->type);
+ spice_warning("invalid cursor command %u", cursor_cmd->type);
+ return;
}
if (red_channel_is_connected(&cursor->common.base) &&
diff --git a/server/red_worker.c b/server/red_worker.c
index d8f8c304..906b6ab0 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -3925,7 +3925,7 @@ static int red_process_cursor(RedWorker *worker, uint32_t max_pipe_size, int *ri
break;
}
default:
- spice_error("bad command type");
+ spice_warning("bad command type");
}
n++;
}
@@ -9368,19 +9368,15 @@ static void red_connect_cursor(RedWorker *worker, RedClient *client, RedsStream
CursorChannel *channel;
CursorChannelClient *ccc;
- if (worker->cursor_channel == NULL) {
- spice_warning("cursor channel was not created");
- return;
- }
+ spice_return_if_fail(worker->cursor_channel != NULL);
+
channel = worker->cursor_channel;
spice_info("add cursor channel client");
ccc = cursor_channel_client_new(channel, client, stream,
migrate,
common_caps, num_common_caps,
caps, num_caps);
- if (!ccc) {
- return;
- }
+ spice_return_if_fail(ccc != NULL);
RedChannelClient *rcc = RED_CHANNEL_CLIENT(ccc);
red_channel_client_ack_zero_messages_window(rcc);
@@ -10048,9 +10044,10 @@ void handle_dev_cursor_channel_create(void *opaque, void *payload)
RedWorker *worker = opaque;
RedChannel *red_channel;
- // TODO: handle seemless migration. Temp, setting migrate to FALSE
if (!worker->cursor_channel) {
worker->cursor_channel = cursor_channel_new(worker);
+ } else {
+ spice_warning("cursor channel already created");
}
red_channel = RED_CHANNEL(worker->cursor_channel);
@@ -10079,7 +10076,7 @@ void handle_dev_cursor_disconnect(void *opaque, void *payload)
RedChannelClient *rcc = msg->rcc;
spice_info("disconnect cursor client");
- spice_assert(rcc);
+ spice_return_if_fail(rcc);
red_channel_client_disconnect(rcc);
}
diff --git a/server/red_worker.h b/server/red_worker.h
index d7a94fdf..33dd9748 100644
--- a/server/red_worker.h
+++ b/server/red_worker.h
@@ -66,7 +66,6 @@ typedef struct VerbItem {
static inline void red_marshall_verb(RedChannelClient *rcc, VerbItem *item)
{
- spice_assert(rcc);
red_channel_client_init_send_data(rcc, item->verb, NULL);
}