[core] dev-only internal request state debugging
move request state debugging behind LIGHTTPD_DEBUG_REQUEST_SET_STATE debug.log-state-handling w/ #define LIGHTTPD_DEBUG_REQUEST_SET_STATE
This commit is contained in:
parent
1fdf2b29d1
commit
82ae5070fc
|
@ -91,11 +91,6 @@ static void connection_close(connection *con) {
|
|||
if (0 != fdio_close_socket(con->fd))
|
||||
log_serror(r->conf.errh, __FILE__, __LINE__,
|
||||
"(warning) close: %d", con->fd);
|
||||
|
||||
if (r->conf.log_state_handling) {
|
||||
log_error(r->conf.errh, __FILE__, __LINE__,
|
||||
"connection closed for fd %d", con->fd);
|
||||
}
|
||||
con->fd = -1;
|
||||
|
||||
--srv->cur_fds;
|
||||
|
@ -154,13 +149,8 @@ static void connection_handle_shutdown(connection *con) {
|
|||
if (con->fd >= 0
|
||||
&& (con->is_ssl_sock || 0 == shutdown(con->fd, SHUT_WR))) {
|
||||
con->close_timeout_ts = log_monotonic_secs;
|
||||
|
||||
request_st * const r = &con->request;
|
||||
connection_set_state(r, CON_STATE_CLOSE);
|
||||
if (r->conf.log_state_handling) {
|
||||
log_error(r->conf.errh, __FILE__, __LINE__,
|
||||
"shutdown for fd %d", con->fd);
|
||||
}
|
||||
} else {
|
||||
connection_close(con);
|
||||
}
|
||||
|
@ -611,11 +601,6 @@ connection *connection_accepted(server *srv, const server_socket *srv_socket, so
|
|||
|
||||
srv->cur_fds++;
|
||||
|
||||
/* ok, we have the connection, register it */
|
||||
#if 0
|
||||
log_error(srv->errh, __FILE__, __LINE__, "accepted() %d", cnt);
|
||||
#endif
|
||||
|
||||
con = connections_get_new_connection(srv);
|
||||
|
||||
con->fd = cnt;
|
||||
|
@ -649,28 +634,11 @@ connection *connection_accepted(server *srv, const server_socket *srv_socket, so
|
|||
}
|
||||
|
||||
|
||||
__attribute_cold__
|
||||
__attribute_noinline__
|
||||
__attribute_nonnull__()
|
||||
static void
|
||||
connection_log_state (const request_st * const r, const char * const tag)
|
||||
{
|
||||
buffer * const tb = r->tmp_buf;
|
||||
buffer_clear(tb);
|
||||
http_request_state_append(tb, r->state);
|
||||
log_error(r->conf.errh, __FILE__, __LINE__,
|
||||
"fd:%d id:%d state:%s%s", r->con->fd, r->x.h2.id, tb->ptr, tag);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
connection_state_machine_loop (request_st * const r, connection * const con)
|
||||
{
|
||||
request_state_t ostate;
|
||||
do {
|
||||
if (r->conf.log_state_handling)
|
||||
connection_log_state(r, "");
|
||||
|
||||
switch ((ostate = r->state)) {
|
||||
case CON_STATE_REQUEST_START: /* transient */
|
||||
/*(should not be reached by HTTP/2 streams)*/
|
||||
|
@ -733,13 +701,9 @@ connection_state_machine_loop (request_st * const r, connection * const con)
|
|||
case CON_STATE_CONNECT:
|
||||
break;
|
||||
default:/*(should not happen)*/
|
||||
/*connection_log_state(r, "");*/ /*(unknown state)*/
|
||||
break;
|
||||
}
|
||||
} while (ostate != r->state);
|
||||
|
||||
if (r->conf.log_state_handling)
|
||||
connection_log_state(r, " at loop exit");
|
||||
}
|
||||
|
||||
|
||||
|
|
13
src/h2.c
13
src/h2.c
|
@ -3189,10 +3189,6 @@ h2_process_streams (connection * const con,
|
|||
/* future: might track read/write interest per request
|
||||
* to avoid iterating through all active requests */
|
||||
/* specialized connection_state_machine_loop() for h2 streams */
|
||||
#if 0
|
||||
if (r->conf.log_state_handling)
|
||||
connection_log_state(r, "");
|
||||
#endif
|
||||
switch (r->state) {
|
||||
case CON_STATE_READ_POST:
|
||||
case CON_STATE_HANDLE_REQUEST:
|
||||
|
@ -3238,11 +3234,6 @@ h2_process_streams (connection * const con,
|
|||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (r->conf.log_state_handling)
|
||||
connection_log_state(r, " at loop exit");
|
||||
#endif
|
||||
|
||||
if (r->state < CON_STATE_WRITE)
|
||||
continue;
|
||||
/* else CON_STATE_WRITE, CON_STATE_RESPONSE_END, CON_STATE_ERROR */
|
||||
|
@ -3271,10 +3262,6 @@ h2_process_streams (connection * const con,
|
|||
continue;
|
||||
|
||||
request_set_state(r, CON_STATE_RESPONSE_END);
|
||||
#if 0
|
||||
if (__builtin_expect( (r->conf.log_state_handling), 0))
|
||||
connection_log_state(r, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
{/*(r->state==CON_STATE_RESPONSE_END || r->state==CON_STATE_ERROR)*/
|
||||
|
|
|
@ -223,6 +223,22 @@ request_set_state_error(request_st * const r, const request_state_t state)
|
|||
request_set_state(r, state);
|
||||
}
|
||||
|
||||
/* internal developer use; inlined in macro to log file and line of call site */
|
||||
#ifdef LIGHTTPD_DEBUG_REQUEST_SET_STATE
|
||||
#undef request_set_state
|
||||
#define request_set_state(r, n) do { \
|
||||
(r)->state = (n); \
|
||||
if ((r)->conf.log_state_handling) { \
|
||||
buffer * const tb = (r)->tmp_buf; \
|
||||
buffer_clear(tb); \
|
||||
http_request_state_append(tb, (r)->state); \
|
||||
log_error((r)->conf.errh, __FILE__, __LINE__, \
|
||||
"fd:%d id:%d state:%s", (r)->con->fd, (r)->x.h2.id, tb->ptr); \
|
||||
} \
|
||||
} while (0)
|
||||
#define request_set_state_error(r, n) request_set_state((r),(n))
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct http_header_parse_ctx {
|
||||
char *k;
|
||||
|
|
Loading…
Reference in New Issue