[core] remove connection_list_append()

merge connection_list_append() into connection_fdwaitqueue_append()

(not converted to singly-linked-list since fdwaitqueue is not expected
to be used during normal operation (except extreme overload condition),
so use allocated list of pointers (allocated when needed) instead of
adding ptr member to (every) allocated struct connection)

remove connections-glue.c
remove inclusion of connections.h by non-base files
This commit is contained in:
Glenn Strauss 2021-07-28 05:37:50 -04:00
parent dc2d1dfe47
commit 323e03fb2d
11 changed files with 12 additions and 29 deletions

View File

@ -758,7 +758,6 @@ set(COMMON_SRC
fdevent_poll.c fdevent_linux_sysepoll.c
fdevent_solaris_devpoll.c fdevent_solaris_port.c
fdevent_freebsd_kqueue.c
connections-glue.c
configfile-glue.c
http-header-glue.c
http_cgi.c

View File

@ -80,7 +80,6 @@ common_src=base64.c buffer.c burl.c log.c \
fdevent_poll.c fdevent_linux_sysepoll.c \
fdevent_solaris_devpoll.c fdevent_solaris_port.c \
fdevent_freebsd_kqueue.c \
connections-glue.c \
configfile-glue.c \
http-header-glue.c \
http_cgi.c \

View File

@ -64,7 +64,6 @@ common_src = Split("base64.c buffer.c burl.c log.c \
fdevent_poll.c fdevent_linux_sysepoll.c \
fdevent_solaris_devpoll.c fdevent_solaris_port.c \
fdevent_freebsd_kqueue.c \
connections-glue.c \
configfile-glue.c \
http-header-glue.c \
http_cgi.c \

View File

@ -1,18 +0,0 @@
#include "first.h"
#include "base.h"
#include "connections.h"
#include <stdlib.h>
__attribute_cold__
static void connection_list_resize(connections *conns) {
conns->size += 16;
conns->ptr = realloc(conns->ptr, sizeof(*conns->ptr) * conns->size);
force_assert(NULL != conns->ptr);
}
void connection_list_append(connections *conns, connection *con) {
if (conns->used == conns->size) connection_list_resize(conns);
conns->ptr[conns->used++] = con;
}

View File

@ -181,9 +181,20 @@ static void connection_handle_shutdown(connection *con) {
}
}
__attribute_cold__
static void connection_list_resize(connections *conns) {
conns->size += 16;
conns->ptr = realloc(conns->ptr, sizeof(*conns->ptr) * conns->size);
force_assert(NULL != conns->ptr);
}
__attribute_cold__
__attribute_noinline__
static void connection_fdwaitqueue_append(connection *con) {
connection_list_append(&con->srv->fdwaitqueue, con);
connections * const conns = &con->srv->fdwaitqueue;
if (conns->used == conns->size) connection_list_resize(conns);
conns->ptr[conns->used++] = con;
}

View File

@ -22,6 +22,4 @@ connection * connection_accepted(server *srv, const struct server_socket *srv_so
void connection_state_machine(connection *con);
void connection_list_append(connections *conns, connection *con);
#endif

View File

@ -1072,7 +1072,6 @@ static void gw_restart_dead_procs(gw_host * const host, log_error_st * const err
#include "base.h"
#include "connections.h"
#include "response.h"

View File

@ -717,7 +717,6 @@ common_src = [
'burl.c',
'chunk.c',
'configfile-glue.c',
'connections-glue.c',
'http_etag.c',
'fdevent_freebsd_kqueue.c',
'fdevent_libev.c',

View File

@ -4,7 +4,6 @@
#include "stat_cache.h"
#include "http_kv.h"
#include "log.h"
#include "connections.h"
#include "response.h"
#include "http_cgi.h"
#include "http_chunk.h"

View File

@ -16,7 +16,6 @@
#include "base.h"
#include "log.h"
#include "buffer.h"
#include "connections.h"/* joblist_append() */
#include "fdevent.h"
#include "http_chunk.h"
#include "http_header.h"

View File

@ -90,7 +90,6 @@
#include "fdevent.h"
#include "http_header.h"
#include "log.h"
#include "connections.h"
#define MOD_WEBSOCKET_LOG_NONE 0
#define MOD_WEBSOCKET_LOG_ERR 1