reds-stream: Remove shutdown field

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/disconnecting) 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@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-09-11 09:27:25 +01:00
parent 12da078a9f
commit d9bb9abb9e
2 changed files with 6 additions and 7 deletions

View File

@ -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);

View File

@ -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;
};