Browse Source

[core] move connections_get_state to connections.c

connections_get_state() is used only in connections.c for debugging
master
Glenn Strauss 1 year ago
parent
commit
d8b88be056
  1. 35
      src/connections-glue.c
  2. 22
      src/connections.c
  3. 2
      src/connections.h

35
src/connections-glue.c

@ -2,44 +2,9 @@
#include "base.h"
#include "connections.h"
#include "request.h"
#include <stdlib.h>
const char *connection_get_state(request_state_t state) {
switch (state) {
case CON_STATE_CONNECT: return "connect";
case CON_STATE_READ: return "read";
case CON_STATE_READ_POST: return "readpost";
case CON_STATE_WRITE: return "write";
case CON_STATE_CLOSE: return "close";
case CON_STATE_ERROR: return "error";
case CON_STATE_HANDLE_REQUEST: return "handle-req";
case CON_STATE_REQUEST_START: return "req-start";
case CON_STATE_REQUEST_END: return "req-end";
case CON_STATE_RESPONSE_START: return "resp-start";
case CON_STATE_RESPONSE_END: return "resp-end";
default: return "(unknown)";
}
}
const char *connection_get_short_state(request_state_t state) {
switch (state) {
case CON_STATE_CONNECT: return ".";
case CON_STATE_READ: return "r";
case CON_STATE_READ_POST: return "R";
case CON_STATE_WRITE: return "W";
case CON_STATE_CLOSE: return "C";
case CON_STATE_ERROR: return "E";
case CON_STATE_HANDLE_REQUEST: return "h";
case CON_STATE_REQUEST_START: return "q";
case CON_STATE_REQUEST_END: return "Q";
case CON_STATE_RESPONSE_START: return "s";
case CON_STATE_RESPONSE_END: return "S";
default: return "x";
}
}
__attribute_cold__
static void connection_list_resize(connections *conns) {
conns->size += 16;

22
src/connections.c

@ -998,6 +998,28 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
}
__attribute_cold__
__attribute_noinline__
static const char *
connection_get_state (request_state_t state)
{
switch (state) {
case CON_STATE_CONNECT: return "connect";
case CON_STATE_READ: return "read";
case CON_STATE_READ_POST: return "readpost";
case CON_STATE_WRITE: return "write";
case CON_STATE_CLOSE: return "close";
case CON_STATE_ERROR: return "error";
case CON_STATE_HANDLE_REQUEST: return "handle-req";
case CON_STATE_REQUEST_START: return "req-start";
case CON_STATE_REQUEST_END: return "req-end";
case CON_STATE_RESPONSE_START: return "resp-start";
case CON_STATE_RESPONSE_END: return "resp-end";
default: return "(unknown)";
}
}
static void
connection_state_machine_loop (request_st * const r, connection * const con)
{

2
src/connections.h

@ -15,8 +15,6 @@ void connection_periodic_maint (server *srv, time_t cur_ts);
connection * connection_accept(server *srv, server_socket *srv_sock);
connection * connection_accepted(server *srv, server_socket *srv_socket, sock_addr *cnt_addr, int cnt);
const char * connection_get_state(request_state_t state);
const char * connection_get_short_state(request_state_t state);
void connection_state_machine(connection *con);
#define joblist_append(con) connection_list_append((con)->srv->joblist, (con))

Loading…
Cancel
Save