It was <2013-06-28 pią 10:52>, when walter harms wrote:
> Am 28.06.2013 10:02, schrieb Łukasz Stelmach:
>> It was <2013-06-28 pią 07:32>, when Peter Hutterer wrote:
>>> On Wed, Jun 26, 2013 at 06:18:04PM +0200, Łukasz Stelmach wrote:
>>>> Receive file descriptors of open sockets from systemd instead of
>>>> creating them.
>>>>
>>>> Signed-off-by: Łukasz Stelmach <[email protected]>
>>>> ---
>>>>  Xtrans.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>  1 file changed, 50 insertions(+)
>>>>
>>>> diff --git a/Xtrans.c b/Xtrans.c
>>>> index 0799f04..a96e901 100644
>>>> --- a/Xtrans.c
>>>> +++ b/Xtrans.c

[...]

>>>> +    {
>>>> +  for (i = 0; i < systemd_listen_fds; i++)
>>>> +  {
>>>> +      struct sockaddr_storage a;
>>>> +      int ti;
>>>> +      socklen_t al;
>>>> +
>>>> +      al = sizeof(a);
>>>> +      if (getsockname(i + SD_LISTEN_FDS_START, (struct sockaddr*)&a, &al) 
>>>> < 0)
>>>> +          return -1;
>>>> +
>>>> +      switch (a.ss_family)
>>>> +      {
>>>> +      case AF_UNIX:
>>>> +          ti = TRANS_SOCKET_UNIX_INDEX;
>>>> +          break;
>>>> +      case AF_INET:
>>>> +          ti = TRANS_SOCKET_INET_INDEX;
>>>> +          break;
>>>> +#if defined(IPv6) && defined(AF_INET6)
>>>> +      case AF_INET6:
>>>> +          ti = TRANS_SOCKET_INET6_INDEX;
>>>> +          break;
>>>> +#endif /* IPv6 */
>>>> +      default:
>>>> +          return -1;
>>>> +      }
>>>> +
>>>> +      if ((ciptr = TRANS(ReopenCOTSServer(ti, i + SD_LISTEN_FDS_START,
>>>> +                                          getenv("DISPLAY"))))==NULL)
>>>> + fprintf(stderr, "Got NULL while trying to Reopen socket received
>>>> from systemd.\n");
>>>
>>> lowercase 'reopen'
>> 
>> Fixed.
>> 
>>> (don't have the brain capacity to do a proper review atm, sorry)
>> 
>> Thak you for your comments. I will send v2 when I get some more.
>
>
> These if-statement if very complex. You should revamp it and make at least 2 
> statements
> like:
> ciptr = TRANS(ReopenCOTSServer(ti, i + SD_LISTEN_FDS_START,getenv("DISPLAY"));
> if (ciptr == NULL )

This is exactly the same way lauchd is handeled right before the place
this patch is applied[1]. Should I fix that too?

> btw: can getenv() fail ?

Yes, and a NULL is returned. However TRANS(ReopenCOTSServer)[2]
(actually it is TRANS(Reopen)[3][4]) returns NULL in such case. This way
failing getenv() is also covered.

[1] 
http://cgit.freedesktop.org/xorg/lib/libxtrans/tree/Xtrans.c?id=bd53f4c8543faf910a7a151241ee07661b4d57ad#n1036
[2] 
http://cgit.freedesktop.org/xorg/lib/libxtrans/tree/Xtrans.c?id=bd53f4c8543faf910a7a151241ee07661b4d57ad#n612
[3] 
http://cgit.freedesktop.org/xorg/lib/libxtrans/tree/Xtrans.c?id=bd53f4c8543faf910a7a151241ee07661b4d57ad#n486
[4] 
http://cgit.freedesktop.org/xorg/lib/libxtrans/tree/Xtrans.c?id=bd53f4c8543faf910a7a151241ee07661b4d57ad#n518

-- 
Ł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

Reply via email to