Bug 31029

Summary: convenience function to listen on an arbitrary Unix socket
Product: Telepathy Reporter: Simon McVittie <smcv>
Component: tp-glibAssignee: Simon McVittie <smcv>
Status: RESOLVED MOVED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: enhancement    
Priority: medium Keywords: patch
Version: git master   
Hardware: Other   
OS: All   
URL: http://git.collabora.co.uk/?p=user/smcv/telepathy-glib-smcv.git;a=shortlog;h=refs/heads/unix
See Also: https://bugzilla.gnome.org/show_bug.cgi?id=631314
Whiteboard:
i915 platform: i915 features:

Description Simon McVittie 2010-10-21 03:59:32 UTC
As Guillaume said in <https://bugzilla.gnome.org/show_bug.cgi?id=631314>, "Most of the time when I create an UNIX socket, I don't care about its path and just want a socket in the temporary directory."

At the moment we use tmpnam(), which makes the compiler warn (we are in fact using it safely, as far as I can see, but the compiler can't know that). This branch replaces _tp_create_temp_unix_socket with a function following Dan Winship's suggestions on the GNOME bug.
Comment 1 Guillaume Desmottes 2010-10-21 07:04:15 UTC
I assume the branch is actually http://git.collabora.co.uk/?p=user/smcv/telepathy-glib-smcv.git;a=shortlog;h=refs/heads/unix

Looks good.
Comment 2 Simon McVittie 2010-10-26 07:40:54 UTC
Guillaume has reviewed up to and including 1820295f15ee.

Following discussion on the GNOME bug regarding portability, I'm not entirely happy with this; I've updated the branch to use a private subdirectory, and added a cleanup function which unlinks the path and removes the directory.

More discussion on the GNOME bug -> over there.
Comment 3 Simon McVittie 2010-10-26 08:01:56 UTC
Implementation r+ from Guillaume up to 99edd4b0d3769, but I'm waiting for the API ideas on the GNOME bug to settle.
Comment 4 Simon McVittie 2010-12-14 05:44:40 UTC
The need to clean up the temporary directory meant I wanted a better cleanup function, so I encapsulated the "listening thing" as a mini-object. We now have this API:

typedef struct _TpUnixListener TpUnixListener;
TpUnixListener *tp_unix_listener_new (const gchar *hint,
    GSocketType type, GError **error);
GSocket *tp_unix_listener_get_socket (TpUnixListener *self);
/* really returns a GUnixSocketAddress, transfer none */
GSocketAddress *tp_unix_listener_get_address (TpUnixListener *self);
const gchar *tp_unix_listener_get_path (TpUnixListener *self, gsize *len);
void tp_unix_listener_free (TpUnixListener *self);

A non-NULL TpUnixListener can only be created on Unix.
Comment 5 Guillaume Desmottes 2010-12-14 06:17:03 UTC
Hardcoding "/stream" while the socket could, in theory, have a different GSocketType seems a bit weird.

I'm not a big fan of struct as pseudo object. From my experience, we often ends up at some point missing it not being a proper GObject (when you need to pass ref without needing a _copy() for example). This object would be a real object in a proper OOo language.
Comment 6 GitLab Migration User 2019-12-03 20:04:10 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/telepathy/telepathy-glib/issues/45.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.