Mercurial > hg > nginx-quic
comparison src/http/modules/ngx_http_geo_module.c @ 2442:6978f3827a5c
*) fix duplicate geo ranges
*) split existent range and insert a new one
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 16 Jan 2009 13:17:12 +0000 |
parents | 39f3b4f9989e |
children | 3d868fc44879 |
comparison
equal
deleted
inserted
replaced
2441:0c117a89f399 | 2442:6978f3827a5c |
---|---|
565 range = a->elts; | 565 range = a->elts; |
566 | 566 |
567 ngx_memcpy(&range[i + 2], &range[i + 1], | 567 ngx_memcpy(&range[i + 2], &range[i + 1], |
568 (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t)); | 568 (a->nelts - 2 - i) * sizeof(ngx_http_geo_range_t)); |
569 | 569 |
570 range = &range[i + 1]; | 570 range[i + 1].start = (u_short) s; |
571 range[i + 1].end = (u_short) e; | |
572 range[i + 1].value = ctx->value; | |
571 | 573 |
572 goto next; | 574 goto next; |
573 } | 575 } |
574 | 576 |
575 if (s == (ngx_uint_t) range[i].start | 577 if (s == (ngx_uint_t) range[i].start |
576 && e == (ngx_uint_t) range[i].end) | 578 && e == (ngx_uint_t) range[i].end) |
577 { | 579 { |
578 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | 580 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
579 "duplicate range \"%V\", value: \"%v\", old value: \"%v\"", | 581 "duplicate range \"%V\", value: \"%v\", old value: \"%v\"", |
580 ctx->net, ctx->value, range[i].value); | 582 ctx->net, ctx->value, range[i].value); |
581 continue; | 583 |
584 range[i].value = ctx->value; | |
585 | |
586 goto next; | |
587 } | |
588 | |
589 if (s > (ngx_uint_t) range[i].start | |
590 && e < (ngx_uint_t) range[i].end) | |
591 { | |
592 /* split the range and insert the new one */ | |
593 | |
594 range = ngx_array_push(a); | |
595 if (range == NULL) { | |
596 return NGX_CONF_ERROR; | |
597 } | |
598 | |
599 range = ngx_array_push(a); | |
600 if (range == NULL) { | |
601 return NGX_CONF_ERROR; | |
602 } | |
603 | |
604 range = a->elts; | |
605 | |
606 ngx_memcpy(&range[i + 3], &range[i + 1], | |
607 (a->nelts - 3 - i) * sizeof(ngx_http_geo_range_t)); | |
608 | |
609 range[i + 2].start = (u_short) (e + 1); | |
610 range[i + 2].end = range[i].end; | |
611 range[i + 2].value = range[i].value; | |
612 | |
613 range[i].end = (u_short) (s - 1); | |
614 | |
615 range[i + 1].start = (u_short) s; | |
616 range[i + 1].end = (u_short) e; | |
617 range[i + 1].value = ctx->value; | |
618 | |
619 goto next; | |
582 } | 620 } |
583 | 621 |
584 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 622 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
585 "overlapped range \"%V\"", ctx->net); | 623 "overlapped range \"%V\"", ctx->net); |
586 | 624 |
592 range = ngx_array_push(a); | 630 range = ngx_array_push(a); |
593 if (range == NULL) { | 631 if (range == NULL) { |
594 return NGX_CONF_ERROR; | 632 return NGX_CONF_ERROR; |
595 } | 633 } |
596 | 634 |
597 next: | |
598 | |
599 range->start = (u_short) s; | 635 range->start = (u_short) s; |
600 range->end = (u_short) e; | 636 range->end = (u_short) e; |
601 range->value = ctx->value; | 637 range->value = ctx->value; |
638 | |
639 next: | |
640 | |
641 continue; | |
602 } | 642 } |
603 | 643 |
604 return NGX_CONF_OK; | 644 return NGX_CONF_OK; |
605 } | 645 } |
606 | 646 |