[Spice-devel] [PATCH spice-server 03/10] reds-stream: Remove shutdown field
Frediano Ziglio
fziglio at redhat.com
Mon Sep 11 10:15:40 UTC 2017
This field was used only by RedChannelClient to mark when the
socket was shutdown. This condition can simply be tested by
RedChannelClient checking if there's a watch as is the only
condition (beside object destroying) where the watch is removed.
In any case the shutdown was used to understand if there were
possible data still to read.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
server/red-channel-client.c | 9 ++++++---
server/reds-stream.h | 4 ----
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/server/red-channel-client.c b/server/red-channel-client.c
index 35bb8d922..9a47b7e6f 100644
--- a/server/red-channel-client.c
+++ b/server/red-channel-client.c
@@ -1014,12 +1014,11 @@ void red_channel_client_destroy(RedChannelClient *rcc)
void red_channel_client_shutdown(RedChannelClient *rcc)
{
- if (rcc->priv->stream && !rcc->priv->stream->shutdown) {
+ if (rcc->priv->stream && rcc->priv->stream->watch) {
SpiceCoreInterfaceInternal *core = red_channel_get_core_interface(rcc->priv->channel);
core->watch_remove(core, rcc->priv->stream->watch);
rcc->priv->stream->watch = NULL;
shutdown(rcc->priv->stream->socket, SHUT_RDWR);
- rcc->priv->stream->shutdown = TRUE;
}
}
@@ -1110,7 +1109,11 @@ static int red_peer_receive(RedsStream *stream, uint8_t *buf, uint32_t size)
uint8_t *pos = buf;
while (size) {
int now;
- if (stream->shutdown) {
+ /* if we don't have a watch it means socket has been shutdown
+ * shutdown read doesn't work as accepted - receive may return data afterward.
+ * check the flag before calling receive
+ */
+ if (!stream->watch) {
return -1;
}
now = reds_stream_read(stream, pos, size);
diff --git a/server/reds-stream.h b/server/reds-stream.h
index 55a82745e..10ec50b38 100644
--- a/server/reds-stream.h
+++ b/server/reds-stream.h
@@ -34,10 +34,6 @@ struct RedsStream {
int socket;
SpiceWatch *watch;
- /* set it to TRUE if you shutdown the socket. shutdown read doesn't work as accepted -
- receive may return data afterward. check the flag before calling receive*/
- int shutdown;
-
RedsStreamPrivate *priv;
};
--
2.13.5
More information about the Spice-devel
mailing list