ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix possible connection leak appeared in 0.7.25



Hello!

Патч.

Исправление проблемы было любезно спонсировано Михаилом Монашёвым, 
им же протестировано в боевых условиях.

Подробности можно найти в этой рассылке - последний тред про это 
был с темой "Бага между 0.7.24 и 0.7.26".  Что именно происходит и 
как это воспроизводить я постарался описать в заголовке патча.

Maxim Dounin
# HG changeset patch
# User Maxim Dounin <mdounin@xxxxxxxxxx>
# Date 1240275056 -14400
# Node ID 195b3a3567a897e7795f79dd10ebab379bef4b3c
# Parent  0c98173187ac5eefad45ed8309e75e98f54210c1
Fix connection leak under some specific conditions.

Return code of ngx_http_output_filter() wasn't correctly checked in
ngx_http_writer() function.  This resulted in incorrect processing of
connections closed prematurely by clients - these connections were sometimes
closed due to timeouts (and hence higher numbers of 'Writing' connections
were observed in stub_status module compared to previous versions), and
sometimes permanently leaked.

Since the issue is racy it's hard to reproduce it without accept filters
used.   Though it's relatively easy too with

    listen ... accept_filter=httpready;
    sendfile_max_chunk  16k;

by requesting big file and closing client connection immediately.

The bug had appeared in 0.7.25.

diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -2098,6 +2098,11 @@ ngx_http_writer(ngx_http_request_t *r)
     ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,
                    "http writer output filter: %d, \"%V?%V\"",
                    rc, &r->uri, &r->args);
+
+    if (rc == NGX_ERROR) {
+        ngx_http_finalize_request(r, rc);
+        return;
+    }
 
     if (r->buffered || r->postponed || (r == r->main && c->buffered)) {
 


 




Copyright © Lexa Software, 1996-2009.