Changeset 7bf8e1
- Timestamp:
- 02/19/08 15:44:50 (4 years ago)
- Branches:
- master-v0.7, master-v0.6, memcached_hash, upstream_count_limit
- Children:
- 11531c
- Parents:
- a64318
- git-author:
- Tomash Brechko <tomash.brechko@…> (02/19/08 15:44:50)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (02/19/08 15:44:50)
- Location:
- server/src/http
- Files:
-
- 2 edited
-
modules/ngx_http_memcached_module.c (modified) (7 diffs)
-
ngx_http_variables.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
server/src/http/modules/ngx_http_memcached_module.c
r0019fc r7bf8e1 14 14 ngx_http_upstream_conf_t upstream; 15 15 ngx_int_t index; 16 ngx_int_t ns_index; 16 17 } ngx_http_memcached_loc_conf_t; 17 18 … … 150 151 151 152 static ngx_str_t ngx_http_memcached_key = ngx_string("memcached_key"); 153 static ngx_str_t ngx_http_memcached_ns = ngx_string("memcached_namespace"); 152 154 153 155 … … 227 229 { 228 230 size_t len; 229 uintptr_t escape ;231 uintptr_t escape, ns_escape = 0; 230 232 ngx_buf_t *b; 231 233 ngx_chain_t *cl; 232 234 ngx_http_memcached_ctx_t *ctx; 233 ngx_http_variable_value_t *vv ;235 ngx_http_variable_value_t *vv, *ns_vv; 234 236 ngx_http_memcached_loc_conf_t *mlcf; 235 237 … … 246 248 escape = 2 * ngx_escape_uri(NULL, vv->data, vv->len, NGX_ESCAPE_MEMCACHED); 247 249 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; 249 259 250 260 b = ngx_create_temp_buf(r->pool, len); … … 268 278 269 279 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 } 270 290 271 291 if (escape == 0) { … … 525 545 * 526 546 * conf->index = 0; 547 * conf->ns_index = 0; 527 548 */ 528 549 … … 629 650 } 630 651 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 631 658 return NGX_CONF_OK; 632 659 } -
server/src/http/ngx_http_variables.c
r0019fc r7bf8e1 1313 1313 1314 1314 1315 static ngx_int_t 1316 ngx_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 1315 1324 ngx_int_t 1316 1325 ngx_http_variables_init_vars(ngx_conf_t *cf) … … 1374 1383 } 1375 1384 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 1376 1391 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, 1377 1392 "unknown \"%V\" variable", &v[i].name);
Note: See TracChangeset
for help on using the changeset viewer.
