output/httpd: add assertions
This commit is contained in:
parent
b7f435b50e
commit
7c887af1ea
@ -143,6 +143,8 @@ httpd_client_unref_page(gpointer data, G_GNUC_UNUSED gpointer user_data)
|
|||||||
void
|
void
|
||||||
httpd_client_free(struct httpd_client *client)
|
httpd_client_free(struct httpd_client *client)
|
||||||
{
|
{
|
||||||
|
assert(client != NULL);
|
||||||
|
|
||||||
if (client->state == RESPONSE) {
|
if (client->state == RESPONSE) {
|
||||||
if (client->write_source_id != 0)
|
if (client->write_source_id != 0)
|
||||||
g_source_remove(client->write_source_id);
|
g_source_remove(client->write_source_id);
|
||||||
@ -169,6 +171,8 @@ httpd_client_free(struct httpd_client *client)
|
|||||||
static void
|
static void
|
||||||
httpd_client_close(struct httpd_client *client)
|
httpd_client_close(struct httpd_client *client)
|
||||||
{
|
{
|
||||||
|
assert(client != NULL);
|
||||||
|
|
||||||
httpd_output_remove_client(client->httpd, client);
|
httpd_output_remove_client(client->httpd, client);
|
||||||
httpd_client_free(client);
|
httpd_client_free(client);
|
||||||
}
|
}
|
||||||
@ -179,6 +183,9 @@ httpd_client_close(struct httpd_client *client)
|
|||||||
static void
|
static void
|
||||||
httpd_client_begin_response(struct httpd_client *client)
|
httpd_client_begin_response(struct httpd_client *client)
|
||||||
{
|
{
|
||||||
|
assert(client != NULL);
|
||||||
|
assert(client->state != RESPONSE);
|
||||||
|
|
||||||
client->state = RESPONSE;
|
client->state = RESPONSE;
|
||||||
client->write_source_id = 0;
|
client->write_source_id = 0;
|
||||||
client->pages = g_queue_new();
|
client->pages = g_queue_new();
|
||||||
@ -239,6 +246,9 @@ httpd_client_handle_line(struct httpd_client *client, const char *line)
|
|||||||
static char *
|
static char *
|
||||||
httpd_client_read_line(struct httpd_client *client)
|
httpd_client_read_line(struct httpd_client *client)
|
||||||
{
|
{
|
||||||
|
assert(client != NULL);
|
||||||
|
assert(client->state != RESPONSE);
|
||||||
|
|
||||||
const char *p, *newline;
|
const char *p, *newline;
|
||||||
size_t length;
|
size_t length;
|
||||||
char *line;
|
char *line;
|
||||||
@ -271,6 +281,7 @@ httpd_client_send_response(struct httpd_client *client)
|
|||||||
GIOStatus status;
|
GIOStatus status;
|
||||||
gsize bytes_written;
|
gsize bytes_written;
|
||||||
|
|
||||||
|
assert(client != NULL);
|
||||||
assert(client->state == RESPONSE);
|
assert(client->state == RESPONSE);
|
||||||
|
|
||||||
if (!client->metadata_requested) {
|
if (!client->metadata_requested) {
|
||||||
@ -334,14 +345,19 @@ httpd_client_send_response(struct httpd_client *client)
|
|||||||
static bool
|
static bool
|
||||||
httpd_client_received(struct httpd_client *client)
|
httpd_client_received(struct httpd_client *client)
|
||||||
{
|
{
|
||||||
|
assert(client != NULL);
|
||||||
|
assert(client->state != RESPONSE);
|
||||||
|
|
||||||
char *line;
|
char *line;
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
while ((line = httpd_client_read_line(client)) != NULL) {
|
while ((line = httpd_client_read_line(client)) != NULL) {
|
||||||
success = httpd_client_handle_line(client, line);
|
success = httpd_client_handle_line(client, line);
|
||||||
g_free(line);
|
g_free(line);
|
||||||
if (!success)
|
if (!success) {
|
||||||
|
assert(client->state != RESPONSE);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (client->state == RESPONSE) {
|
if (client->state == RESPONSE) {
|
||||||
if (!fifo_buffer_is_empty(client->input)) {
|
if (!fifo_buffer_is_empty(client->input)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user