Changeset 7fd3c2


Ignore:
Timestamp:
02/19/08 15:45:00 (4 years ago)
Author:
Tomash Brechko <tomash.brechko@…>
Branches:
master-v0.7, master-v0.6, memcached_hash, upstream_count_limit
Children:
030d22
Parents:
9bc63b (diff), 7bf8e1 (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 15:45:00)
git-committer:
Tomash Brechko <tomash.brechko@…> (02/19/08 15:45:00)
Message:

Merge branch 'memcached_namespace' into memcached_hash

Files:
8 added
8 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_memcached_module.c

    r0019fc r7bf8e1  
    1414    ngx_http_upstream_conf_t   upstream; 
    1515    ngx_int_t                  index; 
     16    ngx_int_t                  ns_index; 
    1617} ngx_http_memcached_loc_conf_t; 
    1718 
     
    150151 
    151152static ngx_str_t  ngx_http_memcached_key = ngx_string("memcached_key"); 
     153static ngx_str_t  ngx_http_memcached_ns = ngx_string("memcached_namespace"); 
    152154 
    153155 
     
    227229{ 
    228230    size_t                          len; 
    229     uintptr_t                       escape; 
     231    uintptr_t                       escape, ns_escape = 0; 
    230232    ngx_buf_t                      *b; 
    231233    ngx_chain_t                    *cl; 
    232234    ngx_http_memcached_ctx_t       *ctx; 
    233     ngx_http_variable_value_t      *vv; 
     235    ngx_http_variable_value_t      *vv, *ns_vv; 
    234236    ngx_http_memcached_loc_conf_t  *mlcf; 
    235237 
     
    246248    escape = 2 * ngx_escape_uri(NULL, vv->data, vv->len, NGX_ESCAPE_MEMCACHED); 
    247249 
    248     len = sizeof("get ") - 1 + vv->len + escape + sizeof(CRLF) - 1; 
     250    ns_vv = ngx_http_get_indexed_variable(r, mlcf->ns_index); 
     251 
     252    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     253        ns_escape = 2 * ngx_escape_uri(NULL, ns_vv->data, 
     254                                       ns_vv->len, NGX_ESCAPE_MEMCACHED); 
     255    } 
     256 
     257    len = sizeof("get ") - 1 + ns_vv->len + ns_escape 
     258                             + vv->len + escape + sizeof(CRLF) - 1; 
    249259 
    250260    b = ngx_create_temp_buf(r->pool, len); 
     
    268278 
    269279    ctx->key.data = b->last; 
     280 
     281    if (ns_vv != NULL && !ns_vv->not_found && ns_vv->len != 0) { 
     282        if (ns_escape == 0) { 
     283            b->last = ngx_copy(b->last, ns_vv->data, ns_vv->len); 
     284        } else { 
     285            b->last = (u_char *) ngx_escape_uri(b->last, ns_vv->data, 
     286                                                ns_vv->len, 
     287                                                NGX_ESCAPE_MEMCACHED); 
     288        } 
     289    } 
    270290 
    271291    if (escape == 0) { 
     
    525545     * 
    526546     *     conf->index = 0; 
     547     *     conf->ns_index = 0; 
    527548     */ 
    528549 
     
    629650    } 
    630651 
     652    lcf->ns_index = ngx_http_get_variable_index(cf, &ngx_http_memcached_ns); 
     653 
     654    if (lcf->ns_index == NGX_ERROR) { 
     655        return NGX_CONF_ERROR; 
     656    } 
     657 
    631658    return NGX_CONF_OK; 
    632659} 
  • server/src/http/ngx_http_upstream.c

    r0019fc rde9561  
    31393139    } 
    31403140 
     3141    us->name = u.url; 
    31413142    us->addrs = u.addrs; 
    31423143    us->naddrs = u.naddrs; 
  • server/src/http/ngx_http_upstream.h

    r0019fc rde9561  
    6565 
    6666typedef struct { 
     67    ngx_str_t                       name; 
    6768    ngx_peer_addr_t                *addrs; 
    6869    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.