Commit 7371d0ab authored by Karl Heyes's avatar Karl Heyes

move the source client '200 OK' response to the source client specific part

of the source thread, and rearrange stats around that

svn path=/trunk/icecast/; revision=5862
parent c1bb9e98
......@@ -479,8 +479,6 @@ int connection_complete_source (source_t *source)
global.sources++;
global_unlock();
stats_event_inc(NULL, "sources");
stats_event_inc(NULL, "source_total_connections");
/* for relays, we don't yet have a client, however we do require one
* to retrieve the stream from. This is created here, quite late,
......@@ -490,8 +488,6 @@ int connection_complete_source (source_t *source)
if (source->client == NULL)
source->client = client_create (source->con, source->parser);
sock_set_blocking (source->con->sock, SOCK_NONBLOCK);
while (mountproxy)
{
if (strcmp (mountproxy->mountname, source->mount) == 0)
......
......@@ -398,18 +398,10 @@ void *source_main(void *arg)
/* grab a read lock, to make sure we get a chance to cleanup */
thread_rwlock_rlock(source->shutdown_rwlock);
/* If we connected successfully, we can send the message (if requested)
* back
*/
if(source->send_return) {
source->client->respcode = 200;
bytes = sock_write(source->client->con->sock,
"HTTP/1.0 200 OK\r\n\r\n");
if(bytes > 0) source->client->con->sent_bytes = bytes;
}
/* start off the statistics */
source->listeners = 0;
stats_event_inc(NULL, "sources");
stats_event_inc(NULL, "source_total_connections");
stats_event(source->mount, "listeners", "0");
stats_event(source->mount, "type", source->format->format_description);
#ifdef USE_YP
......@@ -520,6 +512,7 @@ void *source_main(void *arg)
}
}
sock_set_blocking (source->con->sock, SOCK_NONBLOCK);
DEBUG0("Source creation complete");
source->running = 1;
......@@ -913,10 +906,25 @@ void source_apply_mount (source_t *source, mount_proxy *mountinfo)
void *source_client_thread (void *arg)
{
source_t *source = arg;
const char ok_msg[] = "HTTP/1.0 200 OK\r\n\r\n";
int bytes;
source->client->respcode = 200;
bytes = sock_write_bytes (source->client->con->sock, ok_msg, sizeof (ok_msg)-1);
if (bytes < sizeof (ok_msg)-1)
{
global_lock();
global.sources--;
global_unlock();
WARN0 ("Error writing 200 OK message to source client");
}
else
{
source->client->con->sent_bytes += bytes;
source->send_return = 1;
stats_event_inc(NULL, "source_client_connections");
source_main (source);
stats_event_inc(NULL, "source_client_connections");
source_main (source);
}
source_free_source (source);
return NULL;
}
......
......@@ -53,7 +53,6 @@ typedef struct source_tag
long listeners;
long max_listeners;
int yp_public;
int send_return;
struct auth_tag *authenticator;
int fallback_override;
int no_mount;
......
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