[vlc-commits] commit: net_Listen: pass socket type parameter ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Wed May 5 18:30:43 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May  5 19:15:48 2010 +0300| [bb7ae441f98c35ed5248c6cb2946a371d4a82c96] | committer: Rémi Denis-Courmont 

net_Listen: pass socket type parameter

We cannot use any random type semantic that we do not know of.
This also works around bugs in deficient getaddrinfo() implementations.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bb7ae441f98c35ed5248c6cb2946a371d4a82c96
---

 include/vlc_network.h    |    5 +++--
 modules/stream_out/rtp.c |    9 ++++++++-
 src/network/io.c         |    3 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/include/vlc_network.h b/include/vlc_network.h
index 77b3829..0a51a12 100644
--- a/include/vlc_network.h
+++ b/include/vlc_network.h
@@ -92,9 +92,10 @@ int net_Socket (vlc_object_t *obj, int family, int socktype, int proto);
 VLC_EXPORT( int, net_Connect, (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol) );
 #define net_Connect(a, b, c, d, e) net_Connect(VLC_OBJECT(a), b, c, d, e)
 
-VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int protocol) );
+VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol) );
 
-#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, IPPROTO_TCP)
+#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, \
+                                          SOCK_STREAM, IPPROTO_TCP)
 
 static inline int net_ConnectTCP (vlc_object_t *obj, const char *host, int port)
 {
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index ab3907b..2199469 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1023,8 +1023,12 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 #endif
 
     if( p_sys->psz_destination != NULL )
+    {
+        int type = SOCK_STREAM;
+
         switch( p_sys->proto )
         {
+#ifdef SOCK_DCCP
             case IPPROTO_DCCP:
             {
                 const char *code;
@@ -1036,11 +1040,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
                     default:       code = "RTPORTPV"; break;
                 }
                 var_SetString (p_stream, "dccp-service", code);
+                type = SOCK_DCCP;
             }   /* fall through */
+#endif
             case IPPROTO_TCP:
                 id->listen.fd = net_Listen( VLC_OBJECT(p_stream),
                                             p_sys->psz_destination, i_port,
-                                            p_sys->proto );
+                                            type, p_sys->proto );
                 if( id->listen.fd == NULL )
                 {
                     msg_Err( p_stream, "passive COMEDIA RTP socket failed" );
@@ -1072,6 +1078,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
                 rtp_add_sink( id, fd, p_sys->rtcp_mux, NULL );
             }
         }
+    }
 
     if( p_fmt == NULL )
     {
diff --git a/src/network/io.c b/src/network/io.c
index c4238d5..2defe31 100644
--- a/src/network/io.c
+++ b/src/network/io.c
@@ -127,11 +127,12 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
 
 
 int *net_Listen (vlc_object_t *p_this, const char *psz_host,
-                 int i_port, int protocol)
+                 int i_port, int type, int protocol)
 {
     struct addrinfo hints, *res;
 
     memset (&hints, 0, sizeof( hints ));
+    hints.ai_socktype = type;
     hints.ai_protocol = protocol;
     hints.ai_flags = AI_PASSIVE;
 



More information about the vlc-commits mailing list