[Spice-commits] 3 commits - gtk/channel-main.c gtk/spice-channel.c tests/util.c
Christophe Fergau
teuf at kemper.freedesktop.org
Thu Sep 18 04:28:49 PDT 2014
gtk/channel-main.c | 53 +++++++++++++++++++++++++---------------------------
gtk/spice-channel.c | 17 +++++++++++-----
tests/util.c | 11 +++++-----
3 files changed, 44 insertions(+), 37 deletions(-)
New commits:
commit 9cd267a9db91aee10459a4a2bbb984663b03dd9e
Author: Christophe Fergeau <cfergeau at redhat.com>
Date: Wed Sep 10 15:50:53 2014 +0200
Don't report IO error on clean guest shutdown
Since commit 9cf9ca434, spice_channel_iterate() will report a
SPICE_CHANNEL_ERROR_IO error to library users when
SpiceChannel::has_error is set. In particular, when the server side
closes its SPICE sockets because the VM is being shut down, an IO error
will get reported. Prior to this change, a channel-closed event was
reported on graceful VM shutdowns as there was
a g_socket_condition_check() guarding the emission of the IO error
signal.
This commit readds the g_socket_condition_check() test, but only when
SpiceChannel::has_error is set.
This fixes https://bugs.freedesktop.org/show_bug.cgi?id=83692
diff --git a/gtk/spice-channel.c b/gtk/spice-channel.c
index e875963..5d1a86e 100644
--- a/gtk/spice-channel.c
+++ b/gtk/spice-channel.c
@@ -2117,11 +2117,18 @@ static gboolean spice_channel_iterate(SpiceChannel *channel)
SPICE_CHANNEL_GET_CLASS(channel)->iterate_read(channel);
if (c->has_error) {
- CHANNEL_DEBUG(channel, "channel got error");
- if (c->state > SPICE_CHANNEL_STATE_CONNECTING)
- g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0,
- c->state == SPICE_CHANNEL_STATE_READY ?
- SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
+ GIOCondition ret;
+ /* We don't want to report an error if the socket was closed gracefully
+ * on the other end (VM shutdown) */
+ ret = g_socket_condition_check(c->sock, G_IO_IN | G_IO_ERR | G_IO_HUP);
+ if (ret & (G_IO_ERR|G_IO_HUP)) {
+ CHANNEL_DEBUG(channel, "channel got error");
+ if (c->state > SPICE_CHANNEL_STATE_CONNECTING) {
+ g_coroutine_signal_emit(channel, signals[SPICE_CHANNEL_EVENT], 0,
+ c->state == SPICE_CHANNEL_STATE_READY ?
+ SPICE_CHANNEL_ERROR_IO : SPICE_CHANNEL_ERROR_LINK);
+ }
+ }
return FALSE;
}
commit 457d556c00c59bdb44476d1154b876652788d05f
Author: Pavel Grunt <pavel.grunt at gmail.com>
Date: Thu Sep 4 15:33:16 2014 +0200
Fix -Wsign-compare
diff --git a/tests/util.c b/tests/util.c
index e090f5c..b9b9535 100644
--- a/tests/util.c
+++ b/tests/util.c
@@ -36,7 +36,7 @@ static void test_dos2unix(void)
{
GError *err = NULL;
gchar *tmp;
- int i;
+ unsigned int i;
for (i = 0; i < G_N_ELEMENTS(dosunix); i++) {
if (!(dosunix[i].flags & DOS2UNIX))
@@ -59,7 +59,7 @@ static void test_unix2dos(void)
{
GError *err = NULL;
gchar *tmp;
- int i;
+ unsigned int i;
for (i = 0; i < G_N_ELEMENTS(dosunix); i++) {
if (!(dosunix[i].flags & UNIX2DOS))
@@ -137,9 +137,9 @@ static void test_set_bit(void)
"\xf7\x31",
}
};
- int i, j, bit;
+ unsigned int i, j, bit;
guint8 *dest;
- int bytes;
+ unsigned int bytes;
for (i = 0 ; i < G_N_ELEMENTS(tests); ++i) {
bytes = (tests[i].len + 7) / 8;
@@ -158,7 +158,8 @@ static void test_set_bit(void)
static void test_mono_edge_highlight(void)
{
- int i, j, bit;
+ unsigned int i;
+ int j, bit;
guint8 *and;
guint8 *xor;
guint8 *dest;
commit 18fc36c0542db120d78bd5a4a4c4d89b44607f5d
Author: Fabiano Fidêncio <fidencio at redhat.com>
Date: Thu Aug 28 10:46:14 2014 +0200
channel-main: allow transferring multiple files at once
Allow to drag and drop, from host to guest, more than one file at the
same time.
diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 021fa83..1ad090f 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
@@ -2729,7 +2729,7 @@ static void file_xfer_read_async_cb(GObject *obj, GAsyncResult *res, gpointer da
}
static void file_xfer_send_start_msg_async(SpiceMainChannel *channel,
- GFile *file,
+ GFile **files,
GFileCopyFlags flags,
GCancellable *cancellable,
GFileProgressCallback progress_callback,
@@ -2740,27 +2740,30 @@ static void file_xfer_send_start_msg_async(SpiceMainChannel *channel,
SpiceMainChannelPrivate *c = channel->priv;
SpiceFileXferTask *task;
static uint32_t xfer_id; /* Used to identify task id */
+ gint i;
- task = g_malloc0(sizeof(SpiceFileXferTask));
- task->id = ++xfer_id;
- task->channel = g_object_ref(channel);
- task->file = g_object_ref(file);
- task->flags = flags;
- task->cancellable = cancellable;
- task->progress_callback = progress_callback;
- task->progress_callback_data = progress_callback_data;
- task->callback = callback;
- task->user_data = user_data;
-
- CHANNEL_DEBUG(task->channel, "Insert a xfer task:%d to task list", task->id);
- g_hash_table_insert(c->file_xfer_tasks, GUINT_TO_POINTER(task->id), task);
-
- g_file_read_async(file,
- G_PRIORITY_DEFAULT,
- cancellable,
- file_xfer_read_async_cb,
- task);
- task->pending = TRUE;
+ for (i = 0; files[i] != NULL && !g_cancellable_is_cancelled(cancellable); i++) {
+ task = g_malloc0(sizeof(SpiceFileXferTask));
+ task->id = ++xfer_id;
+ task->channel = g_object_ref(channel);
+ task->file = g_object_ref(files[i]);
+ task->flags = flags;
+ task->cancellable = cancellable;
+ task->progress_callback = progress_callback;
+ task->progress_callback_data = progress_callback_data;
+ task->callback = callback;
+ task->user_data = user_data;
+
+ CHANNEL_DEBUG(task->channel, "Insert a xfer task:%d to task list", task->id);
+ g_hash_table_insert(c->file_xfer_tasks, GUINT_TO_POINTER(task->id), task);
+
+ g_file_read_async(files[i],
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ file_xfer_read_async_cb,
+ task);
+ task->pending = TRUE;
+ }
}
/**
@@ -2803,11 +2806,7 @@ void spice_main_file_copy_async(SpiceMainChannel *channel,
g_return_if_fail(channel != NULL);
g_return_if_fail(SPICE_IS_MAIN_CHANNEL(channel));
- g_return_if_fail(sources != NULL && sources[0] != NULL);
-
- /* At the moment, the copy() method is limited to a single file,
- support for copying multi-files will be implemented later. */
- g_return_if_fail(sources[1] == NULL);
+ g_return_if_fail(sources != NULL);
if (!c->agent_connected) {
g_simple_async_report_error_in_idle(G_OBJECT(channel),
@@ -2820,7 +2819,7 @@ void spice_main_file_copy_async(SpiceMainChannel *channel,
}
file_xfer_send_start_msg_async(channel,
- sources[0],
+ sources,
flags,
cancellable,
progress_callback,
More information about the Spice-commits
mailing list