[PATCH 19/31] connection: process takes node, not con+args, cleanup error handeling (propagate)
Niv Sardi <[email protected]>
| Newsgroups | gmane.comp.audio.icecast.devel |
|---|---|
| Message-ID | <[email protected]> |
Signed-off-by: Niv Sardi <[email protected]> --- src/connection.c | 19 +++++++++---------- 1 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/connection.c b/src/connection.c index 9532bab..0e75fab 100644 --- a/src/connection.c +++ b/src/connection.c @@ -671,6 +671,7 @@ static int _connection_process (connection_queue_t *node) { http_parser_t *parser = NULL; int hdrsize = 0; int shoutcast = 0; + int err; char *shoutcast_mount = NULL; if (!node->refbuf) @@ -679,26 +680,24 @@ static int _connection_process (connection_queue_t *node) { hdrsize = util_read_header (node->con, header, HEADER_READ_ENTIRE); if (hdrsize < 0) { - global_unlock(); ERROR ("Header read failed"); - thread_sleep (400000); - return -1; + return hdrsize; } /* process normal HTTP headers */ parser = httpp_create_parser(); httpp_initialize(parser, NULL); - if (!httpp_parse (parser, header->data, hdrsize)) + err = httpp_parse (parser, header->data, hdrsize); + if (err == 0) { ERROR0("HTTP request parsing failed"); - client_destroy (client); - return -1; + return -EINVAL; } if (httpp_getvar (parser, HTTPP_VAR_ERROR_MESSAGE)) { ERROR("Error(%s)", httpp_getvar(parser, HTTPP_VAR_ERROR_MESSAGE)); - return -1; + return err; } if (header->sync_point && (parser->req_type == httpp_req_source || @@ -711,13 +710,13 @@ static int _connection_process (connection_queue_t *node) { } global_lock(); - if (client_create (&client, node->con, parser) < 0) + err = client_create (&client, node->con, parser); + if (err < 0) { global_unlock(); client_send_403 (client, "Icecast connection limit reached"); /* don't be too eager as this is an imposed hard limit */ - thread_sleep (400000); - return -1; + return err; } if (sock_set_blocking (client->con->sock, 0) || sock_set_nodelay (client->con->sock)) -- 1.7.1