After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 637696 - g_unix_connection_send_fd() doesn't work
g_unix_connection_send_fd() doesn't work
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
2.27.x
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-12-20 22:07 UTC by Nobuyoshi Nakada
Modified: 2011-01-12 21:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch with a test case (3.83 KB, patch)
2011-01-11 02:48 UTC, Daiki Ueno
committed Details | Review

Description Nobuyoshi Nakada 2010-12-20 22:07:16 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 ">=".
Comment 1 Daiki Ueno 2011-01-11 02:48:41 UTC
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
Comment 2 Dan Winship 2011-01-12 21:03:47 UTC
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!