summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2023-04-09 18:39:48 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2023-04-29 16:29:21 -0400
commita2555e50972b8dec4cfa1a414655732a9a6b8772 (patch)
treeb1b5032fd5f67cb3869d5b8c56d6b602d8607647 /src
parent51f5607c6dc6873e3a2fa6f8a15293cc06797774 (diff)
downloadlighttpd-git-a2555e50972b8dec4cfa1a414655732a9a6b8772.tar.gz
[core] r->x union w/ structs for r->x.{h1}
Diffstat (limited to 'src')
-rw-r--r--src/connections.c19
-rw-r--r--src/h2.c2
-rw-r--r--src/reqpool.c11
-rw-r--r--src/request.h17
4 files changed, 29 insertions, 20 deletions
diff --git a/src/connections.c b/src/connections.c
index 51e03f22..4b892701 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -214,8 +214,8 @@ static void connection_handle_response_end_state(request_st * const r, connectio
con->is_readable = 1; /* potentially trigger optimistic read */
/*(accounting used by mod_accesslog for HTTP/1.0 and HTTP/1.1)*/
/*(overloaded to detect next bytes recv'd on keep-alive con)*/
- r->bytes_read_ckpt = r->read_queue.bytes_in;
- r->bytes_written_ckpt = r->write_queue.bytes_out;
+ r->x.h1.bytes_read_ckpt = r->read_queue.bytes_in;
+ r->x.h1.bytes_written_ckpt = r->write_queue.bytes_out;
#if 0
r->start_hp.tv_sec = log_epoch_secs;
con->read_idle_ts = log_monotonic_secs;
@@ -556,8 +556,6 @@ void connections_free(server *srv) {
static void connection_reset(connection *con) {
request_st * const r = &con->request;
request_reset(r);
- r->bytes_read_ckpt = 0;
- r->bytes_written_ckpt = 0;
con->is_readable = 1;
con->bytes_written_cur_second = 0;
}
@@ -684,7 +682,6 @@ connection_check_upgrade (request_st * const r, connection * const con)
/*(Upgrade: h2c over cleartext does not have SNI; no COMP_HTTP_HOST)*/
r->conditional_is_valid = (1 << COMP_SERVER_SOCKET)
| (1 << COMP_HTTP_REMOTE_IP);
- r->bytes_read_ckpt = 0;
/*connection_handle_write(r, con);*//* defer write to network */
return 1;
}
@@ -710,7 +707,7 @@ static int connection_handle_read_state(connection * const con) {
if (con->request_count > 1) {
discard_blank = 1;
- if (cq->bytes_in == r->bytes_read_ckpt) {
+ if (cq->bytes_in == r->x.h1.bytes_read_ckpt) {
keepalive_request_start = 1;
if (NULL != c) { /* !chunkqueue_is_empty(cq)) */
pipelined_request_start = 1;
@@ -783,7 +780,7 @@ static int connection_handle_read_state(connection * const con) {
} while ((c = connection_read_header_more(con, cq, c, clen)));
if (keepalive_request_start) {
- if (cq->bytes_in > r->bytes_read_ckpt) {
+ if (cq->bytes_in > r->x.h1.bytes_read_ckpt) {
/* update r->start_hp.tv_sec timestamp when first byte of
* next request is received on a keep-alive connection */
r->start_hp.tv_sec = log_epoch_secs;
@@ -805,9 +802,9 @@ static int connection_handle_read_state(connection * const con) {
char * const hdrs = c->mem->ptr + hoff[1];
if (con->request_count > 1) {
- /* adjust r->bytes_read_ckpt for http_request_stats_bytes_in()
+ /* adjust r->x.h1.bytes_read_ckpt for http_request_stats_bytes_in()
* (headers_len is still in cq; marked written, bytes_out incr below) */
- r->bytes_read_ckpt = cq->bytes_out;
+ r->x.h1.bytes_read_ckpt = cq->bytes_out;
/* clear buffers which may have been kept for reporting on keep-alive,
* (e.g. mod_status) */
request_reset_ex(r);
@@ -1440,7 +1437,7 @@ connection_handle_read_post_chunked (request_st * const r, chunkqueue * const cq
{
/* r->conf.max_request_size is in kBytes */
const off_t max_request_size = (off_t)r->conf.max_request_size << 10;
- off_t te_chunked = r->te_chunked;
+ off_t te_chunked = r->x.h1.te_chunked;
do {
off_t len = chunkqueue_length(cq);
@@ -1594,7 +1591,7 @@ connection_handle_read_post_chunked (request_st * const r, chunkqueue * const cq
} while (!chunkqueue_is_empty(cq));
- r->te_chunked = te_chunked;
+ r->x.h1.te_chunked = te_chunked;
return HANDLER_GO_ON;
}
diff --git a/src/h2.c b/src/h2.c
index 8c463175..49582af7 100644
--- a/src/h2.c
+++ b/src/h2.c
@@ -3031,7 +3031,7 @@ h2_con_upgrade_h2c (request_st * const h2r, connection * const con)
#endif
#if 0 /* expect empty request body */
r->reqbody_length = h2r->reqbody_length; /* currently always 0 */
- r->te_chunked = h2r->te_chunked; /* must be 0 */
+ r->x.h1.te_chunked = h2r->x.h1.te_chunked;/*must be 0 before r->x.h2 above*/
r->resp_body_scratchpad = h2r->resp_body_scratchpad; /*(not started yet)*/
swap(&r->reqbody_queue,&h2r->reqbody_queue);/*currently always empty queue*/
#endif
diff --git a/src/reqpool.c b/src/reqpool.c
index 1e6e7f29..7f640e66 100644
--- a/src/reqpool.c
+++ b/src/reqpool.c
@@ -87,8 +87,14 @@ request_reset (request_st * const r)
r->loops_per_request = 0;
r->keep_alive = 0;
- r->h2state = 0; /* H2_STATE_IDLE */
- r->h2id = 0;
+ memset(&r->x, 0, sizeof(r->x));
+ /* clear initial members of r->x union */
+ /*r->x.h1.bytes_written_ckpt = 0;*/
+ /*r->x.h1.bytes_read_ckpt = 0;*/
+ /*r->x.h1.te_chunked = 0;*/
+ /*r->x.h2.state = 0;*/ /* H2_STATE_IDLE */
+ /*r->x.h2.id = 0;*/
+
r->http_method = HTTP_METHOD_UNSET;
r->http_version = HTTP_VERSION_UNSET;
@@ -96,7 +102,6 @@ request_reset (request_st * const r)
r->http_host = NULL;
r->reqbody_length = 0;
- r->te_chunked = 0;
r->resp_body_scratchpad = -1;
r->rqst_htags = 0;
diff --git a/src/request.h b/src/request.h
index 8e581aff..b7c51018 100644
--- a/src/request.h
+++ b/src/request.h
@@ -129,6 +129,14 @@ struct request_st {
int16_t h2_rwin_fudge;
uint8_t h2_prio;
+ union {
+ struct {
+ off_t bytes_written_ckpt; /*used by http_request_stats_bytes_out()*/
+ off_t bytes_read_ckpt; /*used by http_request_stats_bytes_in() */
+ off_t te_chunked;
+ } h1;
+ } x;
+
http_method_t http_method;
http_version_t http_version;
@@ -154,7 +162,6 @@ struct request_st {
array env; /* used to pass lighttpd internal stuff */
off_t reqbody_length; /* request Content-Length */
- off_t te_chunked;
off_t resp_body_scratchpad;
buffer *http_host; /* copy of array value buffer ptr; not alloc'ed */
@@ -186,8 +193,6 @@ struct request_st {
buffer *tmp_buf; /* shared; same as srv->tmp_buf */
response_dechunk *gw_dechunk;
- off_t bytes_written_ckpt; /* used by mod_accesslog */
- off_t bytes_read_ckpt; /* used by mod_accesslog */
unix_timespec64_t start_hp;
int error_handler_saved_status; /* error-handler */
@@ -265,10 +270,12 @@ int64_t li_restricted_strtoint64 (const char *v, const uint32_t vlen, const char
: http_request_state_short((con)->request.state))
#define http_request_stats_bytes_in(r) \
- ((r)->read_queue.bytes_out - (r)->bytes_read_ckpt)
+ ((r)->read_queue.bytes_out \
+ - ((r)->http_version > HTTP_VERSION_1_1 ? 0 : (r)->x.h1.bytes_read_ckpt))
#define http_request_stats_bytes_out(r) \
- ((r)->write_queue.bytes_out - (r)->bytes_written_ckpt)
+ ((r)->write_queue.bytes_out \
+ - ((r)->http_version > HTTP_VERSION_1_1 ? 0 : (r)->x.h1.bytes_written_ckpt))
__attribute_pure__
const char * http_request_state_short (request_state_t state);