* [Qemu-devel] [PATCH v2] io: fix handling of EOF / error conditions in websock GSource
@ 2019-03-07 16:58 Daniel P. Berrangé
[not found] ` <20190319112431.GI29713@redhat.com>
0 siblings, 1 reply; 2+ messages in thread
From: Daniel P. Berrangé @ 2019-03-07 16:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Philippe Mathieu-Daudé, Daniel P. Berrangé
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
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
Changed in v2:
- Fix typo
- Remove use of G_IO_IN at same time as HUP/ERR since. It is
not required since the websock source doesn't do a real
poll itself.
io/channel-websock.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/io/channel-websock.c b/io/channel-websock.c
index dc43dc6bb9..77d30f0e4a 100644
--- a/io/channel-websock.c
+++ b/io/channel-websock.c
@@ -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;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2] io: fix handling of EOF / error conditions in websock GSource
[not found] ` <20190319112431.GI29713@redhat.com>
@ 2019-04-01 7:55 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-04-01 7:55 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: QEMU Developers
On Tue, Mar 19, 2019 at 12:24 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> ping
>
> On Thu, Mar 07, 2019 at 04:58:24PM +0000, Daniel P. Berrangé wrote:
> > 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
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >
> > Changed in v2:
> > - Fix typo
> > - Remove use of G_IO_IN at same time as HUP/ERR since. It is
> > not required since the websock source doesn't do a real
> > poll itself.
> >
> > io/channel-websock.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/io/channel-websock.c b/io/channel-websock.c
> > index dc43dc6bb9..77d30f0e4a 100644
> > --- a/io/channel-websock.c
> > +++ b/io/channel-websock.c
> > @@ -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;
> > }
> > --
> > 2.20.1
> >
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-01 7:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 16:58 [Qemu-devel] [PATCH v2] io: fix handling of EOF / error conditions in websock GSource Daniel P. Berrangé
[not found] ` <20190319112431.GI29713@redhat.com>
2019-04-01 7:55 ` Philippe Mathieu-Daudé
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.