comparison src/core/ngx_inet.c @ 4721:538363721933 stable-1.2

Merge of r4653: ngx_inet.c code reduction. Code reduction (no functional changes).
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 02 Jul 2012 16:11:02 +0000
parents c3bddd3df3fb
children c070fa19511e
comparison
equal deleted inserted replaced
4720:e92582b7da05 4721:538363721933
632 uri = ngx_strlchr(host, last, '/'); 632 uri = ngx_strlchr(host, last, '/');
633 633
634 args = ngx_strlchr(host, last, '?'); 634 args = ngx_strlchr(host, last, '?');
635 635
636 if (args) { 636 if (args) {
637 if (uri == NULL) { 637 if (uri == NULL || args < uri) {
638 uri = args;
639
640 } else if (args < uri) {
641 uri = args; 638 uri = args;
642 } 639 }
643 } 640 }
644 641
645 if (uri) { 642 if (uri) {
660 657
661 if (port) { 658 if (port) {
662 port++; 659 port++;
663 660
664 len = last - port; 661 len = last - port;
665
666 if (len == 0) {
667 u->err = "invalid port";
668 return NGX_ERROR;
669 }
670 662
671 n = ngx_atoi(port, len); 663 n = ngx_atoi(port, len);
672 664
673 if (n < 1 || n > 65535) { 665 if (n < 1 || n > 65535) {
674 u->err = "invalid port"; 666 u->err = "invalid port";
772 764
773 if (u->listen) { 765 if (u->listen) {
774 return NGX_OK; 766 return NGX_OK;
775 } 767 }
776 768
777 if (ngx_inet_resolve_host(pool, u) != NGX_OK) { 769 return ngx_inet_resolve_host(pool, u);
778 return NGX_ERROR;
779 }
780
781 return NGX_OK;
782 } 770 }
783 771
784 772
785 static ngx_int_t 773 static ngx_int_t
786 ngx_parse_inet6_url(ngx_pool_t *pool, ngx_url_t *u) 774 ngx_parse_inet6_url(ngx_pool_t *pool, ngx_url_t *u)
824 812
825 if (*port == ':') { 813 if (*port == ':') {
826 port++; 814 port++;
827 815
828 len = last - port; 816 len = last - port;
829
830 if (len == 0) {
831 u->err = "invalid port";
832 return NGX_ERROR;
833 }
834 817
835 n = ngx_atoi(port, len); 818 n = ngx_atoi(port, len);
836 819
837 if (n < 1 || n > 65535) { 820 if (n < 1 || n > 65535) {
838 u->err = "invalid port"; 821 u->err = "invalid port";