mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +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>
|
2007-12-03 Behdad Esfahbod <behdad@gnome.org>
|
||||||
|
|
||||||
* glib/gnulib/Makefile.am: Fix EXTRA_DIST automake warnings. (#501107)
|
* glib/gnulib/Makefile.am: Fix EXTRA_DIST automake warnings. (#501107)
|
||||||
|
@@ -701,6 +701,7 @@ g_buffered_input_stream_skip (GInputStream *stream,
|
|||||||
{
|
{
|
||||||
GBufferedInputStream *bstream;
|
GBufferedInputStream *bstream;
|
||||||
GBufferedInputStreamPrivate *priv;
|
GBufferedInputStreamPrivate *priv;
|
||||||
|
GBufferedInputStreamClass *class;
|
||||||
GInputStream *base_stream;
|
GInputStream *base_stream;
|
||||||
gsize available, bytes_skipped;
|
gsize available, bytes_skipped;
|
||||||
gssize nread;
|
gssize nread;
|
||||||
@@ -748,9 +749,8 @@ g_buffered_input_stream_skip (GInputStream *stream,
|
|||||||
return bytes_skipped;
|
return bytes_skipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||||
nread = g_buffered_input_stream_fill (bstream, priv->len, cancellable, error);
|
nread = class->fill (bstream, priv->len, cancellable, error);
|
||||||
g_input_stream_set_pending (stream, TRUE); /* enable again */
|
|
||||||
|
|
||||||
if (nread < 0)
|
if (nread < 0)
|
||||||
{
|
{
|
||||||
@@ -778,6 +778,7 @@ g_buffered_input_stream_read (GInputStream *stream,
|
|||||||
{
|
{
|
||||||
GBufferedInputStream *bstream;
|
GBufferedInputStream *bstream;
|
||||||
GBufferedInputStreamPrivate *priv;
|
GBufferedInputStreamPrivate *priv;
|
||||||
|
GBufferedInputStreamClass *class;
|
||||||
GInputStream *base_stream;
|
GInputStream *base_stream;
|
||||||
gsize available, bytes_read;
|
gsize available, bytes_read;
|
||||||
gssize nread;
|
gssize nread;
|
||||||
@@ -826,9 +827,8 @@ g_buffered_input_stream_read (GInputStream *stream,
|
|||||||
return bytes_read;
|
return bytes_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||||
nread = g_buffered_input_stream_fill (bstream, priv->len, cancellable, error);
|
nread = class->fill (bstream, priv->len, cancellable, error);
|
||||||
g_input_stream_set_pending (stream, TRUE); /* enable again */
|
|
||||||
if (nread < 0)
|
if (nread < 0)
|
||||||
{
|
{
|
||||||
if (bytes_read == 0)
|
if (bytes_read == 0)
|
||||||
@@ -875,6 +875,7 @@ g_buffered_input_stream_read_byte (GBufferedInputStream *stream,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GBufferedInputStreamPrivate *priv;
|
GBufferedInputStreamPrivate *priv;
|
||||||
|
GBufferedInputStreamClass *class;
|
||||||
GInputStream *input_stream;
|
GInputStream *input_stream;
|
||||||
gsize available;
|
gsize available;
|
||||||
gssize nread;
|
gssize nread;
|
||||||
@@ -905,17 +906,22 @@ g_buffered_input_stream_read_byte (GBufferedInputStream *stream,
|
|||||||
|
|
||||||
/* Byte not available, request refill for more */
|
/* Byte not available, request refill for more */
|
||||||
|
|
||||||
|
g_input_stream_set_pending (input_stream, TRUE);
|
||||||
|
|
||||||
if (cancellable)
|
if (cancellable)
|
||||||
g_push_current_cancellable (cancellable);
|
g_push_current_cancellable (cancellable);
|
||||||
|
|
||||||
priv->pos = 0;
|
priv->pos = 0;
|
||||||
priv->end = 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)
|
if (cancellable)
|
||||||
g_pop_current_cancellable (cancellable);
|
g_pop_current_cancellable (cancellable);
|
||||||
|
|
||||||
|
g_input_stream_set_pending (input_stream, FALSE);
|
||||||
|
|
||||||
if (nread <= 0)
|
if (nread <= 0)
|
||||||
return -1; /* error or end of stream */
|
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);
|
bstream = G_BUFFERED_INPUT_STREAM (source_object);
|
||||||
priv = bstream->priv;
|
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);
|
data = g_simple_async_result_get_op_res_gpointer (simple);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
@@ -1110,6 +1114,7 @@ g_buffered_input_stream_read_async (GInputStream *stream,
|
|||||||
{
|
{
|
||||||
GBufferedInputStream *bstream;
|
GBufferedInputStream *bstream;
|
||||||
GBufferedInputStreamPrivate *priv;
|
GBufferedInputStreamPrivate *priv;
|
||||||
|
GBufferedInputStreamClass *class;
|
||||||
GInputStream *base_stream;
|
GInputStream *base_stream;
|
||||||
gsize available;
|
gsize available;
|
||||||
GSimpleAsyncResult *simple;
|
GSimpleAsyncResult *simple;
|
||||||
@@ -1166,10 +1171,9 @@ g_buffered_input_stream_read_async (GInputStream *stream,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||||
g_buffered_input_stream_fill_async (bstream, priv->len,
|
class->fill_async (bstream, priv->len, io_priority, cancellable,
|
||||||
io_priority, cancellable,
|
read_fill_buffer_callback, simple);
|
||||||
read_fill_buffer_callback, simple);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1249,8 +1253,6 @@ skip_fill_buffer_callback (GObject *source_object,
|
|||||||
bstream = G_BUFFERED_INPUT_STREAM (source_object);
|
bstream = G_BUFFERED_INPUT_STREAM (source_object);
|
||||||
priv = bstream->priv;
|
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);
|
data = g_simple_async_result_get_op_res_gpointer (simple);
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
@@ -1288,6 +1290,7 @@ g_buffered_input_stream_skip_async (GInputStream *stream,
|
|||||||
{
|
{
|
||||||
GBufferedInputStream *bstream;
|
GBufferedInputStream *bstream;
|
||||||
GBufferedInputStreamPrivate *priv;
|
GBufferedInputStreamPrivate *priv;
|
||||||
|
GBufferedInputStreamClass *class;
|
||||||
GInputStream *base_stream;
|
GInputStream *base_stream;
|
||||||
gsize available;
|
gsize available;
|
||||||
GSimpleAsyncResult *simple;
|
GSimpleAsyncResult *simple;
|
||||||
@@ -1340,10 +1343,9 @@ g_buffered_input_stream_skip_async (GInputStream *stream,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_input_stream_set_pending (stream, FALSE); /* to avoid already pending error */
|
class = G_BUFFERED_INPUT_STREAM_GET_CLASS (stream);
|
||||||
g_buffered_input_stream_fill_async (bstream, priv->len,
|
class->fill_async (bstream, priv->len, io_priority, cancellable,
|
||||||
io_priority, cancellable,
|
skip_fill_buffer_callback, simple);
|
||||||
skip_fill_buffer_callback, simple);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -423,11 +423,20 @@ g_output_stream_real_splice (GOutputStream *stream,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
GOutputStreamClass *class = G_OUTPUT_STREAM_GET_CLASS (stream);
|
||||||
gssize n_read, n_written;
|
gssize n_read, n_written;
|
||||||
gssize bytes_copied;
|
gssize bytes_copied;
|
||||||
char buffer[8192], *p;
|
char buffer[8192], *p;
|
||||||
gboolean res;
|
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;
|
bytes_copied = 0;
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
do
|
do
|
||||||
@@ -445,9 +454,7 @@ g_output_stream_real_splice (GOutputStream *stream,
|
|||||||
p = buffer;
|
p = buffer;
|
||||||
while (n_read > 0)
|
while (n_read > 0)
|
||||||
{
|
{
|
||||||
stream->priv->pending = FALSE;
|
n_written = class->write (stream, p, n_read, cancellable, error);
|
||||||
n_written = g_output_stream_write (stream, p, n_read, cancellable, error);
|
|
||||||
stream->priv->pending = TRUE;
|
|
||||||
if (n_written == -1)
|
if (n_written == -1)
|
||||||
{
|
{
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
@@ -461,6 +468,7 @@ g_output_stream_real_splice (GOutputStream *stream,
|
|||||||
}
|
}
|
||||||
while (res);
|
while (res);
|
||||||
|
|
||||||
|
notsupported:
|
||||||
if (!res)
|
if (!res)
|
||||||
error = NULL; /* Ignore further errors */
|
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)
|
if (flags & G_OUTPUT_STREAM_SPLICE_FLAGS_CLOSE_TARGET)
|
||||||
{
|
{
|
||||||
/* But write errors on close are bad! */
|
/* But write errors on close are bad! */
|
||||||
stream->priv->pending = FALSE;
|
if (!class->close (stream, cancellable, error))
|
||||||
if (!g_output_stream_close (stream, cancellable, error))
|
|
||||||
res = FALSE;
|
res = FALSE;
|
||||||
stream->priv->pending = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
@@ -546,13 +552,13 @@ g_output_stream_close (GOutputStream *stream,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = g_output_stream_flush (stream, cancellable, error);
|
|
||||||
|
|
||||||
stream->priv->pending = TRUE;
|
stream->priv->pending = TRUE;
|
||||||
|
|
||||||
if (cancellable)
|
if (cancellable)
|
||||||
g_push_current_cancellable (cancellable);
|
g_push_current_cancellable (cancellable);
|
||||||
|
|
||||||
|
res = class->flush (stream, cancellable, error);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
/* flushing caused the error that we want to return,
|
/* 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);
|
class = G_OUTPUT_STREAM_GET_CLASS (object);
|
||||||
op = g_simple_async_result_get_op_res_gpointer (result);
|
op = g_simple_async_result_get_op_res_gpointer (result);
|
||||||
|
|
||||||
stream->priv->pending = FALSE;
|
op->bytes_copied = class->splice (stream,
|
||||||
op->bytes_copied =
|
op->source,
|
||||||
g_output_stream_splice (stream,
|
op->flags,
|
||||||
op->source,
|
cancellable,
|
||||||
op->flags,
|
&error);
|
||||||
cancellable,
|
|
||||||
&error);
|
|
||||||
stream->priv->pending = TRUE;
|
|
||||||
|
|
||||||
if (op->bytes_copied == -1)
|
if (op->bytes_copied == -1)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user