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 <[email protected]>
>> Cc: Kyungmin Park <[email protected]>
>> Cc: MyungJoo Ham <[email protected]>
>> Cc: Piort Bereza <[email protected]>
>> Cc: Karol Lewandowski <[email protected]>
>> Cc: Lennart Poettering <[email protected]>
>> Cc: Zbigniew Jędrzejewski-Szmek <[email protected]>
>> Cc: Peter Hutterer <[email protected]>
>> Cc: walter harms <[email protected]>
>> Cc: Alan Coopersmith <[email protected]>
>> ---
>> 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
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel