Commit d2f69bc3 authored by Rafaël Carré's avatar Rafaël Carré

http: split loop function

parent 1eec0949
......@@ -1923,14 +1923,8 @@ static void httpd_ClientTlsHandshake( httpd_client_t *cl )
}
}
static void* httpd_HostThread( void *data )
static void httpdLoop(httpd_host_t *host)
{
httpd_host_t *host = data;
int canc = vlc_savecancel();
vlc_mutex_lock( &host->lock );
while( host->i_ref > 0 )
{
struct pollfd ufd[host->nfd + host->i_client];
unsigned nfd;
for( nfd = 0; nfd < host->nfd; nfd++ )
......@@ -1944,15 +1938,14 @@ static void* httpd_HostThread( void *data )
while( host->i_url <= 0 )
{
mutex_cleanup_push( &host->lock );
vlc_restorecancel( canc );
vlc_cond_wait( &host->wait, &host->lock );
canc = vlc_savecancel();
vlc_cleanup_pop();
}
mtime_t now = mdate();
bool b_low_delay = false;
int canc = vlc_savecancel();
for(int i_client = 0; i_client < host->i_client; i_client++ )
{
int64_t i_offset;
......@@ -1986,8 +1979,7 @@ static void* httpd_HostThread( void *data )
pufd->events = POLLOUT;
break;
case HTTPD_CLIENT_RECEIVE_DONE:
{
case HTTPD_CLIENT_RECEIVE_DONE: {
httpd_message_t *answer = &cl->answer;
httpd_message_t *query = &cl->query;
......@@ -2145,8 +2137,8 @@ static void* httpd_HostThread( void *data )
cl->i_state = HTTPD_CLIENT_SENDING;
}
}
}
break;
}
case HTTPD_CLIENT_SEND_DONE:
if( !cl->b_stream_mode || cl->answer.i_body_offset == 0 )
......@@ -2247,7 +2239,8 @@ static void* httpd_HostThread( void *data )
msleep( 100000 );
}
case 0:
continue;
vlc_restorecancel( canc );
return;
}
/* Handle client sockets */
......@@ -2306,7 +2299,17 @@ static void* httpd_HostThread( void *data )
TAB_APPEND( host->i_client, host->client, cl );
}
}
vlc_restorecancel(canc);
}
static void* httpd_HostThread( void *data )
{
httpd_host_t *host = data;
vlc_mutex_lock( &host->lock );
while( host->i_ref > 0 )
httpdLoop(host);
vlc_mutex_unlock( &host->lock );
return NULL;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment