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 627071 - g_output_stream_write() clarification
g_output_stream_write() clarification
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-08-16 18:11 UTC by David Zeuthen (not reading bugmail)
Modified: 2010-08-16 19:39 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description David Zeuthen (not reading bugmail) 2010-08-16 18:11:16 UTC
Hi,

This patch guarantees that g_output_stream_write() can never fail with G_IO_ERROR_WOULD_BLOCK. Without such a guarantee, we would need some kind of GIOPollable interface or some way to get an event when the stream is writable again. Which is mostly useless considering that this method is asynchronous anyway.

Note: this patch just codifies existing behavior - GUnixOutputStream, GSocketOutputStream and other implementations already work this way.

See also bug 626748 comment 5 for how the GDBus code relies on this guarantee.

Thanks.

diff --git a/gio/goutputstream.c b/gio/goutputstream.c
index 1115599..c4c7502 100644
--- a/gio/goutputstream.c
+++ b/gio/goutputstream.c
@@ -673,6 +673,10 @@ async_ready_close_flushed_callback_wrapper (GObject      *s
  * requested size, as it can happen e.g. on a partial I/O error, 
  * but generally we try to write as many bytes as requested. 
  *
+ * You are guaranteed that this method will never fail with
+ * %G_IO_ERROR_WOULD_BLOCK - if no space is left in @stream, the
+ * method will just wait until space becomes available.
+ *
  * Any outstanding I/O request with higher priority (lower numerical 
  * value) will be executed before an outstanding request with lower 
  * priority. Default priority is %G_PRIORITY_DEFAULT.
Comment 1 Dan Winship 2010-08-16 18:14:12 UTC
(In reply to comment #0)
> + * You are guaranteed that this method will never fail with
> + * %G_IO_ERROR_WOULD_BLOCK - if no space is left in @stream, the
> + * method will just wait until space becomes available.

"no space is left" isn't necessarily the problem. I'd say something more generic like "if @stream can't accept more data".

But yeah, the clarification is good.
Comment 2 Alexander Larsson 2010-08-16 18:29:25 UTC
Yeah, this sounds good to me.
Comment 3 David Zeuthen (not reading bugmail) 2010-08-16 19:39:08 UTC
Committed, thanks!

http://git.gnome.org/browse/glib/commit/?id=b8e7ef6e90512999be0340a6ef3f20e1783647c4