[glib/wip/smcv/big-dbus-write-with-fds: 1/2] gdbus: Cope with sending fds in a message that takes multiple writes
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/smcv/big-dbus-write-with-fds: 1/2] gdbus: Cope with sending fds in a message that takes multiple writes
- Date: Wed, 28 Oct 2020 11:05:55 +0000 (UTC)
commit d7f12aceb777ee959952150518a2ea61c42227d4
Author: Simon McVittie <smcv collabora com>
Date: Wed Oct 28 11:04:47 2020 +0000
gdbus: Cope with sending fds in a message that takes multiple writes
Suppose we are sending a 5K message with fds, and the kernel is only
accepting 4K with each sendmsg(). data->blob_size is 5K.
The first time we get into write_message_continue_writing(),
data->total_written is 0. We will try to write the entire message,
plus the attached file descriptors; or if the stream doesn't support
fd-passing (not a socket), we need to fail with
"Tried sending a file descriptor on unsupported stream".
Because the kernel didn't accept the entire message, we come back in.
This time, we won't enter the Unix-specific block that involves sending
fds, because now data->total_written is 4K, and it would be wrong to
try to attach the same fds again. However, we also need to avoid
failing with "Tried sending a file descriptor on unsupported stream"
in this case.
Resolves: https://gitlab.gnome.org/GNOME/glib/-/issues/2074
Signed-off-by: Simon McVittie <smcv collabora com>
gio/gdbusprivate.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c
index 5c980b40b..2551e4791 100644
--- a/gio/gdbusprivate.c
+++ b/gio/gdbusprivate.c
@@ -1085,8 +1085,11 @@ write_message_continue_writing (MessageToWriteData *data)
else
{
#ifdef G_OS_UNIX
- if (fd_list != NULL)
+ if (data->total_written == 0 && fd_list != NULL)
{
+ /* We were trying to write byte 0 of the message, which needs
+ * the fd list to be attached to it, but this connection doesn't
+ * support doing that. */
g_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]