$OpenBSD: patch-ext_nginx_Configuration_c,v 1.1 2015/01/02 19:32:21 robert Exp $
--- ext/nginx/Configuration.c.orig	Fri Jan  2 20:15:18 2015
+++ ext/nginx/Configuration.c	Fri Jan  2 20:21:53 2015
@@ -256,14 +256,19 @@ passenger_create_loc_conf(ngx_conf_t *cf)
     conf->upstream_config.pass_request_body = NGX_CONF_UNSET;
 
 #if (NGX_HTTP_CACHE)
-    conf->upstream_config.cache = NGX_CONF_UNSET_PTR;
+    #if NGINX_VERSION_NUM >= 1007009
+        conf->upstream_config.cache = NGX_CONF_UNSET_PTR;
+    #else
+        conf->upstream_config.cache = NGX_CONF_UNSET;
+    #endif
     conf->upstream_config.cache_min_uses = NGX_CONF_UNSET_UINT;
     conf->upstream_config.cache_bypass = NGX_CONF_UNSET_PTR;
     conf->upstream_config.no_cache = NGX_CONF_UNSET_PTR;
     conf->upstream_config.cache_valid = NGX_CONF_UNSET_PTR;
-    #if NGINX_VERSION_NUM >= 1002000
-        conf->upstream_config.cache_lock = NGX_CONF_UNSET;
-        conf->upstream_config.cache_lock_timeout = NGX_CONF_UNSET_MSEC;
+    conf->upstream_config.cache_lock = NGX_CONF_UNSET;
+    conf->upstream_config.cache_lock_timeout = NGX_CONF_UNSET_MSEC;
+    #if NGINX_VERSION_NUM >= 1007008
+        conf->upstream_config.cache_lock_age = NGX_CONF_UNSET_MSEC;
     #endif
 #endif
 
@@ -294,9 +299,7 @@ passenger_create_loc_conf(ngx_conf_t *cf)
     DEFINE_VAR_TO_PASS("SERVER_ADDR",     "$server_addr");
     DEFINE_VAR_TO_PASS("SERVER_PORT",     "$server_port");
 
-#if NGINX_VERSION_NUM >= 1000010
     ngx_str_set(&conf->upstream_config.module, "passenger");
-#endif
 
     return conf;
 }
@@ -369,16 +372,35 @@ passenger_merge_loc_conf(ngx_conf_t *cf, void *parent,
     /******************************/
     /******************************/
 
-    if (conf->upstream_config.store != 0) {
-        ngx_conf_merge_value(conf->upstream_config.store,
-                                  prev->upstream_config.store, 0);
+    #if (NGX_HTTP_CACHE) && NGINX_VERSION_NUM >= 1007009
+        if (conf->upstream_config.store > 0) {
+            conf->upstream_config.cache = 0;
+        }
+        if (conf->upstream_config.cache > 0) {
+            conf->upstream_config.store = 0;
+        }
+    #endif
 
-        if (conf->upstream_config.store_lengths == NULL) {
+    #if NGINX_VERSION_NUM >= 1007009
+        if (conf->upstream_config.store == NGX_CONF_UNSET) {
+            ngx_conf_merge_value(conf->upstream_config.store,
+                                      prev->upstream_config.store, 0);
+
             conf->upstream_config.store_lengths = prev->upstream_config.store_lengths;
             conf->upstream_config.store_values = prev->upstream_config.store_values;
         }
-    }
+    #else
+        if (conf->upstream_config.store != 0) {
+            ngx_conf_merge_value(conf->upstream_config.store,
+                                      prev->upstream_config.store, 0);
 
+            if (conf->upstream_config.store_lengths == NULL) {
+                conf->upstream_config.store_lengths = prev->upstream_config.store_lengths;
+                conf->upstream_config.store_values = prev->upstream_config.store_values;
+            }
+        }
+    #endif
+
     ngx_conf_merge_uint_value(conf->upstream_config.store_access,
                               prev->upstream_config.store_access, 0600);
 
@@ -521,21 +543,48 @@ passenger_merge_loc_conf(ngx_conf_t *cf, void *parent,
 
 #if (NGX_HTTP_CACHE)
 
-    ngx_conf_merge_ptr_value(conf->upstream_config.cache,
-                             prev->upstream_config.cache, NULL);
+    #if NGINX_VERSION_NUM >= 1007009
+        if (conf->upstream_config.cache == NGX_CONF_UNSET) {
+           ngx_conf_merge_value(conf->upstream_config.cache,
+                                prev->upstream_config.cache, 0);
 
-    if (conf->upstream_config.cache && conf->upstream_config.cache->data == NULL) {
-        ngx_shm_zone_t  *shm_zone;
+           conf->upstream_config.cache_zone = prev->upstream_config.cache_zone;
+           conf->upstream_config.cache_value = prev->upstream_config.cache_value;
+        }
 
-        shm_zone = conf->upstream_config.cache;
+        if (conf->upstream_config.cache_zone && conf->upstream_config.cache_zone->data == NULL) {
+            ngx_shm_zone_t  *shm_zone;
 
-        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
-                           "\"scgi_cache\" zone \"%V\" is unknown",
-                           &shm_zone->shm.name);
+            shm_zone = conf->upstream_config.cache_zone;
 
-        return NGX_CONF_ERROR;
-    }
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "\"scgi_cache\" zone \"%V\" is unknown",
+                               &shm_zone->shm.name);
 
+            return NGX_CONF_ERROR;
+        }
+    #else
+        ngx_conf_merge_ptr_value(conf->upstream_config.cache,
+                                 prev->upstream_config.cache, NULL);
+
+        if (conf->upstream_config.cache && conf->upstream_config.cache->data == NULL) {
+            ngx_shm_zone_t  *shm_zone;
+
+            shm_zone = conf->upstream_config.cache;
+
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "\"scgi_cache\" zone \"%V\" is unknown",
+                               &shm_zone->shm.name);
+
+            return NGX_CONF_ERROR;
+        }
+    #endif
+
+    #if NGINX_VERSION_NUM >= 1007008
+        ngx_conf_merge_msec_value(conf->upstream_config.cache_lock_age,
+                                  prev->upstream_config.cache_lock_age, 5000);
+    #endif
+
     ngx_conf_merge_uint_value(conf->upstream_config.cache_min_uses,
                               prev->upstream_config.cache_min_uses, 1);
 
@@ -572,13 +621,11 @@ passenger_merge_loc_conf(ngx_conf_t *cf, void *parent,
         conf->cache_key = prev->cache_key;
     }
 
-    #if NGINX_VERSION_NUM >= 1002000
     ngx_conf_merge_value(conf->upstream_config.cache_lock,
                          prev->upstream_config.cache_lock, 0);
 
     ngx_conf_merge_msec_value(conf->upstream_config.cache_lock_timeout,
                               prev->upstream_config.cache_lock_timeout, 5000);
-    #endif
 
 #endif
 
