comparison src/http/ngx_http_upstream.c @ 2639:8deee4408c94 stable-0.6

r2361 merge: read and process upstream header in cycle, this fixes the case when local FastCGI server sends many warnings in stderr
author Igor Sysoev <igor@sysoev.ru>
date Wed, 01 Apr 2009 15:51:04 +0000
parents afba93b8bf06
children 002f6fd88177
comparison
equal deleted inserted replaced
2638:a3f062177dba 2639:8deee4408c94
1097 u->buffer.last = u->buffer.pos; 1097 u->buffer.last = u->buffer.pos;
1098 } 1098 }
1099 #endif 1099 #endif
1100 } 1100 }
1101 1101
1102 n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last); 1102 for ( ;; ) {
1103 1103
1104 if (n == NGX_AGAIN) { 1104 n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
1105
1106 if (n == NGX_AGAIN) {
1105 #if 0 1107 #if 0
1106 ngx_add_timer(rev, u->read_timeout); 1108 ngx_add_timer(rev, u->read_timeout);
1107 #endif 1109 #endif
1108 1110
1109 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { 1111 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) {
1110 ngx_http_upstream_finalize_request(r, u, 1112 ngx_http_upstream_finalize_request(r, u,
1111 NGX_HTTP_INTERNAL_SERVER_ERROR); 1113 NGX_HTTP_INTERNAL_SERVER_ERROR);
1112 return; 1114 return;
1113 } 1115 }
1114 1116
1115 return; 1117 return;
1116 } 1118 }
1117 1119
1118 if (n == 0) { 1120 if (n == 0) {
1119 ngx_log_error(NGX_LOG_ERR, rev->log, 0, 1121 ngx_log_error(NGX_LOG_ERR, rev->log, 0,
1120 "upstream prematurely closed connection"); 1122 "upstream prematurely closed connection");
1121 } 1123 }
1122 1124
1123 if (n == NGX_ERROR || n == 0) { 1125 if (n == NGX_ERROR || n == 0) {
1124 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); 1126 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
1125 return; 1127 return;
1126 } 1128 }
1127 1129
1128 u->buffer.last += n; 1130 u->buffer.last += n;
1129 1131
1130 #if 0 1132 #if 0
1131 u->valid_header_in = 0; 1133 u->valid_header_in = 0;
1132 1134
1133 u->peer.cached = 0; 1135 u->peer.cached = 0;
1134 #endif 1136 #endif
1135 1137
1136 rc = u->process_header(r); 1138 rc = u->process_header(r);
1137 1139
1138 if (rc == NGX_AGAIN) { 1140 if (rc == NGX_AGAIN) {
1139 #if 0 1141
1140 ngx_add_timer(rev, u->read_timeout); 1142 if (u->buffer.pos == u->buffer.end) {
1141 #endif 1143 ngx_log_error(NGX_LOG_ERR, rev->log, 0,
1142 1144 "upstream sent too big header");
1143 if (u->buffer.pos == u->buffer.end) { 1145
1144 ngx_log_error(NGX_LOG_ERR, rev->log, 0, 1146 ngx_http_upstream_next(r, u,
1145 "upstream sent too big header"); 1147 NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);
1146 1148 return;
1147 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_INVALID_HEADER); 1149 }
1148 return; 1150
1149 } 1151 continue;
1150 1152 }
1151 if (ngx_handle_read_event(rev, 0) == NGX_ERROR) { 1153
1152 ngx_http_upstream_finalize_request(r, u, 1154 break;
1153 NGX_HTTP_INTERNAL_SERVER_ERROR);
1154 return;
1155 }
1156
1157 return;
1158 } 1155 }
1159 1156
1160 if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) { 1157 if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {
1161 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_INVALID_HEADER); 1158 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_INVALID_HEADER);
1162 return; 1159 return;