[pulseaudio-discuss] [PATCH 4/8] socket-server: Add support for systemd socket activation.

Colin Guthrie gmane at colin.guthr.ie
Fri Oct 24 02:34:36 PDT 2014


Tanu Kaskinen wrote on 24/10/14 09:35:
> On Sat, 2014-10-18 at 20:43 +0200, Colin Guthrie wrote:
>> --- a/src/pulsecore/socket-server.c
>> +++ b/src/pulsecore/socket-server.c
>>  pa_socket_server* pa_socket_server_new_unix(pa_mainloop_api *m, const char *filename) {
>> -    int fd = -1;
>> +    int n, fd = -1;
>> +    bool activated = false;
>>      struct sockaddr_un sa;
>>      pa_socket_server *s;
>>  
>>      pa_assert(m);
>>      pa_assert(filename);
>>  
>> -    if ((fd = pa_socket_cloexec(PF_UNIX, SOCK_STREAM, 0)) < 0) {
>> -        pa_log("socket(): %s", pa_cstrerror(errno));
>> -        goto fail;
>> +#ifdef HAVE_SYSTEMD_DAEMON
>> +    n = sd_listen_fds(0);
>> +    if (n > 0) {
>> +        int i;
>> +        for (i = 0; i < n; ++i) {
>> +            if (sd_is_socket_unix(SD_LISTEN_FDS_START + i, SOCK_STREAM, 1, filename, 0) > 0) {
>> +                fd = SD_LISTEN_FDS_START + i;
>> +                activated = true;
>> +                pa_log_info("socket(): Found socket activation socket for '%s' \\o/", filename);
> 
> Why does the log message start with "socket():"?

Indeed!

In my original attempt I had a separate function (similar to the
_adopt() approach in the other patch), and called it "PF_SYSTEMD" there
- which is made up, but useful to distinguish it separately. When I
realised this approach wasn't ideal, I just removed the text and didn't
replace it with PF_UNIX or really think about it (just blindly copied
stuff surrounding it).

Now you've made me think about it, there definitaly shouldn't be any
socket(): prefix. I'll just nuke that bit in my tree.

Oh and BTW, I took some time yesterday to do some git-based wrangling on
the wiki and fixed up some URLs a bit (and a few others that were caught
up in it, including the standard TOC too that failed on several pages
depending on their depth).

Probably lots more that could be done there, but fixed a few issues.

My documentation URL is now:
http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Running/
(tho' I've not edited it too much - just fixed typos Thomas spotted so
far, but will add some more in due course)


Col


-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/


More information about the pulseaudio-discuss mailing list