[PATCH libxtrans v3.1] Enable systemd socket activation
Łukasz Stelmach
l.stelmach at samsung.com
Mon Jul 15 01:32:30 PDT 2013
It was <2013-07-12 pią 18:08>, when walter harms wrote:
> Am 12.07.2013 17:17, schrieb Łukasz Stelmach:
>> Receive file descriptors of open sockets from systemd instead of
>> creating them.
>>
>> Signed-off-by: Łukasz Stelmach <l.stelmach at samsung.com>
>> Cc: Kyungmin Park <kyungmin.park at samsung.com>
>> Cc: MyungJoo Ham <myungjoo.ham at samsung.com>
>> Cc: Piort Bereza <p.bereza at samsung.com>
>> Cc: Karol Lewandowski <k.lewandowsk at samsung.com>
>> Cc: Lennart Poettering <lennart at poettering.net>
>> Cc: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
>> Cc: Peter Hutterer <peter.hutterer at who-t.net>
>> Cc: walter harms <wharms at bfs.de>
>> Cc: Alan Coopersmith <alan.coopersmith at oracle.com>
>> ---
>> Xtrans.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 77 insertions(+), 1 deletion(-)
>>
>> diff --git a/Xtrans.c b/Xtrans.c
>> index 5860f3a..891edb4 100644
>> --- a/Xtrans.c
>> +++ b/Xtrans.c
>> @@ -48,6 +48,9 @@ from The Open Group.
>> */
>>
>> #include <ctype.h>
>> +#ifdef HAVE_SYSTEMD
>> +#include <systemd/sd-daemon.h>
>> +#endif
>>
>> /*
>> * The transport table contains a definition for every transport (protocol)
>> @@ -1037,6 +1040,75 @@ complete_network_count (void)
>> }
>>
>>
>> +static int
>> +receive_listening_fds(char* port, XtransConnInfo* temp_ciptrs, int* count_ret)
>> +
>> +{
>> +#ifdef HAVE_SYSTEMD
>> + XtransConnInfo ciptr;
>> + char buffer[8];
>> + int systemd_listen_fds, i;
>> +
>> + systemd_listen_fds = sd_listen_fds(1);
>> + if (systemd_listen_fds < 0)
>> + {
>> + return -1;
>> + }
>
> sd_listen_fds(1) can never be 0 ?
Of course it can. It means no file descriptors have been passed (or they
have been passed incorectly)[1] and as one might expect it causes the
programme to jump directly to the "return 0" at the end of the function.
>> + else if (systemd_listen_fds > 0)
>> + {
>> + snprintf(buffer, sizeof(buffer), ":%s", port);
>
> sorry, i feel stupid but i still can not see any use of buffer.
> The others seem to use it for debugging output but not in this function.
Indeed. You are right, I've fixed it.
[1] http://www.freedesktop.org/software/systemd/man/sd_listen_fds.html
--
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
More information about the xorg-devel
mailing list