Changeset 030d22
- Timestamp:
- 02/19/08 16:11:23 (4 years ago)
- Branches:
- master-v0.7, master-v0.6, memcached_hash, upstream_count_limit
- Children:
- 2340f0
- Parents:
- 7fd3c2
- git-author:
- Tomash Brechko <tomash.brechko@…> (02/19/08 16:11:23)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (02/19/08 16:11:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
memcached_hash/ngx_http_upstream_memcached_hash_module.c
r9bc63b r030d22 16 16 17 17 #define CONTINUUM_MAX_POINT 0xffffffffU 18 19 20 static ngx_str_t memcached_ns = ngx_string("memcached_namespace"); 18 21 19 22 … … 43 46 unsigned int ketama_points; 44 47 unsigned int scale; 48 ngx_int_t ns_index; 45 49 }; 46 50 … … 50 54 struct memcached_hash *memd; 51 55 ngx_http_upstream_server_t *server; 52 ngx_ chain_t **request_bufs;56 ngx_http_request_t *request; 53 57 }; 54 58 … … 133 137 else 134 138 { 139 ngx_chain_t *request_bufs = find_ctx->request->upstream->request_bufs; 140 ngx_http_variable_value_t *ns_vv = 141 ngx_http_get_indexed_variable(find_ctx->request, memd->ns_index); 142 135 143 /* 136 144 We take the key directly from request_buf, because there it is 137 145 in the escaped form that will be seen by memcached server. 138 146 */ 139 key = (*find_ctx->request_bufs)->buf->start + (sizeof("get ") - 1); 140 len = (((*find_ctx->request_bufs)->buf->last - key) 141 - (sizeof("\r\n") - 1)); 147 key = request_bufs->buf->start + (sizeof("get ") - 1); 148 if (ns_vv && ! ns_vv->not_found && ns_vv->len != 0) 149 { 150 key += ns_vv->len + 2 * ngx_escape_uri(NULL, ns_vv->data, ns_vv->len, 151 NGX_ESCAPE_MEMCACHED); 152 } 153 154 len = request_bufs->buf->last - key - (sizeof("\r\n") - 1); 142 155 143 156 point = ngx_crc32_long(key, len); … … 218 231 return NGX_ERROR; 219 232 find_ctx->memd = memd; 220 find_ctx->request _bufs = &r->upstream->request_bufs;233 find_ctx->request = r; 221 234 find_ctx->server = us->servers->elts; 222 235 … … 454 467 memd->ketama_points = ketama_points; 455 468 memd->scale = scale; 469 memd->ns_index = ngx_http_get_variable_index(cf, &memcached_ns); 470 471 if (memd->ns_index == NGX_ERROR) { 472 return NGX_CONF_ERROR; 473 } 456 474 457 475 uscf->peer.data = memd;
Note: See TracChangeset
for help on using the changeset viewer.
