#include <vlc_tls.h>
#include <vlc_acl.h>
#include <vlc_strings.h>
+#include <vlc_rand.h>
#include "../libvlc.h"
#include <string.h>
"application/octet-stream" );
httpd_MsgAdd( answer, "Server", "Cougar 4.1.0.3921" );
httpd_MsgAdd( answer, "Pragma", "no-cache" );
- httpd_MsgAdd( answer, "Pragma", "client-id=%d", rand()&0x7fff );
+ httpd_MsgAdd( answer, "Pragma", "client-id=%lu",
+ vlc_mrand48()&0x7fff );
httpd_MsgAdd( answer, "Pragma", "features=\"broadcast\"" );
/* Check if there is a xPlayStrm=1 */
vlc_cond_init( &host->wait );
host->i_ref = 1;
+ vlc_object_attach( host, p_this );
+
host->fds = net_ListenTCP( p_this, psz_host, i_port );
if( host->fds == NULL )
{
if( httpd->i_host <= 0 )
{
libvlc_priv (httpd->p_libvlc)->p_httpd = NULL;
- vlc_object_detach( httpd );
vlc_object_release( httpd );
}
vlc_mutex_unlock( &httpd_mutex );
msg_Dbg( httpd, "no hosts left, stopping httpd" );
libvlc_priv (httpd->p_libvlc)->p_httpd = NULL;
- vlc_object_detach( httpd );
vlc_object_release( httpd );
}
vlc_mutex_unlock( &httpd_mutex );
answer->i_body = 0;
answer->p_body = NULL;
- httpd_MsgAdd( answer, "Server", "%s", PACKAGE_STRING );
+ httpd_MsgAdd( answer, "Server", "VLC/%s", VERSION );
httpd_MsgAdd( answer, "Content-Length", "0" );
switch( query->i_proto )
continue;
/* */
-#ifdef HAVE_ACCEPT4
- fd = accept4 (fd, NULL, NULL, SOCK_CLOEXEC);
- if (fd == -1 && errno == ENOSYS)
-#endif
- fd = accept (fd, NULL, NULL);
+ fd = vlc_accept (fd, NULL, NULL, true);
if (fd == -1)
continue;
+ setsockopt (fd, SOL_SOCKET, SO_REUSEADDR,
+ &(int){ 1 }, sizeof(int));
- net_SetupSocket (fd);
if( p_tls != NULL )
{
switch( tls_ServerSessionHandshake( p_tls, fd ) )