Skip to content

Commit

Permalink
io: fix handling of EOF / error conditions in websock GSource
Browse files Browse the repository at this point in the history
We were never reporting the G_IO_HUP event when an end of file was hit
on the websocket channel.

We also didn't report G_IO_ERR when we hit a fatal error processing the
websocket protocol.

The latter in particular meant that the chardev code would not notice
when an eof/error was encountered on the websocket channel, unless the
guest OS happened to trigger a write operation.

This meant that once the first client had quit, the chardev would never
listen to accept a new client.

Fixes launchpad bug 1816819
Acked-by: Stefano Garzarella <[email protected]>
Signed-off-by: Daniel P. Berrangé <[email protected]>
  • Loading branch information
berrange committed Mar 20, 2019
1 parent 62a172e commit dd154c4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion io/channel-websock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1225,12 +1225,18 @@ qio_channel_websock_source_check(GSource *source)
QIOChannelWebsockSource *wsource = (QIOChannelWebsockSource *)source;
GIOCondition cond = 0;

if (wsource->wioc->rawinput.offset || wsource->wioc->io_eof) {
if (wsource->wioc->rawinput.offset) {
cond |= G_IO_IN;
}
if (wsource->wioc->encoutput.offset < QIO_CHANNEL_WEBSOCK_MAX_BUFFER) {
cond |= G_IO_OUT;
}
if (wsource->wioc->io_eof) {
cond |= G_IO_HUP;
}
if (wsource->wioc->io_err) {
cond |= G_IO_ERR;
}

return cond & wsource->condition;
}
Expand Down

0 comments on commit dd154c4

Please sign in to comment.