handle_connection(): factor out failure code
this allows us in a next step to replace goto fail with a call to that function, so we can see in a backtrace from where the failure was triggered.
This commit is contained in:
parent
b549ba5af3
commit
e94cbdb3a5
47
src/reqs.c
47
src/reqs.c
@ -1485,6 +1485,31 @@ get_request_entity(struct conn_s *connptr)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_connection_failure(struct conn_s *connptr)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* First, get the body if there is one.
|
||||||
|
* If we don't read all there is from the socket first,
|
||||||
|
* it is still marked for reading and we won't be able
|
||||||
|
* to send our data properly.
|
||||||
|
*/
|
||||||
|
if (get_request_entity (connptr) < 0) {
|
||||||
|
log_message (LOG_WARNING,
|
||||||
|
"Could not retrieve request entity");
|
||||||
|
indicate_http_error (connptr, 400, "Bad Request",
|
||||||
|
"detail",
|
||||||
|
"Could not retrieve the request entity "
|
||||||
|
"the client.", NULL);
|
||||||
|
update_stats (STAT_BADCONN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connptr->error_variables) {
|
||||||
|
send_http_error_message (connptr);
|
||||||
|
} else if (connptr->show_stats) {
|
||||||
|
showstats (connptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is the main drive for each connection. As you can tell, for the
|
* This is the main drive for each connection. As you can tell, for the
|
||||||
@ -1712,27 +1737,7 @@ e401:
|
|||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
/*
|
handle_connection_failure(connptr);
|
||||||
* First, get the body if there is one.
|
|
||||||
* If we don't read all there is from the socket first,
|
|
||||||
* it is still marked for reading and we won't be able
|
|
||||||
* to send our data properly.
|
|
||||||
*/
|
|
||||||
if (get_request_entity (connptr) < 0) {
|
|
||||||
log_message (LOG_WARNING,
|
|
||||||
"Could not retrieve request entity");
|
|
||||||
indicate_http_error (connptr, 400, "Bad Request",
|
|
||||||
"detail",
|
|
||||||
"Could not retrieve the request entity "
|
|
||||||
"the client.", NULL);
|
|
||||||
update_stats (STAT_BADCONN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connptr->error_variables) {
|
|
||||||
send_http_error_message (connptr);
|
|
||||||
} else if (connptr->show_stats) {
|
|
||||||
showstats (connptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
free_request_struct (request);
|
free_request_struct (request);
|
||||||
|
Loading…
Reference in New Issue
Block a user