mirror of
https://github.com/nginx/nginx.git
synced 2025-01-20 21:33:20 -06:00
*) ngx_http_ephemeral
*) use preallocated terminal_posted_request
This commit is contained in:
parent
8c491a77bc
commit
ddda411d14
@ -84,13 +84,17 @@ ngx_int_t ngx_http_find_server_conf(ngx_http_request_t *r);
|
||||
void ngx_http_update_location_config(ngx_http_request_t *r);
|
||||
void ngx_http_handler(ngx_http_request_t *r);
|
||||
void ngx_http_run_posted_requests(ngx_connection_t *c);
|
||||
ngx_int_t ngx_http_post_request(ngx_http_request_t *r);
|
||||
ngx_int_t ngx_http_post_request(ngx_http_request_t *r,
|
||||
ngx_http_posted_request_t *pr);
|
||||
void ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc);
|
||||
|
||||
void ngx_http_empty_handler(ngx_event_t *wev);
|
||||
void ngx_http_request_empty_handler(ngx_http_request_t *r);
|
||||
|
||||
|
||||
#define ngx_http_ephemeral(r) (ngx_http_ephemeral_t *) (&r->uri_start)
|
||||
|
||||
|
||||
#define NGX_HTTP_LAST 1
|
||||
#define NGX_HTTP_FLUSH 2
|
||||
|
||||
|
@ -2139,7 +2139,7 @@ ngx_http_subrequest(ngx_http_request_t *r,
|
||||
|
||||
*psr = sr;
|
||||
|
||||
return ngx_http_post_request(sr);
|
||||
return ngx_http_post_request(sr, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,7 +102,7 @@ ngx_http_postpone_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||
|
||||
c->data = pr->request;
|
||||
|
||||
return ngx_http_post_request(pr->request);
|
||||
return ngx_http_post_request(pr->request, NULL);
|
||||
}
|
||||
|
||||
if (pr->out == NULL) {
|
||||
|
@ -1810,13 +1810,15 @@ ngx_http_run_posted_requests(ngx_connection_t *c)
|
||||
|
||||
|
||||
ngx_int_t
|
||||
ngx_http_post_request(ngx_http_request_t *r)
|
||||
ngx_http_post_request(ngx_http_request_t *r, ngx_http_posted_request_t *pr)
|
||||
{
|
||||
ngx_http_posted_request_t *pr, **p;
|
||||
ngx_http_posted_request_t **p;
|
||||
|
||||
pr = ngx_palloc(r->pool, sizeof(ngx_http_posted_request_t));
|
||||
if (pr == NULL) {
|
||||
return NGX_ERROR;
|
||||
pr = ngx_palloc(r->pool, sizeof(ngx_http_posted_request_t));
|
||||
if (pr == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
pr->request = r;
|
||||
@ -1965,7 +1967,7 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
}
|
||||
}
|
||||
|
||||
if (ngx_http_post_request(pr) != NGX_OK) {
|
||||
if (ngx_http_post_request(pr, NULL) != NGX_OK) {
|
||||
r->main->count++;
|
||||
ngx_http_terminate_request(r, 0);
|
||||
return;
|
||||
@ -2025,8 +2027,9 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
static void
|
||||
ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
{
|
||||
ngx_http_cleanup_t *cln;
|
||||
ngx_http_request_t *mr;
|
||||
ngx_http_cleanup_t *cln;
|
||||
ngx_http_request_t *mr;
|
||||
ngx_http_ephemeral_t *e;
|
||||
|
||||
mr = r->main;
|
||||
|
||||
@ -2054,9 +2057,10 @@ ngx_http_terminate_request(ngx_http_request_t *r, ngx_int_t rc)
|
||||
return;
|
||||
}
|
||||
|
||||
e = ngx_http_ephemeral(mr);
|
||||
mr->posted_requests = NULL;
|
||||
mr->write_event_handler = ngx_http_terminate_handler;
|
||||
(void) ngx_http_post_request(mr);
|
||||
(void) ngx_http_post_request(mr, &e->terminal_posted_request);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -510,6 +510,21 @@ struct ngx_http_request_s {
|
||||
/* used to parse HTTP headers */
|
||||
|
||||
ngx_uint_t state;
|
||||
|
||||
ngx_uint_t header_hash;
|
||||
ngx_uint_t lowcase_index;
|
||||
u_char lowcase_header[NGX_HTTP_LC_HEADER_LEN];
|
||||
|
||||
u_char *header_name_start;
|
||||
u_char *header_name_end;
|
||||
u_char *header_start;
|
||||
u_char *header_end;
|
||||
|
||||
/*
|
||||
* a memory that can be reused after parsing a request line
|
||||
* via ngx_http_ephemeral_t
|
||||
*/
|
||||
|
||||
u_char *uri_start;
|
||||
u_char *uri_end;
|
||||
u_char *uri_ext;
|
||||
@ -523,20 +538,17 @@ struct ngx_http_request_s {
|
||||
u_char *host_end;
|
||||
u_char *port_start;
|
||||
u_char *port_end;
|
||||
u_char *header_name_start;
|
||||
u_char *header_name_end;
|
||||
u_char *header_start;
|
||||
u_char *header_end;
|
||||
|
||||
unsigned http_minor:16;
|
||||
unsigned http_major:16;
|
||||
|
||||
ngx_uint_t header_hash;
|
||||
ngx_uint_t lowcase_index;
|
||||
u_char lowcase_header[NGX_HTTP_LC_HEADER_LEN];
|
||||
};
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_http_posted_request_t terminal_posted_request;
|
||||
} ngx_http_ephemeral_t;
|
||||
|
||||
|
||||
extern ngx_http_header_t ngx_http_headers_in[];
|
||||
extern ngx_http_header_out_t ngx_http_headers_out[];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user