Mercurial > hg > nginx-ranges
comparison src/http/modules/ngx_http_memcached_module.c @ 635:e67b227c8dbb default tip
Merge with current.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 25 Apr 2011 04:07:55 +0400 |
parents | ff463db0be31 |
children |
comparison
equal
deleted
inserted
replaced
578:f3a9e57d2e17 | 635:e67b227c8dbb |
---|---|
36 void *parent, void *child); | 36 void *parent, void *child); |
37 | 37 |
38 static char *ngx_http_memcached_pass(ngx_conf_t *cf, ngx_command_t *cmd, | 38 static char *ngx_http_memcached_pass(ngx_conf_t *cf, ngx_command_t *cmd, |
39 void *conf); | 39 void *conf); |
40 | 40 |
41 static char *ngx_http_memcached_upstream_max_fails_unsupported(ngx_conf_t *cf, | |
42 ngx_command_t *cmd, void *conf); | |
43 static char *ngx_http_memcached_upstream_fail_timeout_unsupported(ngx_conf_t *cf, | |
44 ngx_command_t *cmd, void *conf); | |
45 | |
46 | 41 |
47 static ngx_conf_bitmask_t ngx_http_memcached_next_upstream_masks[] = { | 42 static ngx_conf_bitmask_t ngx_http_memcached_next_upstream_masks[] = { |
48 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, | 43 { ngx_string("error"), NGX_HTTP_UPSTREAM_FT_ERROR }, |
49 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, | 44 { ngx_string("timeout"), NGX_HTTP_UPSTREAM_FT_TIMEOUT }, |
50 { ngx_string("invalid_response"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, | 45 { ngx_string("invalid_response"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, |
102 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | 97 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, |
103 ngx_conf_set_bitmask_slot, | 98 ngx_conf_set_bitmask_slot, |
104 NGX_HTTP_LOC_CONF_OFFSET, | 99 NGX_HTTP_LOC_CONF_OFFSET, |
105 offsetof(ngx_http_memcached_loc_conf_t, upstream.next_upstream), | 100 offsetof(ngx_http_memcached_loc_conf_t, upstream.next_upstream), |
106 &ngx_http_memcached_next_upstream_masks }, | 101 &ngx_http_memcached_next_upstream_masks }, |
107 | |
108 { ngx_string("memcached_upstream_max_fails"), | |
109 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
110 ngx_http_memcached_upstream_max_fails_unsupported, | |
111 0, | |
112 0, | |
113 NULL }, | |
114 | |
115 { ngx_string("memcached_upstream_fail_timeout"), | |
116 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | |
117 ngx_http_memcached_upstream_fail_timeout_unsupported, | |
118 0, | |
119 0, | |
120 NULL }, | |
121 | 102 |
122 ngx_null_command | 103 ngx_null_command |
123 }; | 104 }; |
124 | 105 |
125 | 106 |
187 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 168 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
188 } | 169 } |
189 | 170 |
190 u = r->upstream; | 171 u = r->upstream; |
191 | 172 |
192 u->schema.len = sizeof("memcached://") - 1; | 173 ngx_str_set(&u->schema, "memcached://"); |
193 u->schema.data = (u_char *) "memcached://"; | |
194 | |
195 u->output.tag = (ngx_buf_tag_t) &ngx_http_memcached_module; | 174 u->output.tag = (ngx_buf_tag_t) &ngx_http_memcached_module; |
196 | 175 |
197 mlcf = ngx_http_get_module_loc_conf(r, ngx_http_memcached_module); | 176 mlcf = ngx_http_get_module_loc_conf(r, ngx_http_memcached_module); |
198 | 177 |
199 u->conf = &mlcf->upstream; | 178 u->conf = &mlcf->upstream; |
430 | 409 |
431 if (u->length == ctx->rest) { | 410 if (u->length == ctx->rest) { |
432 | 411 |
433 if (ngx_strncmp(b->last, | 412 if (ngx_strncmp(b->last, |
434 ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - ctx->rest, | 413 ngx_http_memcached_end + NGX_HTTP_MEMCACHED_END - ctx->rest, |
435 ctx->rest) | 414 bytes) |
436 != 0) | 415 != 0) |
437 { | 416 { |
438 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, | 417 ngx_log_error(NGX_LOG_ERR, ctx->request->connection->log, 0, |
439 "memcached sent invalid trailer"); | 418 "memcached sent invalid trailer"); |
419 | |
420 u->length = 0; | |
421 ctx->rest = 0; | |
422 | |
423 return NGX_OK; | |
440 } | 424 } |
441 | 425 |
442 u->length = 0; | 426 u->length -= bytes; |
443 ctx->rest = 0; | 427 ctx->rest -= bytes; |
444 | 428 |
445 return NGX_OK; | 429 return NGX_OK; |
446 } | 430 } |
447 | 431 |
448 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) { | 432 for (cl = u->out_bufs, ll = &u->out_bufs; cl; cl = cl->next) { |
635 return NGX_CONF_ERROR; | 619 return NGX_CONF_ERROR; |
636 } | 620 } |
637 | 621 |
638 return NGX_CONF_OK; | 622 return NGX_CONF_OK; |
639 } | 623 } |
640 | |
641 | |
642 static char * | |
643 ngx_http_memcached_upstream_max_fails_unsupported(ngx_conf_t *cf, | |
644 ngx_command_t *cmd, void *conf) | |
645 { | |
646 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
647 "\"memcached_upstream_max_fails\" is not supported, " | |
648 "use the \"max_fails\" parameter of the \"server\" directive ", | |
649 "inside the \"upstream\" block"); | |
650 | |
651 return NGX_CONF_ERROR; | |
652 } | |
653 | |
654 | |
655 static char * | |
656 ngx_http_memcached_upstream_fail_timeout_unsupported(ngx_conf_t *cf, | |
657 ngx_command_t *cmd, void *conf) | |
658 { | |
659 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
660 "\"memcached_upstream_fail_timeout\" is not supported, " | |
661 "use the \"fail_timeout\" parameter of the \"server\" directive ", | |
662 "inside the \"upstream\" block"); | |
663 | |
664 return NGX_CONF_ERROR; | |
665 } |