]> git.sesse.net Git - vlc/commitdiff
- Do not store HTTPd clients addresses (unused anyway)
authorRémi Denis-Courmont <rem@videolan.org>
Wed, 21 Feb 2007 20:49:01 +0000 (20:49 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Wed, 21 Feb 2007 20:49:01 +0000 (20:49 +0000)
- Use net_Accept()

src/network/httpd.c

index 086432093b6d06545b7c7679a9a2c25cd6b0428f..e8725038f60442c8b8ef22c779719a6813766d82 100644 (file)
@@ -164,8 +164,6 @@ struct httpd_client_t
 
     int     i_ref;
 
-    struct  sockaddr_storage sock;
-    int     i_sock_size;
     int     fd;
 
     int     i_mode;
@@ -1508,9 +1506,7 @@ static void httpd_ClientClean( httpd_client_t *cl )
     }
 }
 
-static httpd_client_t *httpd_ClientNew( int fd, struct sockaddr_storage *sock,
-                                        int i_sock_size,
-                                        tls_session_t *p_tls, mtime_t now )
+static httpd_client_t *httpd_ClientNew( int fd, tls_session_t *p_tls, mtime_t now )
 {
     httpd_client_t *cl = malloc( sizeof( httpd_client_t ) );
 
@@ -1518,8 +1514,6 @@ static httpd_client_t *httpd_ClientNew( int fd, struct sockaddr_storage *sock,
 
     cl->i_ref   = 0;
     cl->fd      = fd;
-    memcpy( &cl->sock, sock, sizeof( cl->sock ) );
-    cl->i_sock_size = i_sock_size;
     cl->url     = NULL;
     cl->p_tls = p_tls;
 
@@ -2443,15 +2437,10 @@ static void httpd_HostThread( httpd_host_t *host )
             if (ufd[nfd].revents == 0)
                 continue;
 
-            struct sockaddr_storage addr;
-            socklen_t addrlen = sizeof (addr);
-
-            int fd = accept (ufd[nfd].fd, (struct sockaddr *)&addr, &addrlen);
+            int fd = net_Accept (host, host->fds, 0);
             if (fd == -1)
                 continue;
 
-            net_SetupSocket (fd);
-
             int i_state = 0;
 
             if (p_tls != NULL)
@@ -2474,23 +2463,22 @@ static void httpd_HostThread( httpd_host_t *host )
                         break;
                 }
 
-                if (p_tls == NULL)
+                if ((p_tls == NULL) != (host->p_tls == NULL))
                     break; // wasted TLS session, cannot accept() anymore
             }
 
             httpd_client_t *cl;
-            char ip[NI_MAXNUMERICHOST];
             stats_UpdateInteger( host, host->p_total_counter, 1, NULL );
             stats_UpdateInteger( host, host->p_active_counter, 1, NULL );
-            cl = httpd_ClientNew( fd, &addr, addrlen, p_tls, now );
-            httpd_ClientIP( cl, ip );
-            msg_Dbg( host, "Connection from %s", ip );
+            cl = httpd_ClientNew( fd, p_tls, now );
             p_tls = NULL;
             vlc_mutex_lock( &host->lock );
             TAB_APPEND( host->i_client, host->client, cl );
             vlc_mutex_unlock( &host->lock );
             cl->i_state = i_state; // override state for TLS
-            break; // cannot accept more than one because of TLS
+
+            if (host->p_tls != NULL)
+                break; // cannot accept further without new TLS session
         }
 
         /* now try all others socket */