diff options
author | Max Kellermann <max@duempel.org> | 2011-08-24 01:47:10 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-08-24 01:47:10 +0200 |
commit | 5ecb6fecc478733622aa33aaf4e6997f618bd006 (patch) | |
tree | 8a022436fa867d45f6026ccf8a629d99604da1ac /src/output/httpd_client.c | |
parent | eea726740bf222a92885b0f3c3c1255a5b04cd01 (diff) | |
parent | b3df4dc2c92d27034eaf9cef52e97a6e39c77d2e (diff) | |
download | mpd-5ecb6fecc478733622aa33aaf4e6997f618bd006.tar.gz mpd-5ecb6fecc478733622aa33aaf4e6997f618bd006.tar.xz mpd-5ecb6fecc478733622aa33aaf4e6997f618bd006.zip |
Merge branch 'v0.16.x'
Diffstat (limited to 'src/output/httpd_client.c')
-rw-r--r-- | src/output/httpd_client.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/output/httpd_client.c b/src/output/httpd_client.c index 32f355a43..e2c49c6c8 100644 --- a/src/output/httpd_client.c +++ b/src/output/httpd_client.c @@ -143,6 +143,8 @@ httpd_client_unref_page(gpointer data, G_GNUC_UNUSED gpointer user_data) void httpd_client_free(struct httpd_client *client) { + assert(client != NULL); + if (client->state == RESPONSE) { if (client->write_source_id != 0) g_source_remove(client->write_source_id); @@ -169,6 +171,8 @@ httpd_client_free(struct httpd_client *client) static void httpd_client_close(struct httpd_client *client) { + assert(client != NULL); + httpd_output_remove_client(client->httpd, client); httpd_client_free(client); } @@ -179,6 +183,9 @@ httpd_client_close(struct httpd_client *client) static void httpd_client_begin_response(struct httpd_client *client) { + assert(client != NULL); + assert(client->state != RESPONSE); + client->state = RESPONSE; client->write_source_id = 0; client->pages = g_queue_new(); @@ -239,6 +246,9 @@ httpd_client_handle_line(struct httpd_client *client, const char *line) static char * httpd_client_read_line(struct httpd_client *client) { + assert(client != NULL); + assert(client->state != RESPONSE); + const char *p, *newline; size_t length; char *line; @@ -271,6 +281,7 @@ httpd_client_send_response(struct httpd_client *client) GIOStatus status; gsize bytes_written; + assert(client != NULL); assert(client->state == RESPONSE); if (!client->metadata_requested) { @@ -334,14 +345,19 @@ httpd_client_send_response(struct httpd_client *client) static bool httpd_client_received(struct httpd_client *client) { + assert(client != NULL); + assert(client->state != RESPONSE); + char *line; bool success; while ((line = httpd_client_read_line(client)) != NULL) { success = httpd_client_handle_line(client, line); g_free(line); - if (!success) + if (!success) { + assert(client->state != RESPONSE); return false; + } if (client->state == RESPONSE) { if (!fifo_buffer_is_empty(client->input)) { @@ -370,7 +386,14 @@ httpd_client_read(struct httpd_client *client) if (client->state == RESPONSE) { /* the client has already sent the request, and he must not send more */ - g_warning("unexpected input from client"); + char buffer[1]; + + status = g_io_channel_read_chars(client->channel, buffer, + sizeof(buffer), &bytes_read, + NULL); + if (status == G_IO_STATUS_NORMAL) + g_warning("unexpected input from client"); + return false; } |