Changeset 7fd3c2
- Timestamp:
- 02/19/08 15:45:00 (4 years ago)
- 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)
- Files:
-
- 8 added
- 8 edited
-
memcached_hash/Changes (added)
-
memcached_hash/README (added)
-
memcached_hash/TODO (added)
-
memcached_hash/config (added)
-
memcached_hash/dist.sh (added)
-
memcached_hash/nginx.conf (added)
-
memcached_hash/ngx_http_upstream_memcached_hash_module.c (added)
-
memcached_hash/populate.pl (added)
-
server/src/core/nginx.c (modified) (1 diff)
-
server/src/core/ngx_crc32.c (modified) (1 diff)
-
server/src/core/ngx_crc32.h (modified) (1 diff)
-
server/src/core/ngx_string.h (modified) (1 diff)
-
server/src/http/modules/ngx_http_memcached_module.c (modified) (7 diffs)
-
server/src/http/ngx_http_upstream.c (modified) (1 diff)
-
server/src/http/ngx_http_upstream.h (modified) (1 diff)
-
server/src/http/ngx_http_variables.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
server/src/core/nginx.c
r0019fc r6a5335 274 274 } 275 275 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) { 279 281 return 1; 280 282 } -
server/src/core/ngx_crc32.c
r0019fc r6a5335 103 103 104 104 ngx_int_t 105 ngx_crc32_ init(void)105 ngx_crc32_table_init(void) 106 106 { 107 107 void *p; -
server/src/core/ngx_crc32.h
r0019fc r6a5335 50 50 51 51 52 ngx_int_t ngx_crc32_init(void); 52 #define ngx_crc32_init(crc) \ 53 crc = 0xffffffff 54 55 56 static ngx_inline void 57 ngx_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 75 ngx_int_t ngx_crc32_table_init(void); 53 76 54 77 -
server/src/core/ngx_string.h
r0019fc r8760a9 64 64 #define ngx_memset(buf, c, n) (void) memset(buf, c, n) 65 65 66 #define ngx_memmove(dst, src, n) (void) memmove(dst, src, n) 66 67 67 68 #if (NGX_MEMCPY_LIMIT) -
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_upstream.c
r0019fc rde9561 3139 3139 } 3140 3140 3141 us->name = u.url; 3141 3142 us->addrs = u.addrs; 3142 3143 us->naddrs = u.naddrs; -
server/src/http/ngx_http_upstream.h
r0019fc rde9561 65 65 66 66 typedef struct { 67 ngx_str_t name; 67 68 ngx_peer_addr_t *addrs; 68 69 ngx_uint_t naddrs; -
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.
