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
..
2010-06-10 13:35:25 -04:00
2010-08-13 17:23:44 -04:00
2010-07-07 19:53:22 -04:00
2010-07-12 15:33:05 -04:00
2009-03-31 19:39:16 -04:00
2010-07-07 19:53:22 -04:00
2010-07-12 18:30:14 -04:00
2010-07-30 19:53:29 -04:00
2010-06-17 16:07:52 -04:00
2010-08-03 10:41:21 -04:00
2010-07-12 18:30:14 -04:00
2009-08-19 11:02:05 +02:00
2010-07-05 00:56:12 -04:00
2010-07-07 19:53:22 -04:00
2010-03-26 09:30:25 -04:00
2010-07-12 18:30:14 -04:00
2010-07-10 17:21:32 -04:00
2010-07-12 18:30:14 -04:00
2010-07-12 18:30:14 -04:00
2010-07-12 18:30:14 -04:00
2010-07-20 10:49:30 -04:00
2010-07-07 19:53:22 -04:00
2010-07-10 17:21:32 -04:00
2010-06-22 12:14:31 -04:00
2010-07-07 19:53:22 -04:00
2010-07-07 19:53:22 -04:00
2010-07-07 19:53:22 -04:00
2010-07-07 19:53:22 -04:00
2010-07-09 07:24:08 -04:00
2009-11-17 20:27:38 -06:00
2010-07-12 18:30:14 -04:00
2010-07-07 19:53:22 -04:00
2010-07-10 17:21:32 -04:00
2009-05-13 14:42:46 +02:00
2010-07-07 19:53:22 -04:00
2010-07-10 17:21:32 -04:00
2010-07-07 19:53:22 -04:00
2010-01-12 16:34:18 +01:00
2010-07-07 19:53:22 -04:00
2010-03-26 11:05:02 -04:00
2009-05-13 14:42:38 +02:00
2010-07-07 19:53:22 -04:00
2010-07-10 18:04:22 -04:00
2010-07-07 19:53:22 -04:00
2010-07-10 17:21:32 -04:00
2010-07-30 19:51:17 -04:00
2009-11-23 16:22:52 +01:00
2010-06-04 19:03:38 +02:00
2010-07-07 19:53:22 -04:00
2010-07-07 19:53:22 -04:00
2010-04-16 23:23:40 -04:00
2010-08-13 21:23:22 -04:00
2010-07-12 18:30:14 -04:00
2010-08-14 16:15:39 -04:00
2010-07-07 19:53:22 -04:00
2010-07-10 17:21:32 -04:00
2010-07-07 19:53:22 -04:00
2010-07-10 17:21:32 -04:00
2010-07-07 19:53:22 -04:00
2009-07-05 22:35:55 -04:00
2010-07-07 19:53:22 -04:00
2010-07-12 18:30:14 -04:00
2010-07-07 19:53:22 -04:00