mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
Don't cheat and unset the "pending" flag around inner calls. Instead, call
2007-11-30 Dan Winship <danw@gnome.org> * goutputstream.c: Don't cheat and unset the "pending" flag around inner calls. Instead, call the class method directly rather than the wrapper function that checks "pending" svn path=/trunk/; revision=6038
This commit is contained in:
committed by
Alexander Larsson
parent
0b89fa790a
commit
b22aa6dde6
@@ -1,3 +1,9 @@
|
||||
2007-11-30 Dan Winship <danw@gnome.org>
|
||||
|
||||
* goutputstream.c: Don't cheat and unset the "pending" flag around
|
||||
inner calls. Instead, call the class method directly rather than
|
||||
the wrapper function that checks "pending"
|
||||
|
||||
2007-12-03 Behdad Esfahbod <behdad@gnome.org>
|
||||
|
||||
* glib/gnulib/Makefile.am: Fix EXTRA_DIST automake warnings. (#501107)
|
||||
|
@@ -701,6 +701,7 @@ g_buffered_input_stream_skip (GInputStream *stream,
|
||||
{
|
||||
GBufferedInputStream *bstream;
|
||||
GBufferedInputStreamPrivate *priv;
|
||||
GBufferedInputStreamClass *class;
|
||||
GInputStream *base_stream;
|
||||
gsize available, bytes_skipped;
|
||||
gssize nread;
|
||||
@@ -748,9 +749,8 @@ g_buffered_input_stream_skip (GInputStream *stream,
|
||||
return bytes_skipped;
|
||||
}
|
||||
|
||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
||||
nread = g_buffered_input_stream_fill (bstream, priv->len, cancellable, error);
|
||||
g_input_stream_set_pending (stream, TRUE); /* enable again */
|
||||
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||
nread = class->fill (bstream, priv->len, cancellable, error);
|
||||
|
||||
if (nread < 0)
|
||||
{
|
||||
@@ -778,6 +778,7 @@ g_buffered_input_stream_read (GInputStream *stream,
|
||||
{
|
||||
GBufferedInputStream *bstream;
|
||||
GBufferedInputStreamPrivate *priv;
|
||||
GBufferedInputStreamClass *class;
|
||||
GInputStream *base_stream;
|
||||
gsize available, bytes_read;
|
||||
gssize nread;
|
||||
@@ -826,9 +827,8 @@ g_buffered_input_stream_read (GInputStream *stream,
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
||||
nread = g_buffered_input_stream_fill (bstream, priv->len, cancellable, error);
|
||||
g_input_stream_set_pending (stream, TRUE); /* enable again */
|
||||
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||
nread = class->fill (bstream, priv->len, cancellable, error);
|
||||
if (nread < 0)
|
||||
{
|
||||
if (bytes_read == 0)
|
||||
@@ -875,6 +875,7 @@ g_buffered_input_stream_read_byte (GBufferedInputStream *stream,
|
||||
GError **error)
|
||||
{
|
||||
GBufferedInputStreamPrivate *priv;
|
||||
GBufferedInputStreamClass *class;
|
||||
GInputStream *input_stream;
|
||||
gsize available;
|
||||
gssize nread;
|
||||
@@ -905,17 +906,22 @@ g_buffered_input_stream_read_byte (GBufferedInputStream *stream,
|
||||
|
||||
/* Byte not available, request refill for more */
|
||||
|
||||
g_input_stream_set_pending (input_stream, TRUE);
|
||||
|
||||
if (cancellable)
|
||||
g_push_current_cancellable (cancellable);
|
||||
|
||||
priv->pos = 0;
|
||||
priv->end = 0;
|
||||
|
||||
nread = g_buffered_input_stream_fill (stream, priv->len, cancellable, error);
|
||||
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||
nread = class->fill (stream, priv->len, cancellable, error);
|
||||
|
||||
if (cancellable)
|
||||
g_pop_current_cancellable (cancellable);
|
||||
|
||||
g_input_stream_set_pending (input_stream, FALSE);
|
||||
|
||||
if (nread <= 0)
|
||||
return -1; /* error or end of stream */
|
||||
|
||||
@@ -1069,8 +1075,6 @@ read_fill_buffer_callback (GObject *source_object,
|
||||
bstream = G_BUFFERED_INPUT_STREAM (source_object);
|
||||
priv = bstream->priv;
|
||||
|
||||
g_input_stream_set_pending (G_INPUT_STREAM (bstream), TRUE); /* enable again */
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
|
||||
error = NULL;
|
||||
@@ -1110,6 +1114,7 @@ g_buffered_input_stream_read_async (GInputStream *stream,
|
||||
{
|
||||
GBufferedInputStream *bstream;
|
||||
GBufferedInputStreamPrivate *priv;
|
||||
GBufferedInputStreamClass *class;
|
||||
GInputStream *base_stream;
|
||||
gsize available;
|
||||
GSimpleAsyncResult *simple;
|
||||
@@ -1166,10 +1171,9 @@ g_buffered_input_stream_read_async (GInputStream *stream,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
||||
g_buffered_input_stream_fill_async (bstream, priv->len,
|
||||
io_priority, cancellable,
|
||||
read_fill_buffer_callback, simple);
|
||||
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||
class->fill_async (bstream, priv->len, io_priority, cancellable,
|
||||
read_fill_buffer_callback, simple);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1249,8 +1253,6 @@ skip_fill_buffer_callback (GObject *source_object,
|
||||
bstream = G_BUFFERED_INPUT_STREAM (source_object);
|
||||
priv = bstream->priv;
|
||||
|
||||
g_input_stream_set_pending (G_INPUT_STREAM (bstream), TRUE); /* enable again */
|
||||
|
||||
data = g_simple_async_result_get_op_res_gpointer (simple);
|
||||
|
||||
error = NULL;
|
||||
@@ -1288,6 +1290,7 @@ g_buffered_input_stream_skip_async (GInputStream *stream,
|
||||
{
|
||||
GBufferedInputStream *bstream;
|
||||
GBufferedInputStreamPrivate *priv;
|
||||
GBufferedInputStreamClass *class;
|
||||
GInputStream *base_stream;
|
||||
gsize available;
|
||||
GSimpleAsyncResult *simple;
|
||||
@@ -1340,10 +1343,9 @@ g_buffered_input_stream_skip_async (GInputStream *stream,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
||||
g_buffered_input_stream_fill_async (bstream, priv->len,
|
||||
io_priority, cancellable,
|
||||
skip_fill_buffer_callback, simple);
|
||||
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||
class->fill_async (bstream, priv->len, io_priority, cancellable,
|
||||
skip_fill_buffer_callback, simple);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -423,11 +423,20 @@ g_output_stream_real_splice (GOutputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GOutputStreamClass *class = G_OUTPUT_STREAM_GET_CLASS (stream);
|
||||
gssize n_read, n_written;
|
||||
gssize bytes_copied;
|
||||
char buffer[8192], *p;
|
||||
gboolean res;
|
||||
|
||||
if (class->write == NULL)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
_("Output stream doesn't implement write"));
|
||||
res = FALSE;
|
||||
goto notsupported;
|
||||
}
|
||||
|
||||
bytes_copied = 0;
|
||||
res = TRUE;
|
||||
do
|
||||
@@ -445,9 +454,7 @@ g_output_stream_real_splice (GOutputStream *stream,
|
||||
p = buffer;
|
||||
while (n_read > 0)
|
||||
{
|
||||
stream->priv->pending = FALSE;
|
||||
n_written = g_output_stream_write (stream, p, n_read, cancellable, error);
|
||||
stream->priv->pending = TRUE;
|
||||
n_written = class->write (stream, p, n_read, cancellable, error);
|
||||
if (n_written == -1)
|
||||
{
|
||||
res = FALSE;
|
||||
@@ -461,6 +468,7 @@ g_output_stream_real_splice (GOutputStream *stream,
|
||||
}
|
||||
while (res);
|
||||
|
||||
notsupported:
|
||||
if (!res)
|
||||
error = NULL; /* Ignore further errors */
|
||||
|
||||
@@ -473,10 +481,8 @@ g_output_stream_real_splice (GOutputStream *stream,
|
||||
if (flags & G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_TARGET)
|
||||
{
|
||||
/* But write errors on close are bad! */
|
||||
stream->priv->pending = FALSE;
|
||||
if (!g_output_stream_close (stream, cancellable, error))
|
||||
if (!class->close (stream, cancellable, error))
|
||||
res = FALSE;
|
||||
stream->priv->pending = TRUE;
|
||||
}
|
||||
|
||||
if (res)
|
||||
@@ -546,13 +552,13 @@ g_output_stream_close (GOutputStream *stream,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
res = g_output_stream_flush (stream, cancellable, error);
|
||||
|
||||
stream->priv->pending = TRUE;
|
||||
|
||||
if (cancellable)
|
||||
g_push_current_cancellable (cancellable);
|
||||
|
||||
res = class->flush (stream, cancellable, error);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
/* flushing caused the error that we want to return,
|
||||
@@ -1202,14 +1208,11 @@ splice_async_thread (GSimpleAsyncResult *result,
|
||||
class = G_OUTPUT_STREAM_GET_CLASS (object);
|
||||
op = g_simple_async_result_get_op_res_gpointer (result);
|
||||
|
||||
stream->priv->pending = FALSE;
|
||||
op->bytes_copied =
|
||||
g_output_stream_splice (stream,
|
||||
op->source,
|
||||
op->flags,
|
||||
cancellable,
|
||||
&error);
|
||||
stream->priv->pending = TRUE;
|
||||
op->bytes_copied = class->splice (stream,
|
||||
op->source,
|
||||
op->flags,
|
||||
cancellable,
|
||||
&error);
|
||||
|
||||
if (op->bytes_copied == -1)
|
||||
{
|
||||
|
Reference in New Issue
Block a user