GMemoryInputStream/GMemoryOutputStream: fix bug in previous commit

A g_input_stream_read_async() implementation can't call
g_input_stream_read() on itself directly because it will fail because
the pending flag is already set. So fix that by invoking the vmethod
directly rather than calling the wrapper. Likewise with
GMemoryOutputStream.

Add a test to gio/tests/memory-input-stream.c to catch read_async
failures in the future.
This commit is contained in:
Dan Winship
2011-12-01 13:10:25 +01:00
parent a5876e5fc1
commit e798349587
3 changed files with 86 additions and 8 deletions

View File

@@ -620,20 +620,24 @@ g_memory_output_stream_write_async (GOutputStream *stream,
gpointer data)
{
GSimpleAsyncResult *simple;
GError *error = NULL;
gssize nwritten;
nwritten = g_output_stream_write (stream,
buffer,
count,
cancellable,
NULL);
nwritten = G_OUTPUT_STREAM_GET_CLASS (stream)->write_fn (stream,
buffer,
count,
cancellable,
&error);
simple = g_simple_async_result_new (G_OBJECT (stream),
callback,
data,
g_memory_output_stream_write_async);
g_simple_async_result_set_op_res_gssize (simple, nwritten);
if (error)
g_simple_async_result_take_error (simple, error);
else
g_simple_async_result_set_op_res_gssize (simple, nwritten);
g_simple_async_result_complete_in_idle (simple);
g_object_unref (simple);
}