Commit 400d297a authored by Karl Heyes's avatar Karl Heyes

merge fix, oddcast (maybe other shoutcast source clients) don't wait for OK

response, so we may have surplus data already read, so keep it.

svn path=/icecast/trunk/icecast/; revision=9772
parent 98d569bb
......@@ -120,7 +120,7 @@ int client_read_bytes (client_t *client, void *buf, unsigned len)
if (client->refbuf->len < len)
len = client->refbuf->len;
memcpy (buf, client->refbuf->data, len);
if (client->refbuf->len < len)
if (len < client->refbuf->len)
{
char *ptr = client->refbuf->data;
memmove (ptr, ptr+len, client->refbuf->len - len);
......
......@@ -765,10 +765,14 @@ static void _handle_source_request (client_t *client, char *uri, int auth_style)
}
else
{
refbuf_t *ok = refbuf_new (PER_CLIENT_REFBUF_SIZE);
client->respcode = 200;
snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE,
snprintf (ok->data, PER_CLIENT_REFBUF_SIZE,
"HTTP/1.0 200 OK\r\n\r\n");
client->refbuf->len = strlen (client->refbuf->data);
ok->len = strlen (ok->data);
/* we may have unprocessed data read in, so don't overwrite it */
ok->associated = client->refbuf;
client->refbuf = ok;
fserve_add_client_callback (client, source_client_callback, source);
}
}
......
......@@ -1200,6 +1200,7 @@ void source_client_callback (client_t *client, void *arg)
{
const char *agent;
source_t *source = arg;
refbuf_t *old_data = client->refbuf;
if (client->con->error)
{
......@@ -1210,6 +1211,9 @@ void source_client_callback (client_t *client, void *arg)
client_destroy (client);
return;
}
client->refbuf = old_data->associated;
old_data->associated = NULL;
refbuf_release (old_data);
stats_event (source->mount, "source_ip", source->client->con->ip);
agent = httpp_getvar (source->client->parser, "user-agent");
if (agent)
......
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