glib/docs/reference/gio
David Zeuthen 8a3a4596e2 Bug 626748 – Use async methods for writing and handle EAGAIN
If sending a lot of data and/or the other peer is not reading it, then
socket buffers can overflow. This is communicated from the kernel by
returning EAGAIN. In GIO, it is modelled by g_output_stream_write()
and g_socket_send_message() returning G_IO_ERROR_WOULD_BLOCK.

It is also problematic that that we're using synchronous IO in the
shared GDBus IO thread. It means that one GDBusConnection can lock up
others.

It turns out that by porting from g_output_stream_write() to
g_output_stream_write_async() we fix the EAGAIN issue. For GSocket, we
still need to handle things manually (by creating a GSource) as
g_socket_send_message() is used.

We check the new behavior in Michael's producer/consumer test case (at
/gdbus/overflow in gdbus-peer.c) added in the last commit.

Also add a test case that sends and receives a 20 MiB message.

Also add a new `transport' G_DBUS_DEBUG option so it is easy to
inspect partial writes:

 $ G_DBUS_DEBUG=transport ./gdbus-connection -p /gdbus/connection/large_message
 [...]
 ========================================================================
 GDBus-debug:Transport:
   >>>> WROTE 128000 bytes of message with serial 4 and
        size 20971669 from offset 0 on a GSocketOutputStream
 ========================================================================
 GDBus-debug:Transport:
   >>>> WROTE 128000 bytes of message with serial 4 and
        size 20971669 from offset 128000 on a GSocketOutputStream
 ========================================================================
 GDBus-debug:Transport:
   >>>> WROTE 128000 bytes of message with serial 4 and
        size 20971669 from offset 256000 on a GSocketOutputStream
 [...]
 ========================================================================
 GDBus-debug:Transport:
   >>>> WROTE 43669 bytes of message with serial 4 and
        size 20971669 from offset 20928000 on a GSocketOutputStream
 [...]
 ========================================================================
 GDBus-debug:Transport:
   <<<< READ 16 bytes of message with serial 3 and
        size 20971620 to offset 0 from a GSocketInputStream
 ========================================================================
 GDBus-debug:Transport:
   <<<< READ 15984 bytes of message with serial 3 and
        size 20971620 to offset 16 from a GSocketInputStream
 ========================================================================
 GDBus-debug:Transport:
   <<<< READ 16000 bytes of message with serial 3 and
        size 20971620 to offset 16000 from a GSocketInputStream
 [...]
 ========================================================================
 GDBus-debug:Transport:
   <<<< READ 144000 bytes of message with serial 3 and
        size 20971620 to offset 20720000 from a GSocketInputStream
 ========================================================================
 GDBus-debug:Transport:
   <<<< READ 107620 bytes of message with serial 3 and
        size 20971620 to offset 20864000 from a GSocketInputStream
 OK

https://bugzilla.gnome.org/show_bug.cgi?id=626748

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-16 13:54:13 -04:00
..
.gitignore .gitignore updates for gsettings stuff 2010-04-27 17:04:57 -04:00
gdbus.xml Add --xml to gdbus-tool to print raw introspected XML 2010-06-14 00:02:57 +02:00
gio-docs.xml Bug 617483 – Credentials passing 2010-07-20 16:34:18 -04:00
gio-querymodules.xml Add a man page for gio-querymodules 2010-04-18 15:54:54 -04:00
gio-sections.txt Always do async vs sync correctly in GSocketConnection streams 2010-08-15 15:34:29 -04:00
gio.types Merge the wip/gapplication branch 2010-06-07 13:48:42 -04:00
glib-compile-schemas.xml Document vendor override files 2010-08-13 21:23:22 -04:00
gsettings.xml Rename gsettings-tool to gsettings 2010-04-22 01:17:02 -04:00
gvfs-overview.odg update the overview image of the gio docs 2009-06-08 17:29:22 +02:00
gvfs-overview.png update the overview image of the gio docs 2009-06-08 17:29:22 +02:00
Makefile.am Replace -I with $(glib_INCLUDES) and friends 2010-08-06 13:10:34 -04:00
migrating-gconf.xml Remove gsettings-schema-convert tool 2010-06-21 13:24:40 -04:00
migrating-gdbus.xml Bug 621213 – GDBusProxy and well-known names 2010-06-11 18:21:27 -04:00
migrating-gnome-vfs.xml Add a migration chapter for dbus bits 2010-05-06 17:58:29 -04:00
migrating-posix.xml Remove duplicate copies of migration docs 2010-05-27 13:07:54 -04:00
overview.xml Bug 626748 – Use async methods for writing and handle EAGAIN 2010-08-16 13:54:13 -04:00
version.xml.in gio/ docs/reference/gio Merged gio-standalone into glib. 2007-11-26 16:13:05 +00:00