1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-29 04:25:55 -04:00

revert parser change, applied changes from rc feedback

svn path=/icecast/branches/kh/icecast/; revision=10023
This commit is contained in:
Karl Heyes 2005-09-16 22:13:49 +00:00
parent 8484f7456c
commit a5a9b7ac5d
13 changed files with 46 additions and 37 deletions

View File

@ -272,7 +272,7 @@ xmlDocPtr admin_build_sourcelist (const char *mount)
if (source->running)
{
if (source->client->con)
if (source->client)
{
snprintf (buf, sizeof(buf), "%lu",
(unsigned long)(now - source->client->con->con_time));

View File

@ -280,17 +280,18 @@ static int add_client_to_source (source_t *source, client_t *client)
return -1;
} while (1);
/* lets add the client to the active list */
client->next = source->active_clients;
source->active_clients = client;
source->listeners++;
stats_event_inc (NULL, "listener_connections");
client->write_to_client = format_generic_write_to_client;
client->check_buffer = format_check_http_buffer;
client->refbuf->len = PER_CLIENT_REFBUF_SIZE;
memset (client->refbuf->data, 0, PER_CLIENT_REFBUF_SIZE);
/* lets add the client to the active list */
client->next = source->active_clients;
source->active_clients = client;
source->listeners++;
stats_event_inc (NULL, "listener_connections");
thread_mutex_unlock (&source->lock);
if (source->running == 0 && source->on_demand)

View File

@ -613,7 +613,7 @@ void connection_accept_loop(void)
/* Called when activating a source. Verifies that the source count is not
* exceeded and applies any initial parameters.
*/
int connection_complete_source (source_t *source, http_parser_t *in_parser, int response)
int connection_complete_source (source_t *source, int response)
{
ice_config_t *config = config_get_config();
@ -625,13 +625,9 @@ int connection_complete_source (source_t *source, http_parser_t *in_parser, int
char *contenttype;
mount_proxy *mountinfo;
format_type_t format_type;
http_parser_t *parser = in_parser;
/* setup format handler */
if (source->client)
parser = source->client->parser;
contenttype = httpp_getvar (parser, "content-type");
contenttype = httpp_getvar (source->parser, "content-type");
if (contenttype != NULL)
{
format_type = format_get_type (contenttype);
@ -656,7 +652,7 @@ int connection_complete_source (source_t *source, http_parser_t *in_parser, int
format_type = FORMAT_TYPE_GENERIC;
}
if (format_get_plugin (format_type, source, parser) < 0)
if (format_get_plugin (format_type, source) < 0)
{
global_unlock();
config_release_config();
@ -881,7 +877,8 @@ static void _handle_source_request (client_t *client, char *uri, int auth_style)
source->shoutcast_compat = 1;
}
source->client = client;
if (connection_complete_source (source, NULL, 1) < 0)
source->parser = client->parser;
if (connection_complete_source (source, 1) < 0)
{
source_clear_source (source);
source_free_source (source);

View File

@ -55,8 +55,7 @@ void connection_shutdown(void);
void connection_accept_loop(void);
void connection_close(connection_t *con);
connection_t *connection_create (sock_t sock, sock_t serversock, char *ip);
int connection_complete_source (struct source_tag *source,
http_parser_t *parser, int response);
int connection_complete_source (struct source_tag *source, int response);
int connection_check_source_pass(http_parser_t *parser, const char *mount);
int connection_check_relay_pass(http_parser_t *parser);

View File

@ -75,7 +75,7 @@ void format_free_plugin (format_plugin_t *format)
}
int format_get_plugin (format_type_t type, source_t *source, http_parser_t *parser)
int format_get_plugin (format_type_t type, source_t *source)
{
int ret = -1;
@ -84,7 +84,7 @@ int format_get_plugin (format_type_t type, source_t *source, http_parser_t *pars
ret = format_ogg_get_plugin (source);
break;
case FORMAT_TYPE_GENERIC:
ret = format_mp3_get_plugin (source, parser);
ret = format_mp3_get_plugin (source);
break;
default:
break;
@ -289,8 +289,8 @@ static int format_prepare_headers (source_t *source, client_t *client)
ptr += bytes;
/* iterate through source http headers and send to client */
avl_tree_rlock (source->client->parser->vars);
node = avl_get_first (source->client->parser->vars);
avl_tree_rlock (source->parser->vars);
node = avl_get_first (source->parser->vars);
while (node)
{
int next = 1;
@ -317,7 +317,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
else
{
if (strcasecmp (var->name, "ice-password") &&
strcasecmp (var->name, "icy-metaint"))
strcasecmp (var->name, "icy-metaint"))
{
if (!strncasecmp ("ice-", var->name, 4))
{
@ -344,7 +344,7 @@ static int format_prepare_headers (source_t *source, client_t *client)
if (next)
node = avl_get_next (node);
}
avl_tree_unlock (source->client->parser->vars);
avl_tree_unlock (source->parser->vars);
bytes = snprintf (ptr, remaining, "Server: %s\r\n", ICECAST_VERSION_STRING);
remaining -= bytes;

View File

@ -58,7 +58,7 @@ typedef struct _format_plugin_tag
} format_plugin_t;
format_type_t format_get_type(char *contenttype);
int format_get_plugin(format_type_t type, struct source_tag *source, http_parser_t *p);
int format_get_plugin(format_type_t type, struct source_tag *source);
int format_generic_write_to_client (client_t *client);
int format_advance_queue (struct source_tag *source, client_t *client);

View File

@ -73,7 +73,7 @@ typedef struct {
refbuf_t *associated;
} mp3_client_data;
int format_mp3_get_plugin (source_t *source, http_parser_t *parser)
int format_mp3_get_plugin (source_t *source)
{
char *metadata;
format_plugin_t *plugin;
@ -91,7 +91,7 @@ int format_mp3_get_plugin (source_t *source, http_parser_t *parser)
plugin->set_tag = mp3_set_tag;
plugin->apply_settings = format_mp3_apply_settings;
plugin->contenttype = httpp_getvar (parser, "content-type");
plugin->contenttype = httpp_getvar (source->parser, "content-type");
if (plugin->contenttype == NULL) {
/* We default to MP3 audio for old clients without content types */
plugin->contenttype = "audio/mpeg";
@ -106,7 +106,7 @@ int format_mp3_get_plugin (source_t *source, http_parser_t *parser)
state->metadata = meta;
state->interval = -1;
metadata = httpp_getvar (parser, "icy-metaint");
metadata = httpp_getvar (source->parser, "icy-metaint");
if (metadata)
{
state->inline_metadata_interval = atoi (metadata);

View File

@ -37,6 +37,6 @@ typedef struct {
char build_metadata[4081];
} mp3_state;
int format_mp3_get_plugin(struct source_tag *src, http_parser_t *p);
int format_mp3_get_plugin(struct source_tag *src);
#endif /* __FORMAT_MP3_H__ */

View File

@ -419,9 +419,12 @@ int fserve_client_create (client_t *httpclient, const char *path)
{
if (strstr (agent, "QTS") || strstr (agent, "QuickTime"))
protocol = "icy";
if (strchr (agent, ':') == NULL)
host = NULL;
}
/* at least a couple of players (fb2k/winamp) are reported to send a
* host header but without the port number. So if we are missing the
* port then lets treat it as if no host line was sent */
if (host && strchr (host, ':') == NULL)
host = NULL;
*dot = 0;
httpclient->respcode = 200;

View File

@ -95,12 +95,11 @@ int get_clf_time (char *buffer, unsigned len, struct tm *t)
}
#endif
/*
** ADDR USER AUTH DATE REQUEST CODE BYTES REFERER AGENT [TIME]
** ADDR IDENT USER DATE REQUEST CODE BYTES REFERER AGENT [TIME]
**
** ADDR = client->con->ip
** USER = -
** we should do this for real once we support authentication
** AUTH = -
** IDENT = always - , we don't support it because it's useless
** USER = client->username
** DATE = _make_date(client->con->con_time)
** REQUEST = build from client->parser
** CODE = client->respcode
@ -116,7 +115,7 @@ void logging_access(client_t *client)
struct tm thetime;
time_t now;
time_t stayed;
char *referrer, *user_agent;
char *referrer, *user_agent, *username;
now = global.time;
@ -137,6 +136,11 @@ void logging_access(client_t *client)
stayed = now - client->con->con_time;
if (client->username == NULL)
username = "-";
else
username = client->username;
referrer = httpp_getvar (client->parser, "referer");
if (referrer == NULL)
referrer = "-";
@ -147,8 +151,9 @@ void logging_access(client_t *client)
#ifdef HAVE_LOGGING_IP
log_write_direct (accesslog,
"%s - - [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
"%s - %s [%s] \"%s\" %d " FORMAT_UINT64 " \"%s\" \"%s\" %lu",
client->con->ip,
username,
datebuf, reqbuf, client->respcode, client->con->sent_bytes,
referrer, user_agent, (unsigned long)stayed);
#else

View File

@ -309,6 +309,7 @@ static void *start_relay_stream (void *arg)
ERROR1("Error from relay request: %s", httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE));
break;
}
src->parser = parser;
global_lock ();
if (client_create (&src->client, con, parser) < 0)
@ -324,7 +325,7 @@ static void *start_relay_stream (void *arg)
parser = NULL;
client_set_queue (src->client, NULL);
if (connection_complete_source (src, NULL, 0) < 0)
if (connection_complete_source (src, 0) < 0)
{
DEBUG0("Failed to complete source initialisation");
break;

View File

@ -194,6 +194,7 @@ void source_clear_source (source_t *source)
DEBUG1 ("clearing source \"%s\"", source->mount);
client_destroy(source->client);
source->client = NULL;
source->parser = NULL;
if (source->dumpfile)
{
@ -1310,9 +1311,10 @@ static void *source_fallback_file (void *arg)
source->hidden = 1;
source->yp_public = 0;
source->intro_file = file;
source->parser = parser;
file = NULL;
if (connection_complete_source (source, parser, 0) < 0)
if (connection_complete_source (source, 0) < 0)
break;
source_client_thread (source);
httpp_destroy (parser);

View File

@ -23,6 +23,7 @@
typedef struct source_tag
{
client_t *client;
http_parser_t *parser;
time_t client_stats_update;
char *mount;