From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1yVu-0007Lm-Qh for qemu-devel@nongnu.org; Tue, 01 Jul 2014 09:54:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1yVo-0006jk-93 for qemu-devel@nongnu.org; Tue, 01 Jul 2014 09:54:26 -0400 Received: from smtp.ispras.ru ([83.149.199.79]:51221) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1yVo-0006jd-10 for qemu-devel@nongnu.org; Tue, 01 Jul 2014 09:54:20 -0400 Date: Tue, 1 Jul 2014 17:54:18 +0400 (MSK) From: Kirill Batuzov In-Reply-To: <87ionhp5ku.fsf@linaro.org> Message-ID: References: <20140527120423.15172.36698.stgit@3820> <1404215552-12962-1-git-send-email-batuzovk@ispras.ru> <87ionhp5ku.fsf@linaro.org> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323329-1738445481-1404222858=:4254" Subject: Re: [Qemu-devel] [PATCH] Handle G_IO_HUP in tcp_chr_read for tcp chardev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Alex_Benn=E9e?= Cc: Antonios Motakis , Nikita Belov , qemu-devel@nongnu.org, Nikolay Nikolaev , "Michael S. Tsirkin" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-1738445481-1404222858=:4254 Content-Type: TEXT/PLAIN; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Tue, 1 Jul 2014, Alex Benn=C3=A9e wrote: >=20 > Kirill Batuzov writes: >=20 > > Due to GLib limitations it is not possible to create several watches = on one > > channel on Windows hosts. See bug #338943 in GNOME bugzilla for detai= ls: > > https://bugzilla.gnome.org/show_bug.cgi?id=3D338943 > > > > Handle G_IO_HUP in tcp_chr_read. It is already watched by correspondi= ng watch. > > Also remove the second watch with its handler. > > > > This reverts commit cdaa86a54b232572bba594bf87a7416e527e460c. > > ("Add G_IO_HUP handler for socket chardev") but keeps its functionali= ty. > > > --- a/qemu-char.c > > +++ b/qemu-char.c > > @@ -2673,6 +2673,12 @@ static gboolean tcp_chr_read(GIOChannel *chan,= GIOCondition cond, void *opaque) > > uint8_t buf[READ_BUF_LEN]; > > int len, size; > > =20 > > + if (cond & G_IO_HUP) { > > + /* connection closed */ > > + tcp_chr_disconnect(chr); > > + return TRUE; > > + } >=20 > Is this right. AIUI we could return FALSE here to remove the watch for > the now closed channel. >=20 > tcp_chr_disconnect will remove the watch and perform other non-obvious cleanup. Also we already have tcp_chr_disconnect followed by return TRUE in tcp_chr_read: size =3D tcp_chr_recv(chr, (void *)buf, len); if (size =3D=3D 0) { /* connection closed */ tcp_chr_disconnect(chr); } else if (size > 0) { /* ... */ } return TRUE; Actually I'm not sure that tcp_chr_read handles all corner cases correctly. For eaxmple, should not it be "size <=3D 0" instead of "size =3D=3D 0" in the above code? tcp_chr_recv may return negative value= on error. Should not tcp_chr_recv handle G_IO_ERR condition? It is watched in corresponding watch. But since we are in soft-freeze before 2.1 I decided to keep the patch as simple as possible and not to fix theoretical bugs for which I do not have real examples. --=20 Kirill --8323329-1738445481-1404222858=:4254--