Changeset 2a12f7
- Timestamp:
- 02/04/08 16:12:02 (4 years ago)
- Branches:
- master-v0.7, master-v0.6, upstream_count_limit
- Children:
- c79fa6
- Parents:
- 35dacc (diff), dbd2c3 (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/04/08 16:12:02)
- git-committer:
- Tomash Brechko <tomash.brechko@…> (02/04/08 16:12:02)
- Files:
-
- 8 added
- 9 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_fastcgi_module.c (modified) (1 diff)
-
server/src/http/modules/ngx_http_gzip_filter_module.c (modified) (8 diffs)
-
server/src/http/modules/ngx_http_proxy_module.c (modified) (1 diff)
-
server/src/http/ngx_http_upstream.c (modified) (4 diffs)
-
server/src/http/ngx_http_upstream.h (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_fastcgi_module.c
r0019fc r66a597 180 180 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, 181 181 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, 182 { ngx_string("http_502"), NGX_HTTP_UPSTREAM_FT_HTTP_502 }, 182 183 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, 184 { ngx_string("http_504"), NGX_HTTP_UPSTREAM_FT_HTTP_504 }, 185 { ngx_string("http_507"), NGX_HTTP_UPSTREAM_FT_HTTP_507 }, 183 186 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, 184 187 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, -
server/src/http/modules/ngx_http_gzip_filter_module.c
r2bbdb3 r95d817 309 309 ngx_http_gzip_ctx_t *ctx; 310 310 ngx_http_gzip_conf_t *conf; 311 const char *method = (r->gunzip ? "inflate" : "deflate"); 311 312 312 313 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module); … … 366 367 if (rc != Z_OK) { 367 368 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 368 " deflateInit2() failed: %d", rc);369 "%sInit2() failed: %d", method, rc); 369 370 ngx_http_gzip_error(ctx); 370 371 return NGX_ERROR; … … 456 457 457 458 if (ctx->in_buf->last_buf) { 458 ctx->flush = Z_FINISH; 459 /* 460 * We use Z_BLOCK below for the following reason: 461 * if we would use Z_FINISH, then decompression 462 * may return Z_BUF_ERROR, meaning there wasn't 463 * enough room for decompressed data. This error 464 * is not fatal according to zlib.h, however 465 * ignoring it is dangerous and may mask real 466 * bugs. For instance, sometimes completely empty 467 * last buffer is passed to this filter, and 468 * decompression would enter the infinite loop: no 469 * progress is possible because input is void and 470 * Z_BUF_ERROR is ignored. We can't use 471 * Z_NO_FLUSH, because it will never return 472 * Z_STREAM_END. We can't use Z_SYNC_FLUSH, 473 * because it has a special meaning. So we use 474 * Z_BLOCK, which eventually would return 475 * Z_STREAM_END. 476 * 477 * Perhaps the above is also true for compression, 478 * but right now we won't try to change the old 479 * behaviour. 480 */ 481 ctx->flush = (!r->gunzip ? Z_FINISH : Z_BLOCK); 459 482 460 483 } else if (ctx->in_buf->flush) { … … 474 497 475 498 476 /* is there a space for the gzippeddata ? */499 /* is there a space for the output data ? */ 477 500 478 501 if (ctx->zstream.avail_out == 0) { … … 503 526 } 504 527 505 ngx_log_debug6(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 506 "deflate in: ni:%p no:%p ai:%ud ao:%ud fl:%d redo:%d", 528 ngx_log_debug7(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 529 "%s in: ni:%p no:%p ai:%ud ao:%ud fl:%d redo:%d", 530 method, 507 531 ctx->zstream.next_in, ctx->zstream.next_out, 508 532 ctx->zstream.avail_in, ctx->zstream.avail_out, … … 515 539 } 516 540 517 if (rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) {541 if (rc != Z_OK && rc != Z_STREAM_END) { 518 542 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 519 " deflate() failed: %d, %d", ctx->flush, rc);543 "%s() failed: %d, %d", method, ctx->flush, rc); 520 544 ngx_http_gzip_error(ctx); 521 545 return NGX_ERROR; 522 546 } 523 547 524 ngx_log_debug5(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 525 "deflate out: ni:%p no:%p ai:%ud ao:%ud rc:%d", 548 ngx_log_debug6(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 549 "%s out: ni:%p no:%p ai:%ud ao:%ud rc:%d", 550 method, 526 551 ctx->zstream.next_in, ctx->zstream.next_out, 527 552 ctx->zstream.avail_in, ctx->zstream.avail_out, 528 553 rc); 529 554 530 ngx_log_debug 2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,531 " gzipin_buf:%p pos:%p",532 ctx->in_buf, ctx->in_buf->pos);555 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 556 "%s in_buf:%p pos:%p", 557 method, ctx->in_buf, ctx->in_buf->pos); 533 558 534 559 … … 588 613 if (rc != Z_OK) { 589 614 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, 590 " deflateEnd() failed: %d", rc);615 "%sEnd() failed: %d", method, rc); 591 616 ngx_http_gzip_error(ctx); 592 617 return NGX_ERROR; … … 601 626 } 602 627 603 cl->buf = ctx->out_buf; 604 cl->next = NULL; 605 *ctx->last_out = cl; 606 ctx->last_out = &cl->next; 628 /* 629 * On decompression we could already output everything 630 * under (ctx->flush == Z_SYNC_FLUSH), so we test here 631 * that the buffer is not empty. 632 */ 633 if (!r->gunzip || ctx->out_buf->last > ctx->out_buf->pos) { 634 cl->buf = ctx->out_buf; 635 cl->next = NULL; 636 *ctx->last_out = cl; 637 ctx->last_out = &cl->next; 638 } 607 639 608 640 if (!r->gunzip) { -
server/src/http/modules/ngx_http_proxy_module.c
ra64318 r66a597 134 134 { ngx_string("invalid_header"), NGX_HTTP_UPSTREAM_FT_INVALID_HEADER }, 135 135 { ngx_string("http_500"), NGX_HTTP_UPSTREAM_FT_HTTP_500 }, 136 { ngx_string("http_502"), NGX_HTTP_UPSTREAM_FT_HTTP_502 }, 136 137 { ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 }, 138 { ngx_string("http_504"), NGX_HTTP_UPSTREAM_FT_HTTP_504 }, 139 { ngx_string("http_507"), NGX_HTTP_UPSTREAM_FT_HTTP_507 }, 137 140 { ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 }, 138 141 { ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF }, -
server/src/http/ngx_http_upstream.c
r0019fc r445d49 1094 1094 } 1095 1095 1096 if (u->headers_in.status_n == NGX_HTTP_BAD_GATEWAY) { 1097 1098 if (u->peer.tries > 1 1099 && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_502) 1100 { 1101 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_502); 1102 return; 1103 } 1104 } 1105 1106 if (u->headers_in.status_n == NGX_HTTP_SERVICE_UNAVAILABLE) { 1107 1108 if (u->peer.tries > 1 1109 && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_503) 1110 { 1111 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_503); 1112 return; 1113 } 1114 } 1115 1116 if (u->headers_in.status_n == NGX_HTTP_GATEWAY_TIME_OUT) { 1117 1118 if (u->peer.tries > 1 1119 && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_504) 1120 { 1121 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_504); 1122 return; 1123 } 1124 } 1125 1126 if (u->headers_in.status_n == NGX_HTTP_INSUFFICIENT_STORAGE) { 1127 1128 if (u->peer.tries > 1 1129 && u->conf->next_upstream & NGX_HTTP_UPSTREAM_FT_HTTP_507) 1130 { 1131 ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_HTTP_507); 1132 return; 1133 } 1134 } 1096 1135 1097 1136 if (u->headers_in.status_n >= NGX_HTTP_BAD_REQUEST … … 2173 2212 switch(ft_type) { 2174 2213 2214 case NGX_HTTP_UPSTREAM_FT_HTTP_504: 2175 2215 case NGX_HTTP_UPSTREAM_FT_TIMEOUT: 2176 2216 status = NGX_HTTP_GATEWAY_TIME_OUT; … … 2183 2223 case NGX_HTTP_UPSTREAM_FT_HTTP_404: 2184 2224 status = NGX_HTTP_NOT_FOUND; 2225 break; 2226 2227 case NGX_HTTP_UPSTREAM_FT_HTTP_502: 2228 status = NGX_HTTP_BAD_GATEWAY; 2229 break; 2230 2231 case NGX_HTTP_UPSTREAM_FT_HTTP_503: 2232 status = NGX_HTTP_SERVICE_UNAVAILABLE; 2233 break; 2234 2235 case NGX_HTTP_UPSTREAM_FT_HTTP_507: 2236 status = NGX_HTTP_INSUFFICIENT_STORAGE; 2185 2237 break; 2186 2238 … … 3139 3191 } 3140 3192 3193 us->name = u.url; 3141 3194 us->addrs = u.addrs; 3142 3195 us->naddrs = u.naddrs; -
server/src/http/ngx_http_upstream.h
r0019fc r445d49 25 25 #define NGX_HTTP_UPSTREAM_FT_BUSY_LOCK 0x00000080 26 26 #define NGX_HTTP_UPSTREAM_FT_MAX_WAITING 0x00000100 27 #define NGX_HTTP_UPSTREAM_FT_HTTP_502 0x00000200 28 #define NGX_HTTP_UPSTREAM_FT_HTTP_504 0x00000400 29 #define NGX_HTTP_UPSTREAM_FT_HTTP_507 0x00000800 27 30 #define NGX_HTTP_UPSTREAM_FT_OFF 0x80000000 28 31 … … 65 68 66 69 typedef struct { 70 ngx_str_t name; 67 71 ngx_peer_addr_t *addrs; 68 72 ngx_uint_t naddrs;
Note: See TracChangeset
for help on using the changeset viewer.
