Comment 15 for bug 75602

Revision history for this message
In , Krzysztof-konopko (krzysztof-konopko) wrote :

Created attachment 75714
A patch for _dbus_file_get_contents() to support procfs files that appear to be empty

This is the first patch in hopefully a series of patches that will try to remedy the problem described in this bug at least on Linux.

First thing to do is to support files in procfs that appear to be empty. Unfortunately _dbus_file_get_contents() ignores such files upfront.

The patch has been inspired by a patch used in a production system:
https://github.com/kkonopko/dbus/commit/7af563d558808fc91d181b5bf9fe24543a44df4c#L8R148

This one uses _dbus_read() instead of plain read. It's also tempting to fold the logic from the last `else' statement into the first one. And even further the logic that closes the file (and reverts the output DBusString size) and returns the status could also be folded. This will require writing some tests for this function first.

The patch is to get a brief opinion and views.