Changeset 1233ec


Ignore:
Timestamp:
04/13/08 13:20:27 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master-v0.7, master-v0.6, upstream_count_limit
Children:
ca9838, f54237
Parents:
afcdaf (diff), 56389f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Tomash Brechko <tomash.brechko@…> (04/13/08 13:20:27)
git-committer:
Tomash Brechko <tomash.brechko@…> (04/13/08 13:20:27)
Message:

Merge branch 'memcached_gzip'

Files:
8 added
11 edited

Legend:

Unmodified
Added
Removed
  • server/src/core/nginx.c

    r0019fc r6a5335  
    274274    } 
    275275 
    276     /* ngx_crc32_init() requires ngx_cacheline_size set in ngx_os_init() */ 
    277  
    278     if (ngx_crc32_init() != NGX_OK) { 
     276    /* 
     277     * ngx_crc32_table_init() requires ngx_cacheline_size set in ngx_os_init() 
     278     */ 
     279 
     280    if (ngx_crc32_table_init() != NGX_OK) { 
    279281        return 1; 
    280282    } 
  • server/src/core/ngx_crc32.c

    r0019fc r6a5335  
    103103 
    104104ngx_int_t 
    105 ngx_crc32_init(void) 
     105ngx_crc32_table_init(void) 
    106106{ 
    107107    void  *p; 
  • server/src/core/ngx_crc32.h

    r0019fc r6a5335  
    5050 
    5151 
    52 ngx_int_t ngx_crc32_init(void); 
     52#define ngx_crc32_init(crc)                                                   \ 
     53    crc = 0xffffffff 
     54 
     55 
     56static ngx_inline void 
     57ngx_crc32_update(uint32_t *crc, u_char *p, size_t len) 
     58{ 
     59    uint32_t  c; 
     60 
     61    c = *crc; 
     62 
     63    while (len--) { 
     64        c = ngx_crc32_table256[(c ^ *p++) & 0xff] ^ (c >> 8); 
     65    } 
     66 
     67    *crc = c; 
     68} 
     69 
     70 
     71#define ngx_crc32_final(crc)                                                  \ 
     72    crc ^= 0xffffffff 
     73 
     74 
     75ngx_int_t ngx_crc32_table_init(void); 
    5376 
    5477 
  • server/src/core/ngx_string.h

    r0019fc r8760a9  
    6464#define ngx_memset(buf, c, n)     (void) memset(buf, c, n) 
    6565 
     66#define ngx_memmove(dst, src, n)  (void) memmove(dst, src, n) 
    6667 
    6768#if (NGX_MEMCPY_LIMIT) 
  • server/src/http/modules/ngx_http_fastcgi_module.c

    r0019fc r66a597  
    180180    { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, 
    181181    { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, 
     182    { ngx_string("http_502"), NGX_HTTP_UPSTREAM_FT_HTTP_502 }, 
    182183    { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, 
     184    { ngx_string("http_504"), NGX_HTTP_UPSTREAM_FT_HTTP_504 }, 
     185    { ngx_string("http_507"), NGX_HTTP_UPSTREAM_FT_HTTP_507 }, 
    183186    { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, 
    184187    { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, 
  • server/src/http/modules/ngx_http_gzip_filter_module.c

    r95d817 r21b759  
    629629                 * On decompression we could already output everything 
    630630                 * under (ctx->flush == Z_SYNC_FLUSH), so we test here 
    631                  * that the buffer is not empty. 
     631                 * that the buffer is not empty, or Transfer-Encoding: 
     632                 * is chunked.  In the latter case we output empty 
     633                 * buffer to get last zero length chunk. 
    632634                 */ 
    633                 if (!r->gunzip || ctx->out_buf->last > ctx->out_buf->pos) { 
     635                if (!r->gunzip || ctx->out_buf->last > ctx->out_buf->pos 
     636                    || r->chunked) { 
    634637                    cl->buf = ctx->out_buf; 
    635638                    cl->next = NULL; 
  • server/src/http/modules/ngx_http_memcached_module.c

    rb3076c r034113  
    1515    ngx_int_t                  index; 
    1616    ngx_uint_t                 gzip_flag; 
     17    ngx_int_t                  ns_index; 
    1718} ngx_http_memcached_loc_conf_t; 
    1819 
     
    159160 
    160161static ngx_str_t  ngx_http_memcached_key = ngx_string("memcached_key"); 
     162static ngx_str_t  ngx_http_memcached_ns = ngx_string("memcached_namespace"); 
    161163 
    162164 
     
    236238{ 
    237239    size_t                          len; 
    238     uintptr_t                       escape; 
     240    uintptr_t                       escape, ns_escape = 0; 
    239241    ngx_buf_t                      *b; 
    240242    ngx_chain_t                    *cl; 
    241243    ngx_http_memcached_ctx_t       *ctx; 
    242     ngx_http_variable_value_t      *vv; 
     244    ngx_http_variable_value_t      *vv, *ns_vv; 
    243245    ngx_http_memcached_loc_conf_t  *mlcf; 
    244246 
     
    255257    escape = 2 * ngx_escape_uri(NULL, vv->data, vv->len, NGX_ESCAPE_MEMCACHED); 
    256258 
    257     len = sizeof("get ") - 1 + vv->len + escape + sizeof(CRLF) - 1; 
     259    ns_vv = ngx_http_get_indexed_variable(r, mlcf->ns_index); 
     260 
     261    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     262        ns_escape = 2 * ngx_escape_uri(NULL, ns_vv->data, 
     263                                       ns_vv->len, NGX_ESCAPE_MEMCACHED); 
     264    } 
     265 
     266    len = sizeof("get ") - 1 + ns_vv->len + ns_escape 
     267                             + vv->len + escape + sizeof(CRLF) - 1; 
    258268 
    259269    b = ngx_create_temp_buf(r->pool, len); 
     
    277287 
    278288    ctx->key.data = b->last; 
     289 
     290    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     291        if (ns_escape == 0) { 
     292            b->last = ngx_copy(b->last, ns_vv->data, ns_vv->len); 
     293        } else { 
     294            b->last = (u_char *) ngx_escape_uri(b->last, ns_vv->data, 
     295                                                ns_vv->len, 
     296                                                NGX_ESCAPE_MEMCACHED); 
     297        } 
     298    } 
    279299 
    280300    if (escape == 0) { 
     
    589609     * 
    590610     *     conf->index = 0; 
     611     *     conf->ns_index = 0; 
    591612     */ 
    592613 
     
    698719    } 
    699720 
     721    lcf->ns_index = ngx_http_get_variable_index(cf, &ngx_http_memcached_ns); 
     722 
     723    if (lcf->ns_index == NGX_ERROR) { 
     724        return NGX_CONF_ERROR; 
     725    } 
     726 
    700727    return NGX_CONF_OK; 
    701728} 
  • server/src/http/modules/ngx_http_proxy_module.c

    ra64318 r66a597  
    134134    { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, 
    135135    { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, 
     136    { ngx_string("http_502"), NGX_HTTP_UPSTREAM_FT_HTTP_502 }, 
    136137    { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, 
     138    { ngx_string("http_504"), NGX_HTTP_UPSTREAM_FT_HTTP_504 }, 
     139    { ngx_string("http_507"), NGX_HTTP_UPSTREAM_FT_HTTP_507 }, 
    137140    { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, 
    138141    { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, 
  • server/src/http/ngx_http_upstream.c

    r0019fc r445d49  
    10941094    } 
    10951095 
     1096    if (u->headers_in.status_n == NGX_HTTP_BAD_GATEWAY) { 
     1097 
     1098        if (u->peer.tries > 1 
     1099            && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_502) 
     1100        { 
     1101            ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_502); 
     1102            return; 
     1103        } 
     1104    } 
     1105 
     1106    if (u->headers_in.status_n == NGX_HTTP_SERVICE_UNAVAILABLE) { 
     1107 
     1108        if (u->peer.tries > 1 
     1109            && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_503) 
     1110        { 
     1111            ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_503); 
     1112            return; 
     1113        } 
     1114    } 
     1115 
     1116    if (u->headers_in.status_n == NGX_HTTP_GATEWAY_TIME_OUT) { 
     1117 
     1118        if (u->peer.tries > 1 
     1119            && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_504) 
     1120        { 
     1121            ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_504); 
     1122            return; 
     1123        } 
     1124    } 
     1125 
     1126    if (u->headers_in.status_n == NGX_HTTP_INSUFFICIENT_STORAGE) { 
     1127 
     1128        if (u->peer.tries > 1 
     1129            && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_507) 
     1130        { 
     1131            ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_507); 
     1132            return; 
     1133        } 
     1134    } 
    10961135 
    10971136    if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST 
     
    21732212        switch(ft_type) { 
    21742213 
     2214        case NGX_HTTP_UPSTREAM_FT_HTTP_504: 
    21752215        case NGX_HTTP_UPSTREAM_FT_TIMEOUT: 
    21762216            status = NGX_HTTP_GATEWAY_TIME_OUT; 
     
    21832223        case NGX_HTTP_UPSTREAM_FT_HTTP_404: 
    21842224            status = NGX_HTTP_NOT_FOUND; 
     2225            break; 
     2226 
     2227        case NGX_HTTP_UPSTREAM_FT_HTTP_502: 
     2228            status = NGX_HTTP_BAD_GATEWAY; 
     2229            break; 
     2230 
     2231        case NGX_HTTP_UPSTREAM_FT_HTTP_503: 
     2232            status = NGX_HTTP_SERVICE_UNAVAILABLE; 
     2233            break; 
     2234 
     2235        case NGX_HTTP_UPSTREAM_FT_HTTP_507: 
     2236            status = NGX_HTTP_INSUFFICIENT_STORAGE; 
    21852237            break; 
    21862238 
     
    31393191    } 
    31403192 
     3193    us->name = u.url; 
    31413194    us->addrs = u.addrs; 
    31423195    us->naddrs = u.naddrs; 
  • server/src/http/ngx_http_upstream.h

    r0019fc r445d49  
    2525#define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK       0x00000080 
    2626#define NGX_HTTP_UPSTREAM_FT_MAX_WAITING     0x00000100 
     27#define NGX_HTTP_UPSTREAM_FT_HTTP_502        0x00000200 
     28#define NGX_HTTP_UPSTREAM_FT_HTTP_504        0x00000400 
     29#define NGX_HTTP_UPSTREAM_FT_HTTP_507        0x00000800 
    2730#define NGX_HTTP_UPSTREAM_FT_OFF             0x80000000 
    2831 
     
    6568 
    6669typedef struct { 
     70    ngx_str_t                       name; 
    6771    ngx_peer_addr_t                *addrs; 
    6872    ngx_uint_t                      naddrs; 
  • server/src/http/ngx_http_variables.c

    r0019fc r7bf8e1  
    13131313 
    13141314 
     1315static ngx_int_t 
     1316ngx_http_optional_variable(ngx_http_request_t *r, 
     1317    ngx_http_variable_value_t *v, uintptr_t data) 
     1318{ 
     1319    *v = ngx_http_variable_null_value; 
     1320    return NGX_OK; 
     1321} 
     1322 
     1323 
    13151324ngx_int_t 
    13161325ngx_http_variables_init_vars(ngx_conf_t *cf) 
     
    13741383        } 
    13751384 
     1385        if (ngx_strncmp(v[i].name.data, "memcached_namespace", 19) == 0) { 
     1386            v[i].get_handler = ngx_http_optional_variable; 
     1387 
     1388            continue; 
     1389        } 
     1390 
    13761391        ngx_log_error(NGX_LOG_EMERG, cf->log, 0, 
    13771392                      "unknown \"%V\" variable", &v[i].name); 
Note: See TracChangeset for help on using the changeset viewer.