From: RĂ©mi Denis-Courmont Date: Mon, 6 Nov 2006 17:29:07 +0000 (+0000) Subject: Cleanup X-Git-Tag: 0.9.0-test0~9648 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=209a00c674b57f182fb47fca9b1ad306a7165793;p=vlc Cleanup --- diff --git a/include/network.h b/include/network.h index 61b494bdb3..1f6d197253 100644 --- a/include/network.h +++ b/include/network.h @@ -89,8 +89,10 @@ int net_Socket (vlc_object_t *obj, int family, int socktype, int proto); #define net_OpenTCP(a, b, c) __net_ConnectTCP(VLC_OBJECT(a), b, c) VLC_EXPORT( int, __net_ConnectTCP, ( vlc_object_t *p_this, const char *psz_host, int i_port ) ); -int *net_Listen (vlc_object_t *p_this, const char *psz_host, int i_port, - int family, int socktype, int protocol); +/*int *net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, + int family, int socktype, int protocol);*/ +VLC_EXPORT( int, net_ListenSingle, (vlc_object_t *p_this, const char *psz_host, int i_port, + int family, int socktype, int protocol) ); #define net_ListenTCP(a, b, c) __net_ListenTCP(VLC_OBJECT(a), b, c) VLC_EXPORT( int *, __net_ListenTCP, ( vlc_object_t *, const char *, int ) ); @@ -101,7 +103,10 @@ VLC_EXPORT( int, __net_Accept, ( vlc_object_t *, int *, mtime_t ) ); #define net_ConnectUDP(a, b, c, d ) __net_ConnectUDP(VLC_OBJECT(a), b, c, d) VLC_EXPORT( int, __net_ConnectUDP, ( vlc_object_t *p_this, const char *psz_host, int i_port, int hlim ) ); -VLC_EXPORT( int, net_ListenUDP1, (vlc_object_t *obj, const char *host, int port) ); +static inline int net_ListenUDP1 (vlc_object_t *obj, const char *host, int port) +{ + return net_ListenSingle (obj, host, port, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP); +} #define net_OpenUDP(a, b, c, d, e ) __net_OpenUDP(VLC_OBJECT(a), b, c, d, e) VLC_EXPORT( int, __net_OpenUDP, ( vlc_object_t *p_this, const char *psz_bind, int i_bind, const char *psz_server, int i_server ) ); diff --git a/include/vlc_symbols.h b/include/vlc_symbols.h index ff2c696579..87175350ba 100644 --- a/include/vlc_symbols.h +++ b/include/vlc_symbols.h @@ -554,7 +554,6 @@ struct module_symbols_t void (*config_ChainDestroy_inner) (config_chain_t *); char * (*config_ChainCreate_inner) (char **, config_chain_t **, char *); int (*utf8_open_inner) (const char *filename, int flags, mode_t mode); - int (*net_ListenUDP1_inner) (vlc_object_t *obj, const char *host, int port); }; # if defined (__PLUGIN__) # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner @@ -1032,7 +1031,6 @@ struct module_symbols_t # define config_ChainDestroy (p_symbols)->config_ChainDestroy_inner # define config_ChainCreate (p_symbols)->config_ChainCreate_inner # define utf8_open (p_symbols)->utf8_open_inner -# define net_ListenUDP1 (p_symbols)->net_ListenUDP1_inner # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) /****************************************************************** * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. @@ -1513,7 +1511,6 @@ struct module_symbols_t ((p_symbols)->config_ChainDestroy_inner) = config_ChainDestroy; \ ((p_symbols)->config_ChainCreate_inner) = config_ChainCreate; \ ((p_symbols)->utf8_open_inner) = utf8_open; \ - ((p_symbols)->net_ListenUDP1_inner) = net_ListenUDP1; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->__sout_CfgParse_deprecated = NULL; \ (p_symbols)->sout_CfgCreate_deprecated = NULL; \ diff --git a/src/network/io.c b/src/network/io.c index c6cad1649e..65cd3c2752 100644 --- a/src/network/io.c +++ b/src/network/io.c @@ -114,8 +114,8 @@ 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 family, int socktype, int protocol) +static int *net_Listen (vlc_object_t *p_this, const char *psz_host, + int i_port, int family, int socktype, int protocol) { struct addrinfo hints, *res; @@ -233,6 +233,28 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host, int i_port, } +int net_ListenSingle (vlc_object_t *obj, const char *host, int port, + int family, int socktype, int protocol) +{ + int *fdv = net_Listen (obj, host, port, family, socktype, protocol); + if (fdv == NULL) + return -1; + + for (unsigned i = 1; fdv[i] != -1; i++) + { + msg_Warn (obj, "A socket has been dropped!"); + net_Close (fdv[i]); + } + + int fd = fdv[0]; + assert (fd != -1); + + free (fdv); + return fd; +} + + + /***************************************************************************** * __net_Close: ***************************************************************************** diff --git a/src/network/udp.c b/src/network/udp.c index 08bcffd33d..62b64b035b 100644 --- a/src/network/udp.c +++ b/src/network/udp.c @@ -402,38 +402,6 @@ int __net_ConnectUDP( vlc_object_t *p_this, const char *psz_host, int i_port, } -static inline -int *__net_ListenUDP (vlc_object_t *obj, const char *host, int port) -{ - int *fdv = net_Listen (obj, host, port, 0, SOCK_DGRAM, IPPROTO_UDP); - if (fdv == NULL) - return NULL; - - /* FIXME: handle multicast subscription */ - return fdv; -} - - -int net_ListenUDP1 (vlc_object_t *obj, const char *host, int port) -{ - int *fdv = __net_ListenUDP (obj, host, port); - if (fdv == NULL) - return -1; - - for (unsigned i = 1; fdv[i] != -1; i++) - { - msg_Warn (obj, "A socket has been dropped!"); - net_Close (fdv[i]); - } - - int fd = fdv[0]; - assert (fd != -1); - - free (fdv); - return fd; -} - - /***************************************************************************** * __net_OpenUDP: *****************************************************************************