[libsoup] soup-filter-input-stream: fix read_until() with subclasses
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] soup-filter-input-stream: fix read_until() with subclasses
- Date: Sun, 25 Aug 2013 21:08:45 +0000 (UTC)
commit 6d149d8595d93c706c816a22acaffef37ea34ca5
Author: Dan Winship <danw gnome org>
Date: Sun Aug 25 16:45:21 2013 -0400
soup-filter-input-stream: fix read_until() with subclasses
If doing a read_line()/read_until() in a subclass, we need to use the
subclass's read implementation rather than just going directly to the
base stream.
libsoup/soup-filter-input-stream.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/libsoup/soup-filter-input-stream.c b/libsoup/soup-filter-input-stream.c
index 3b76386..8067b88 100644
--- a/libsoup/soup-filter-input-stream.c
+++ b/libsoup/soup-filter-input-stream.c
@@ -23,6 +23,7 @@
struct _SoupFilterInputStreamPrivate {
GByteArray *buf;
gboolean need_more;
+ gboolean in_read_until;
};
static void soup_filter_input_stream_pollable_init (GPollableInputStreamInterface *pollable_interface,
gpointer interface_data);
@@ -79,8 +80,10 @@ soup_filter_input_stream_read_fn (GInputStream *stream,
{
SoupFilterInputStream *fstream = SOUP_FILTER_INPUT_STREAM (stream);
- fstream->priv->need_more = FALSE;
- if (fstream->priv->buf) {
+ if (!fstream->priv->in_read_until)
+ fstream->priv->need_more = FALSE;
+
+ if (fstream->priv->buf && !fstream->priv->in_read_until) {
return read_from_buf (fstream, buffer, count);
} else {
return g_pollable_stream_read (G_FILTER_INPUT_STREAM (fstream)->base_stream,
@@ -108,8 +111,10 @@ soup_filter_input_stream_read_nonblocking (GPollableInputStream *stream,
{
SoupFilterInputStream *fstream = SOUP_FILTER_INPUT_STREAM (stream);
- fstream->priv->need_more = FALSE;
- if (fstream->priv->buf) {
+ if (!fstream->priv->in_read_until)
+ fstream->priv->need_more = FALSE;
+
+ if (fstream->priv->buf && !fstream->priv->in_read_until) {
return read_from_buf (fstream, buffer, count);
} else {
return g_pollable_stream_read (G_FILTER_INPUT_STREAM (fstream)->base_stream,
@@ -217,10 +222,12 @@ soup_filter_input_stream_read_until (SoupFilterInputStream *fstream,
g_byte_array_set_size (fstream->priv->buf, length);
buf = fstream->priv->buf->data;
- nread = g_pollable_stream_read (G_FILTER_INPUT_STREAM (fstream)->base_stream,
+ fstream->priv->in_read_until = TRUE;
+ nread = g_pollable_stream_read (G_INPUT_STREAM (fstream),
buf + prev_len, length - prev_len,
blocking,
cancellable, &my_error);
+ fstream->priv->in_read_until = FALSE;
if (nread <= 0) {
if (prev_len)
fstream->priv->buf->len = prev_len;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]