Commit e22aaa74 authored by Ole André Vadla Ravnås's avatar Ole André Vadla Ravnås Committed by Olivier Crête

test-io-stream-closing-write: Handle partial I/O

parent 1d67c965
...@@ -54,15 +54,15 @@ GCond count_cond; ...@@ -54,15 +54,15 @@ GCond count_cond;
static void static void
read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data) read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data)
{ {
guint8 buf[MESSAGE_SIZE];
gsize bytes_read = 0;
gpointer tmp; gpointer tmp;
guint stream_id; guint stream_id;
GError *error = NULL;
gssize len;
guint8 buf[MESSAGE_SIZE];
/* Block on receiving some data. */ /* Block on receiving some data. */
len = g_input_stream_read (input_stream, buf, sizeof (buf), NULL, &error); g_input_stream_read_all (input_stream, buf, sizeof (buf), &bytes_read, NULL,
g_assert_cmpint (len, ==, sizeof(buf)); NULL);
g_assert_cmpint (bytes_read, ==, sizeof (buf));
g_mutex_lock (&count_lock); g_mutex_lock (&count_lock);
count++; count++;
...@@ -87,8 +87,9 @@ read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data) ...@@ -87,8 +87,9 @@ read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data)
static void static void
write_thread_cb (GOutputStream *output_stream, TestIOStreamThreadData *data) write_thread_cb (GOutputStream *output_stream, TestIOStreamThreadData *data)
{ {
gboolean success;
gchar buf[MESSAGE_SIZE] = {0}; gchar buf[MESSAGE_SIZE] = {0};
gssize ret; gsize bytes_written;
GError *error = NULL; GError *error = NULL;
g_mutex_lock (&count_lock); g_mutex_lock (&count_lock);
...@@ -97,16 +98,16 @@ write_thread_cb (GOutputStream *output_stream, TestIOStreamThreadData *data) ...@@ -97,16 +98,16 @@ write_thread_cb (GOutputStream *output_stream, TestIOStreamThreadData *data)
g_mutex_unlock (&count_lock); g_mutex_unlock (&count_lock);
do { do {
bytes_written = 0;
g_assert_no_error (error); g_assert_no_error (error);
ret = g_output_stream_write (output_stream, buf, sizeof (buf), NULL, success = g_output_stream_write_all (output_stream, buf, sizeof (buf),
&error); &bytes_written, NULL, &error);
if (!data->user_data) { if (!data->user_data) {
g_assert_cmpint (ret, ==, sizeof (buf)); g_assert_cmpint (bytes_written, ==, sizeof (buf));
return; return;
} }
} while (ret > 0); } while (success);
g_assert_cmpint (ret, ==, -1);
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED);
g_clear_error (&error); g_clear_error (&error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment