GNOME Bugzilla – Bug 637696
g_unix_connection_send_fd() doesn't work
Last modified: 2011-01-12 21:03:51 UTC
Because g_unix_fd_message_append_fd() returns FALSE on its first call, g_unix_connection_send_fd() always fails but @error is not set. Citing from gunixfdlist.c: * g_unix_fd_list_append: * Returns: the index of the appended fd in case of success, else -1 * (and @error is set) So 0 will be returned on the first call, but g_unix_fd_message_append_fd() checks if the result is greater than 0. return g_unix_fd_list_append (message->priv->list, fd, error) > 0; I think the fix would be very trivial, replacing the comparison with ">=".
Created attachment 177997 [details] [review] patch with a test case I'm attaching a patch to gunixfdmessage.c and tests/socket.c. Without the change to g_unix_fd_message_append_fd(), the test case now fails with: $ gtester --verbose socket TEST: socket... (pid=19963) /socket/unix-from-fd: OK /socket/unix-connection: OK /socket/unix-connection-ancillary-data: ** ERROR:socket.c:151:test_unix_connection_ancillary_data: assertion failed (s == 53): (0 == 53) ** ERROR:socket.c:128:test_unix_connection_ancillary_data: assertion failed (s == pv[1]): (-1 == 5) FAIL
Hooray test cases! I made a few tweaks to the test case, verified that it still failed without the gunixfdmessage.c change and still passed with it, and committed the whole thing. Thanks!