[vlc-devel] [PATCH] tls: Fix build without netinet/tcp.h

Julian Scheel julian at jusst.de
Fri Mar 10 12:41:44 CET 2017


On 10.03.2017 12:27, RĂ©mi Denis-Courmont wrote:
> On March 10, 2017 12:14:29 PM GMT+02:00, Julian Scheel <julian at jusst.de> wrote:
>> It's not enough to define SOL_TCP if netinet/tcp.h is not available. As
>> there is not toolchain agnostic value we could use to replace
>> TCP_NODELAY do only call setsockopt if netinet/tcp.h is available.
>>
>> Signed-off-by: Julian Scheel <julian at jusst.de>
>> ---
>> src/network/tls.c | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/network/tls.c b/src/network/tls.c
>> index 3210cfe865..e76e59ca22 100644
>> --- a/src/network/tls.c
>> +++ b/src/network/tls.c
>> @@ -42,9 +42,6 @@
>> #ifdef HAVE_NETINET_TCP_H
>> # include <netinet/tcp.h>
>> #endif
>> -#ifndef SOL_TCP
>> -# define SOL_TCP IPPROTO_TCP
>> -#endif
>>
>> #include <vlc_common.h>
>> #include "libvlc.h"
>> @@ -440,8 +437,10 @@ static vlc_tls_t *vlc_tls_SocketAddrInfo(const
>> struct addrinfo *restrict info)
>>
>>   setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &(int){ 1 }, sizeof (int));
>>
>> +#ifdef HAVE_NETINET_TCP_H
>> if (info->ai_socktype == SOCK_STREAM && info->ai_protocol ==
>> IPPROTO_TCP)
>>       setsockopt(fd, SOL_TCP, TCP_NODELAY, &(int){ 1 }, sizeof (int));
>> +#endif
>>
>> vlc_tls_t *sk = vlc_tls_SocketAlloc(fd, info->ai_addr,
>> info->ai_addrlen);
>>     if (unlikely(sk == NULL))
>> --
>> 2.12.0
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>
> Nack. This breaks Windows support
>

Right, Windows declares TCP_NODELAY in ws2def.h, but you can't assume 
this to be true for any system not providing netinet/tcp.h.

You break build on non-windows systems which don't have netinet/tcp.h 
with commit e5aa352, so Nack on that one.

Anyway, would you be happy with putting the setsockopt call under #ifdef 
TCP_NODELAY, keeping your SOL_TCP define. That way it will not change 
behaviour on Windows, but will still fix build on other systems.

I'd be glad if instead of simply rejecting things you'd mind to give 
some thoughts on how you would like it to be.

-Julian


More information about the vlc-devel mailing list