blob: 29e3116881f4d7a9d635af2c95b6e24b7d0d76e3 [file] [log] [blame]
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index 4a668b8..6ca7b6f 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -913,7 +913,7 @@ write_message_async_cb (GObject *source_object,
g_object_unref (simple);
goto out;
}
- g_assert (bytes_written > 0); /* zero is never returned */
+ g_assert (bytes_written >= 0);
write_message_print_transport_debug (bytes_written, data);
@@ -1009,10 +1009,10 @@ write_message_continue_writing (MessageToWriteData *data)
if (control_message != NULL)
g_object_unref (control_message);
- if (bytes_written == -1)
+ if (bytes_written == -1 || bytes_written == 0)
{
- /* Handle WOULD_BLOCK by waiting until there's room in the buffer */
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
+ /* Handle zero bytes written or WOULD_BLOCK by waiting until there's room in the buffer */
+ if (bytes_written == 0 || g_error_matches (error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
{
GSource *source;
source = g_socket_create_source (data->worker->socket,
@@ -1024,7 +1024,8 @@ write_message_continue_writing (MessageToWriteData *data)
NULL); /* GDestroyNotify */
g_source_attach (source, g_main_context_get_thread_default ());
g_source_unref (source);
- g_error_free (error);
+ if (error != NULL)
+ g_error_free (error);
goto out;
}
g_simple_async_result_take_error (simple, error);
@@ -1032,7 +1033,7 @@ write_message_continue_writing (MessageToWriteData *data)
g_object_unref (simple);
goto out;
}
- g_assert (bytes_written > 0); /* zero is never returned */
+ g_assert (bytes_written > 0); /* -1 and 0 is handled above */
write_message_print_transport_debug (bytes_written, data);