Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: обработка nginx-ом stderr полученного от fastcgi сервера
On Thu, Nov 27, 2008 at 05:51:40PM +0200, Alexandr Gevlichenko wrote:
> Работает связка nginx+php-fpm.(nginx 7.22, centos 5.2)
> При получении от php-fpm сообщений в stderr(warnings¬ice) nginx не верно
> обрабатывает их, поведение напоминает переполнение буфера для stderr.
Прилагаемый патч должен исправить ошибку.
--
Игорь Сысоев
http://sysoev.ru
Index: src/http/ngx_http_upstream.c
===================================================================
--- src/http/ngx_http_upstream.c (revision 1676)
+++ src/http/ngx_http_upstream.c (working copy)
@@ -1114,42 +1114,46 @@
#endif
}
- n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
+ do {
- if (n == NGX_AGAIN) {
+ n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
+
+ if (n == NGX_AGAIN) {
#if 0
- ngx_add_timer(rev, u->read_timeout);
+ ngx_add_timer(rev, u->read_timeout);
#endif
- if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
- ngx_http_upstream_finalize_request(r, u,
+ if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
+ ngx_http_upstream_finalize_request(r, u,
NGX_HTTP_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
return;
}
- return;
- }
+ if (n == 0) {
+ ngx_log_error(NGX_LOG_ERR, rev->log, 0,
+ "upstream prematurely closed connection");
+ }
- if (n == 0) {
- ngx_log_error(NGX_LOG_ERR, rev->log, 0,
- "upstream prematurely closed connection");
- }
+ if (n == NGX_ERROR || n == 0) {
+ ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
+ return;
+ }
- if (n == NGX_ERROR || n == 0) {
- ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
- return;
- }
+ u->buffer.last += n;
- u->buffer.last += n;
-
#if 0
- u->valid_header_in = 0;
+ u->valid_header_in = 0;
- u->peer.cached = 0;
+ u->peer.cached = 0;
#endif
- rc = u->process_header(r);
+ rc = u->process_header(r);
+ } while (rc == NGX_AGAIN && u->buffer.pos < u->buffer.end);
+
if (rc == NGX_AGAIN) {
#if 0
ngx_add_timer(rev, u->read_timeout);
|