[Spice-devel] [PATCH spice-gtk] controller: async flush read/write

Marc-André Lureau mlureau at redhat.com
Tue Jul 3 05:24:46 PDT 2012


Hi

----- Mensaje original -----
> On 07/03/2012 04:41 AM, Marc-André Lureau wrote:
> > +		while (i<  length) {
> > +			var n = yield stream.write_async (buffer[i:length]);
> 
> Does stream.write_async throws exceptions on errors ?
> If not, then this code needs to handle errors (throw something).

It does throw exceptions, that are catched in the listen () method, logged as warning, and the client is then properly removed, while the listener continues waiting for connections (note that I realize that the current listener can only handle a single client, but that's something else)

Fwiw, since namedpipe are being used in other part of the code soon, if you do read and write simultaneously (most rpc do), it is really important to take the fix from https://bugzilla.gnome.org/show_bug.cgi?id=679288. And to try to "flush" the read/write like I did here (I do wonder if this should be handled by GIO somehow instead). Also, a namedpipe read() may return 0, which doesn't necessarily mean BROKEN_PIPE. If the write-side is weird, and does write(0), you can't know if it's broken or just a read of 0. Since there is no way to distinguish that atm, the only sane thing you can do is handle broken pipe (we may ask gio to also throw an error in this case to be able to distinguish, but that's an API change). beware! :)


More information about the Spice-devel mailing list