Ignore:
Timestamp:
02/19/08 16:28:06 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master-v0.7, master-v0.6, upstream_count_limit
Children:
034113
Parents:
2a12f7 (diff), 2340f0 (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@…> (02/19/08 16:28:06)
git-committer:
Tomash Brechko <tomash.brechko@…> (02/19/08 16:28:06)
Message:

Merge branch 'memcached_hash'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/src/http/modules/ngx_http_memcached_module.c

    re1c857 rc79fa6  
    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 
     
    158159 
    159160static ngx_str_t  ngx_http_memcached_key = ngx_string("memcached_key"); 
     161static ngx_str_t  ngx_http_memcached_ns = ngx_string("memcached_namespace"); 
    160162 
    161163 
     
    235237{ 
    236238    size_t                          len; 
    237     uintptr_t                       escape; 
     239    uintptr_t                       escape, ns_escape = 0; 
    238240    ngx_buf_t                      *b; 
    239241    ngx_chain_t                    *cl; 
    240242    ngx_http_memcached_ctx_t       *ctx; 
    241     ngx_http_variable_value_t      *vv; 
     243    ngx_http_variable_value_t      *vv, *ns_vv; 
    242244    ngx_http_memcached_loc_conf_t  *mlcf; 
    243245 
     
    254256    escape = 2 * ngx_escape_uri(NULL, vv->data, vv->len, NGX_ESCAPE_MEMCACHED); 
    255257 
    256     len = sizeof("get ") - 1 + vv->len + escape + sizeof(CRLF) - 1; 
     258    ns_vv = ngx_http_get_indexed_variable(r, mlcf->ns_index); 
     259 
     260    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     261        ns_escape = 2 * ngx_escape_uri(NULL, ns_vv->data, 
     262                                       ns_vv->len, NGX_ESCAPE_MEMCACHED); 
     263    } 
     264 
     265    len = sizeof("get ") - 1 + ns_vv->len + ns_escape 
     266                             + vv->len + escape + sizeof(CRLF) - 1; 
    257267 
    258268    b = ngx_create_temp_buf(r->pool, len); 
     
    276286 
    277287    ctx->key.data = b->last; 
     288 
     289    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     290        if (ns_escape == 0) { 
     291            b->last = ngx_copy(b->last, ns_vv->data, ns_vv->len); 
     292        } else { 
     293            b->last = (u_char *) ngx_escape_uri(b->last, ns_vv->data, 
     294                                                ns_vv->len, 
     295                                                NGX_ESCAPE_MEMCACHED); 
     296        } 
     297    } 
    278298 
    279299    if (escape == 0) { 
     
    588608     * 
    589609     *     conf->index = 0; 
     610     *     conf->ns_index = 0; 
    590611     */ 
    591612 
     
    697718    } 
    698719 
     720    lcf->ns_index = ngx_http_get_variable_index(cf, &ngx_http_memcached_ns); 
     721 
     722    if (lcf->ns_index == NGX_ERROR) { 
     723        return NGX_CONF_ERROR; 
     724    } 
     725 
    699726    return NGX_CONF_OK; 
    700727} 
Note: See TracChangeset for help on using the changeset viewer.