After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 673997 - pollable stream additions
pollable stream additions
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-04-12 14:59 UTC by Dan Winship
Modified: 2012-04-17 16:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio: minor GPollableInputStream / GPollableOutputStream fixes (10.03 KB, patch)
2012-04-12 14:59 UTC, Dan Winship
committed Details | Review
gpollableutils: utility functions for pollable stream implementations (20.07 KB, patch)
2012-04-12 14:59 UTC, Dan Winship
committed Details | Review
gio: implement GPollableInput/OutputStream in more stream types (20.82 KB, patch)
2012-04-12 14:59 UTC, Dan Winship
committed Details | Review
gio: use GPollable* to implement fallback read_async/write_async (47.41 KB, patch)
2012-04-12 15:00 UTC, Dan Winship
committed Details | Review

Description Dan Winship 2012-04-12 14:59:51 UTC
This (in particular, making GConverterInputStream pollable) is needed
for some upcoming libsoup stuff. The last patch is also a nice general
cleanup.

(I thought about adding "skip_nonblocking" and "flush_nonblocking" to
GPollableInput/OutputStream, and likewise reimplementing skip_async
and flush_async on top of them when possible... ?)

Not totally sure about the naming of g_pollable_stream_read() /
g_pollable_stream_write(). Calling it "g_pollable_input_stream_read()"
seemed wrong, since the argument doesn't have to be a
GPollableInputStream. Maybe "g_input_stream_pollable_read()" would be
better? or "g_input_stream_read_with_blocking()" to match
"g_socket_receive_with_blocking()", but I never liked that name
anyway...

I'll add a test for the converter stream pollable implementations
before committing.
Comment 1 Dan Winship 2012-04-12 14:59:53 UTC
Created attachment 211937 [details] [review]
gio: minor GPollableInputStream / GPollableOutputStream fixes

Make g_pollable_input_stream_read() and
g_pollable_output_stream_write() look a little bit more like the
non-pollable versions in terms of error handling, etc. Also, use the
read_fn and write_fn virtual methods directly rather than calling
g_input_stream_read()/g_output_stream_write(), to avoid problems with
re-entrancy involving the "pending" flag.

Also belatedly add single-include guards to the header files.
Comment 2 Dan Winship 2012-04-12 14:59:56 UTC
Created attachment 211938 [details] [review]
gpollableutils: utility functions for pollable stream implementations

Move g_pollable_source_new() here from gpollableinputstream.c, add
g_pollable_source_new_full(), and add some new methods to do either
blocking or nonblocking reads depending on a boolean argument.
Comment 3 Dan Winship 2012-04-12 14:59:58 UTC
Created attachment 211939 [details] [review]
gio: implement GPollableInput/OutputStream in more stream types

Implement GPollableInputStream in GMemoryInputStream and
GConverterInputStream, and likewise implement GPollableOutputStream in
the corresponding output streams.
Comment 4 Dan Winship 2012-04-12 15:00:01 UTC
Created attachment 211940 [details] [review]
gio: use GPollable* to implement fallback read_async/write_async

If a GInputStream does not provide a read_async() implementation, but
does implement GPollableInputStream, then instead of doing
read-synchronously-in-a-thread, just use
g_pollable_input_stream_read_nonblocking() and
g_pollable_input_stream_create_source() to implement an async read in
the same thread. Similarly for GOutputStream.

Remove a bunch of existing read_async()/write_async() implementations
that are basically equivalent to the new fallback method.
Comment 5 Matthias Clasen 2012-04-14 03:06:40 UTC
Review of attachment 211938 [details] [review]:

::: gio/gpollableutils.h
@@ +54,3 @@
+				      gsize          *bytes_written,
+				      GCancellable   *cancellable,
+				      GError        **error);

G_AVAILABLE_IN_2_34 ?
Comment 6 Matthias Clasen 2012-04-14 03:07:28 UTC
Review of attachment 211937 [details] [review]:

looks fine to me
Comment 7 Matthias Clasen 2012-04-14 03:08:23 UTC
Review of attachment 211939 [details] [review]:

Looks ok to me
Comment 8 Matthias Clasen 2012-04-14 03:09:40 UTC
Review of attachment 211940 [details] [review]:

nice
Comment 9 Dan Winship 2012-04-17 16:34:15 UTC
pushed with GLIB_AVAILABLE_IN_2_34 and a GConverterInputStream
pollability test (and a fix for a pre-existing GConverterInputStream
bug that it uncovered)