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 707912 - g_io_stream_close() mishandles "pending"
g_io_stream_close() mishandles "pending"
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-09-11 13:46 UTC by Dan Winship
Modified: 2018-05-24 15:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Winship 2013-09-11 13:46:52 UTC
g_io_stream_close() calls g_io_stream_set_pending(), but the iostream-level pending flag is only used by g_io_stream_close() and g_io_stream_close_async(), so this has very little effect. In particular, you can close a GIOStream while simultaneously trying to perform an operation on its input or output streams (qv bug 707097, https://bugs.freedesktop.org/show_bug.cgi?id=64923), which most stream types don't actually handle correctly.

Fixing this is not completely trivial, since g_io_stream_close() can't just call g_input_stream_set_pending() and g_output_stream_set_pending(), since that would break any giostream close implementations that just called g_input_stream_close() and g_output_stream_close().

One fix would be to make the pending flags be properties, and have GIOStream watch the pending properties of its child streams, and mark the iostream pending whenever either child stream is pending.

However, the pending flags are frequently a pain in other situations where the implementation of one operation wants to call into another operation, so maybe a larger overhaul is in order. Eg, perhaps every GInputStream and GOutputStream method could have a "protected" _internal variant that assumed pending was already set, and then eg, g_input_stream_close() would be:

gboolean
g_input_stream_close (GInputStream  *stream,
		      GCancellable  *cancellable,
		      GError       **error)
{
  gboolean res;

  g_return_val_if_fail (G_IS_INPUT_STREAM (stream), FALSE);

  if (!g_input_stream_set_pending (stream, error))
    return FALSE;

  res = g_input_stream_close_internal (stream, cancellable, error);

  g_input_stream_clear_pending (stream);
  return res;
}

and g_local_file_io_stream_close() would then call g_input_stream_close_internal() and g_output_stream_close_internal() rather than the public versions.
Comment 1 Dan Winship 2014-02-05 10:17:44 UTC
*** Bug 723655 has been marked as a duplicate of this bug. ***
Comment 2 Mikhail Zabaluev 2014-02-05 21:52:13 UTC
Bug 723719 would need to be resolved before fixing this one causes a regression in gdbus.
Comment 3 GNOME Infrastructure Team 2018-05-24 15:40:53 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/756.