comparison src/http/ngx_http_upstream.c @ 5883:973ee2276300

Upstream: proxy_limit_rate and friends. The directives limit the upstream read rate. For example, "proxy_limit_rate 42" limits proxy upstream read rate to 42 bytes per second.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 28 Oct 2014 12:29:59 +0300
parents 2c89956b6a76
children 5a042519bfe7
comparison
equal deleted inserted replaced
5882:ec81934727a1 5883:973ee2276300
2577 p->busy_size = u->conf->busy_buffers_size; 2577 p->busy_size = u->conf->busy_buffers_size;
2578 p->upstream = u->peer.connection; 2578 p->upstream = u->peer.connection;
2579 p->downstream = c; 2579 p->downstream = c;
2580 p->pool = r->pool; 2580 p->pool = r->pool;
2581 p->log = c->log; 2581 p->log = c->log;
2582 p->limit_rate = u->conf->limit_rate;
2583 p->start_sec = ngx_time();
2582 2584
2583 p->cacheable = u->cacheable || u->store; 2585 p->cacheable = u->cacheable || u->store;
2584 2586
2585 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t)); 2587 p->temp_file = ngx_pcalloc(r->pool, sizeof(ngx_temp_file_t));
2586 if (p->temp_file == NULL) { 2588 if (p->temp_file == NULL) {
3251 3253
3252 static void 3254 static void
3253 ngx_http_upstream_process_upstream(ngx_http_request_t *r, 3255 ngx_http_upstream_process_upstream(ngx_http_request_t *r,
3254 ngx_http_upstream_t *u) 3256 ngx_http_upstream_t *u)
3255 { 3257 {
3258 ngx_event_t *rev;
3259 ngx_event_pipe_t *p;
3256 ngx_connection_t *c; 3260 ngx_connection_t *c;
3257 3261
3258 c = u->peer.connection; 3262 c = u->peer.connection;
3263 p = u->pipe;
3264 rev = c->read;
3259 3265
3260 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, 3266 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
3261 "http upstream process upstream"); 3267 "http upstream process upstream");
3262 3268
3263 c->log->action = "reading upstream"; 3269 c->log->action = "reading upstream";
3264 3270
3265 if (c->read->timedout) { 3271 if (rev->timedout) {
3266 u->pipe->upstream_error = 1; 3272
3267 ngx_connection_error(c, NGX_ETIMEDOUT, "upstream timed out"); 3273 if (rev->delayed) {
3274
3275 rev->timedout = 0;
3276 rev->delayed = 0;
3277
3278 if (!rev->ready) {
3279 ngx_add_timer(rev, p->read_timeout);
3280
3281 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
3282 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
3283 }
3284
3285 return;
3286 }
3287
3288 if (ngx_event_pipe(p, 0) == NGX_ABORT) {
3289 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
3290 return;
3291 }
3292
3293 } else {
3294 p->upstream_error = 1;
3295 ngx_connection_error(c, NGX_ETIMEDOUT, "upstream timed out");
3296 }
3268 3297
3269 } else { 3298 } else {
3270 if (ngx_event_pipe(u->pipe, 0) == NGX_ABORT) { 3299
3300 if (rev->delayed) {
3301
3302 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
3303 "http upstream delayed");
3304
3305 if (ngx_handle_read_event(rev, 0) != NGX_OK) {
3306 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
3307 }
3308
3309 return;
3310 }
3311
3312 if (ngx_event_pipe(p, 0) == NGX_ABORT) {
3271 ngx_http_upstream_finalize_request(r, u, NGX_ERROR); 3313 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
3272 return; 3314 return;
3273 } 3315 }
3274 } 3316 }
3275 3317