Browse Source

[core] connection_state_machine_loop()

extracted from connection_state_machine() (for reuse)
master
Glenn Strauss 1 year ago
parent
commit
8eea3bd014
  1. 33
      src/connections.c
  2. 2
      src/connections.h

33
src/connections.c

@ -1352,19 +1352,13 @@ static int connection_handle_request(request_st * const r) {
}
int connection_state_machine(connection *con) {
request_st * const r = &con->request;
request_state_t ostate;
int rc;
const int log_state_handling = r->conf.log_state_handling;
if (log_state_handling) {
log_error(r->conf.errh, __FILE__, __LINE__,
"state at enter %d %s", con->fd, connection_get_state(r->state));
}
static void
connection_state_machine_loop (request_st * const r, connection * const con)
{
request_state_t ostate;
do {
if (log_state_handling) {
if (r->conf.log_state_handling) {
log_error(r->conf.errh, __FILE__, __LINE__,
"state for fd %d %s", con->fd, connection_get_state(r->state));
}
@ -1431,13 +1425,26 @@ int connection_state_machine(connection *con) {
break;
}
} while (ostate != (request_state_t)r->state);
}
void connection_state_machine(connection *con) {
request_st * const r = &con->request;
const int log_state_handling = r->conf.log_state_handling;
if (log_state_handling) {
log_error(r->conf.errh, __FILE__, __LINE__,
"state at enter %d %s", con->fd, connection_get_state(r->state));
}
connection_state_machine_loop(r, con);
if (log_state_handling) {
log_error(r->conf.errh, __FILE__, __LINE__,
"state at exit: %d %s", con->fd, connection_get_state(r->state));
}
rc = 0;
int rc = 0;
switch(r->state) {
case CON_STATE_READ:
rc = FDEVENT_IN | FDEVENT_RDHUP;
@ -1488,8 +1495,6 @@ int connection_state_machine(connection *con) {
fdevent_fdnode_event_set(con->srv->ev, con->fdn, rc);
}
}
return 0;
}
static void connection_check_timeout (connection * const con, const time_t cur_ts) {

2
src/connections.h

@ -17,7 +17,7 @@ connection * connection_accepted(server *srv, server_socket *srv_socket, sock_ad
const char * connection_get_state(request_state_t state);
const char * connection_get_short_state(request_state_t state);
int connection_state_machine(connection *con);
void connection_state_machine(connection *con);
handler_t connection_handle_read_post_state(request_st *r);
__attribute_cold__

Loading…
Cancel
Save