diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 2859b5419..ed9a7e8ee 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -2655,6 +2655,14 @@ ngx_http_post_request(ngx_http_request_t *r, ngx_http_posted_request_t *pr) { ngx_http_posted_request_t **p; + for (p = &r->main->posted_requests; *p; p = &(*p)->next) { + if ((*p)->request == r) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "http request already posted"); + return NGX_OK; + } + } + if (pr == NULL) { pr = ngx_palloc(r->pool, sizeof(ngx_http_posted_request_t)); if (pr == NULL) { @@ -2665,8 +2673,6 @@ ngx_http_post_request(ngx_http_request_t *r, ngx_http_posted_request_t *pr) pr->request = r; pr->next = NULL; - for (p = &r->main->posted_requests; *p; p = &(*p)->next) { /* void */ } - *p = pr; return NGX_OK; @@ -2786,6 +2792,8 @@ ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc) r->main->count--; + r->write_event_handler = ngx_http_request_empty_handler; + if (pr->postponed && pr->postponed->request == r) { pr->postponed = pr->postponed->next; }