[Spice-devel] [spice-gtk v1 4/4] spice-channel: small rework on spice_channel_flush_wire()
Victor Toso
victortoso at redhat.com
Fri Feb 3 14:24:51 UTC 2017
From: Victor Toso <me at victortoso.com>
* Keeping compatibility with spice_channel_read_wire() where we keep
the possible context switch of g_coroutine_socket_wait() in the end
of loop and dealing with the return of the _flush_wire_nonblocking()
case by case.
Signed-off-by: Victor Toso <victortoso at redhat.com>
---
src/spice-channel.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/spice-channel.c b/src/spice-channel.c
index e3ff75c..310eb7b 100644
--- a/src/spice-channel.c
+++ b/src/spice-channel.c
@@ -832,26 +832,28 @@ static void spice_channel_flush_wire(SpiceChannel *channel,
while (offset < datalen) {
gssize ret;
- if (c->has_error) return;
+ if (c->has_error)
+ return;
ret = spice_channel_flush_wire_nonblocking(channel, ptr+offset, datalen-offset, &cond);
- if (ret == -1) {
- if (cond != 0) {
- // TODO: should use g_pollable_input/output_stream_create_source() in 2.28 ?
- g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
- continue;
- } else {
- CHANNEL_DEBUG(channel, "Closing the channel: spice_channel_flush %d", errno);
- c->has_error = TRUE;
- return;
- }
+ if (ret > 0) {
+ offset += ret;
+ continue;
}
+
if (ret == 0) {
CHANNEL_DEBUG(channel, "Closing the connection: spice_channel_flush");
c->has_error = TRUE;
return;
}
- offset += ret;
+
+ if (cond == 0) {
+ CHANNEL_DEBUG(channel, "Closing the channel: spice_channel_flush %d", errno);
+ c->has_error = TRUE;
+ return;
+ }
+ // TODO: should use g_pollable_input/output_stream_create_source() in 2.28 ?
+ g_coroutine_socket_wait(&c->coroutine, c->sock, cond);
}
}
--
2.9.3
More information about the Spice-devel
mailing list