comparison src/http/ngx_http_upstream.c @ 384:09b703ae3ba5 NGINX_0_6_36

nginx 0.6.36 *) Change: now the "Invalid argument" error returned by setsockopt(TCP_NODELAY) on Solaris, is ignored. *) Change: now POSTs without "Content-Length" header line are allowed. *) Feature: the "try_files" directive. *) Feature: the --with-pcre option in the configure. *) Feature: the "if_modified_since" directive. *) Feature: the "$cookie_..." variables. *) Feature: the "$arg_..." variables. *) Bugfix: compatibility with Tru64 UNIX. Thanks to Dustin Marquess. *) Bugfix: a "ssl_engine" directive did not use a SSL-accelerator for asymmetric ciphers. Thanks to Marcin Gozdalik. *) Bugfix: in a redirect rewrite directive original arguments were concatenated with new arguments by a "?" rather than an "&"; the bug had appeared in 0.1.18. Thanks to Maxim Dounin. *) Bugfix: nginx could not be built on AIX. *) Bugfix: a double response might be returned if the epoll or rtsig methods are used and a redirect was returned to a request with body. Thanks to Eden Li. *) Bugfix: a segmentation fault might occur in worker process if "resolver" directive was used in SMTP proxy. *) Bugfix: fastcgi_store stored files not always. *) Bugfix: nginx did not process a FastCGI server response, if the server send too many messages to stderr before response.
author Igor Sysoev <http://sysoev.ru>
date Thu, 02 Apr 2009 00:00:00 +0400
parents e9979466be2f
children
comparison
equal deleted inserted replaced
383:3d40b0260a84 384:09b703ae3ba5
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;
1960 1957
1961 1958
1962 static void 1959 static void
1963 ngx_http_upstream_process_body(ngx_event_t *ev) 1960 ngx_http_upstream_process_body(ngx_event_t *ev)
1964 { 1961 {
1962 ngx_uint_t del;
1965 ngx_temp_file_t *tf; 1963 ngx_temp_file_t *tf;
1966 ngx_event_pipe_t *p; 1964 ngx_event_pipe_t *p;
1967 ngx_connection_t *c, *downstream; 1965 ngx_connection_t *c, *downstream;
1968 ngx_http_log_ctx_t *ctx; 1966 ngx_http_log_ctx_t *ctx;
1969 ngx_http_request_t *r; 1967 ngx_http_request_t *r;
2055 2053
2056 if (u->peer.connection) { 2054 if (u->peer.connection) {
2057 2055
2058 if (u->store) { 2056 if (u->store) {
2059 2057
2058 del = p->upstream_error;
2059
2060 tf = u->pipe->temp_file; 2060 tf = u->pipe->temp_file;
2061 2061
2062 if (p->upstream_eof 2062 if (p->upstream_eof || p->upstream_done) {
2063 && u->headers_in.status_n == NGX_HTTP_OK 2063
2064 && (u->headers_in.content_length_n == -1 2064 if (u->headers_in.status_n == NGX_HTTP_OK
2065 || (u->headers_in.content_length_n == tf->offset))) 2065 && (u->headers_in.content_length_n == -1
2066 { 2066 || (u->headers_in.content_length_n == tf->offset)))
2067 ngx_http_upstream_store(r, u); 2067 {
2068 2068 ngx_http_upstream_store(r, u);
2069 } else if ((p->upstream_error 2069
2070 || (p->upstream_eof 2070 } else {
2071 && u->headers_in.status_n != NGX_HTTP_OK)) 2071 del = 1;
2072 && tf->file.fd != NGX_INVALID_FILE) 2072 }
2073 { 2073 }
2074
2075 if (del && tf->file.fd != NGX_INVALID_FILE) {
2076
2074 if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) { 2077 if (ngx_delete_file(tf->file.name.data) == NGX_FILE_ERROR) {
2075 2078
2076 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, 2079 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
2077 ngx_delete_file_n " \"%s\" failed", 2080 ngx_delete_file_n " \"%s\" failed",
2078 u->pipe->temp_file->file.name.data); 2081 u->pipe->temp_file->file.name.data);