diff src/http/ngx_http_upstream.c @ 1378:0be898896d1a

backup upstream servers
author Igor Sysoev <igor@sysoev.ru>
date Thu, 09 Aug 2007 13:54:33 +0000
parents 32cdba6f2ec1
children 6c25a49e548a
line wrap: on
line diff
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -565,9 +565,11 @@ ngx_http_upstream_connect(ngx_http_reque
 
     if (rc == NGX_BUSY) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "no live upstreams");
+        ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_NOLIVE);
+        return;
     }
 
-    if (rc == NGX_BUSY || rc == NGX_DECLINED) {
+    if (rc == NGX_DECLINED) {
         ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR);
         return;
     }
@@ -2153,7 +2155,9 @@ ngx_http_upstream_next(ngx_http_request_
         state = NGX_PEER_FAILED;
     }
 
-    u->peer.free(&u->peer, u->peer.data, state);
+    if (ft_type != NGX_HTTP_UPSTREAM_FT_NOLIVE) {
+        u->peer.free(&u->peer, u->peer.data, state);
+    }
 
     if (ft_type == NGX_HTTP_UPSTREAM_FT_TIMEOUT) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_ETIMEDOUT,
@@ -3118,6 +3122,17 @@ ngx_http_upstream_server(ngx_conf_t *cf,
             continue;
         }
 
+        if (ngx_strncmp(value[i].data, "backup", 6) == 0) {
+
+            if (!(uscf->flags & NGX_HTTP_UPSTREAM_BACKUP)) {
+                goto invalid;
+            }
+
+            us->backup = 1;
+
+            continue;
+        }
+
         if (ngx_strncmp(value[i].data, "down", 4) == 0) {
 
             if (!(uscf->flags & NGX_HTTP_UPSTREAM_DOWN)) {