Mercurial > hg > nginx
comparison src/http/modules/proxy/ngx_http_proxy_handler.c @ 473:8e8f3af115b5 release-0.1.11
nginx-0.1.11-RELEASE import
*) Feature: the worker_priority directive.
*) Change: both tcp_nopush and tcp_nodelay directives affect the
transferred response.
*) Bugfix: nginx did not call initgroups().
Thanks to Andrew Sitnikov and Andrei Nigmatulin.
*) Change: now the ngx_http_autoindex_module shows the file size in the
bytes.
*) Bugfix: the ngx_http_autoindex_module returned the 500 error if the
broken symlink was in a directory.
*) Bugfix: the files bigger than 4G could not be transferred using
sendfile.
*) Bugfix: if the backend was resolved to several backends and there
was an error while the response waiting then process may got caught
in an endless loop.
*) Bugfix: the worker process may exit with the "unknown cycle" message
when the /dev/poll method was used.
*) Bugfix: "close() channel failed" errors.
*) Bugfix: the autodetection of the "nobody" and "nogroup" groups.
*) Bugfix: the send_lowat directive did not work on Linux.
*) Bugfix: the segmentation fault occurred if there was no events
section in configuration.
*) Bugfix: nginx could not be built on OpenBSD.
*) Bugfix: the double slashes in "://" in the URI were converted to
":/".
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 02 Dec 2004 18:40:46 +0000 |
parents | 2ff194b74f1e |
children | ad1e9ebf93bb |
comparison
equal
deleted
inserted
replaced
472:a004b617422d | 473:8e8f3af115b5 |
---|---|
273 }; | 273 }; |
274 | 274 |
275 | 275 |
276 | 276 |
277 static ngx_http_log_op_name_t ngx_http_proxy_log_fmt_ops[] = { | 277 static ngx_http_log_op_name_t ngx_http_proxy_log_fmt_ops[] = { |
278 { ngx_string("proxy"), /* STUB */ 100, | 278 { ngx_string("proxy"), 0, ngx_http_proxy_log_proxy_state }, |
279 ngx_http_proxy_log_proxy_state }, | 279 { ngx_string("proxy_cache_state"), 0, ngx_http_proxy_log_cache_state }, |
280 { ngx_string("proxy_cache_state"), sizeof("BYPASS") - 1, | 280 { ngx_string("proxy_reason"), 0, ngx_http_proxy_log_reason }, |
281 ngx_http_proxy_log_cache_state }, | |
282 { ngx_string("proxy_reason"), sizeof("BPS") - 1, | |
283 ngx_http_proxy_log_reason }, | |
284 { ngx_null_string, 0, NULL } | 281 { ngx_null_string, 0, NULL } |
285 }; | 282 }; |
286 | 283 |
287 | 284 |
288 | 285 |
790 | 787 |
791 | 788 |
792 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, | 789 static u_char *ngx_http_proxy_log_proxy_state(ngx_http_request_t *r, |
793 u_char *buf, uintptr_t data) | 790 u_char *buf, uintptr_t data) |
794 { | 791 { |
795 ngx_http_proxy_ctx_t *p; | 792 ngx_uint_t i; |
793 ngx_http_proxy_ctx_t *p; | |
794 ngx_http_proxy_state_t *state; | |
796 | 795 |
797 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module); | 796 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module); |
798 | 797 |
799 if (p == NULL) { | 798 if (p == NULL) { |
799 if (buf == NULL) { | |
800 return (u_char *) 1; | |
801 } | |
802 | |
800 *buf = '-'; | 803 *buf = '-'; |
801 return buf + 1; | 804 return buf + 1; |
802 } | 805 } |
803 | 806 |
804 if (p->state->cache_state == 0) { | 807 |
805 *buf++ = '-'; | 808 if (buf == NULL) { |
806 | 809 /* find the request line length */ |
807 } else { | 810 return (u_char *) (uintptr_t) (p->states.nelts * /* STUB */ 100); |
808 buf = ngx_cpymem(buf, cache_states[p->state->cache_state - 1].data, | 811 } |
809 cache_states[p->state->cache_state - 1].len); | 812 |
810 } | 813 |
811 | 814 i = 0; |
812 *buf++ = '/'; | 815 state = p->states.elts; |
813 | 816 |
814 if (p->state->expired == 0) { | 817 for ( ;; ) { |
815 *buf++ = '-'; | 818 if (state[i].cache_state == 0) { |
816 | 819 *buf++ = '-'; |
817 } else { | 820 |
818 buf = ngx_sprintf(buf, "%T", p->state->expired); | 821 } else { |
819 } | 822 buf = ngx_cpymem(buf, cache_states[state[i].cache_state - 1].data, |
820 | 823 cache_states[state[i].cache_state - 1].len); |
821 *buf++ = '/'; | 824 } |
822 | 825 |
823 if (p->state->bl_time == 0) { | 826 *buf++ = '/'; |
824 *buf++ = '-'; | 827 |
825 | 828 if (state[i].expired == 0) { |
826 } else { | 829 *buf++ = '-'; |
827 buf = ngx_sprintf(buf, "%T", p->state->bl_time); | 830 |
828 } | 831 } else { |
829 | 832 buf = ngx_sprintf(buf, "%T", state[i].expired); |
830 *buf++ = '/'; | 833 } |
831 | 834 |
832 *buf++ = '*'; | 835 *buf++ = '/'; |
833 | 836 |
834 *buf++ = ' '; | 837 if (state[i].bl_time == 0) { |
835 | 838 *buf++ = '-'; |
836 if (p->state->status == 0) { | 839 |
837 *buf++ = '-'; | 840 } else { |
838 | 841 buf = ngx_sprintf(buf, "%T", state[i].bl_time); |
839 } else { | 842 } |
840 buf = ngx_sprintf(buf, "%ui", p->state->status); | 843 |
841 } | 844 *buf++ = '/'; |
842 | 845 |
843 *buf++ = '/'; | 846 *buf++ = '*'; |
844 | 847 |
845 if (p->state->reason == 0) { | 848 *buf++ = ' '; |
846 *buf++ = '-'; | 849 |
847 | 850 if (state[i].status == 0) { |
848 } else { | 851 *buf++ = '-'; |
849 buf = ngx_cpymem(buf, cache_reasons[p->state->reason - 1].data, | 852 |
850 cache_reasons[p->state->reason - 1].len); | 853 } else { |
851 } | 854 buf = ngx_sprintf(buf, "%ui", state[i].status); |
852 | 855 } |
853 *buf++ = '/'; | 856 |
854 | 857 *buf++ = '/'; |
855 if (p->state->reason < NGX_HTTP_PROXY_CACHE_XAE) { | 858 |
856 *buf++ = '-'; | 859 if (state[i].reason == 0) { |
857 | 860 *buf++ = '-'; |
858 } else { | 861 |
859 buf = ngx_sprintf(buf, "%T", p->state->expires); | 862 } else { |
860 } | 863 buf = ngx_cpymem(buf, cache_reasons[state[i].reason - 1].data, |
861 | 864 cache_reasons[state[i].reason - 1].len); |
862 *buf++ = ' '; | 865 } |
863 *buf++ = '*'; | 866 |
864 | 867 *buf++ = '/'; |
865 return buf; | 868 |
869 if (state[i].reason < NGX_HTTP_PROXY_CACHE_XAE) { | |
870 *buf++ = '-'; | |
871 | |
872 } else { | |
873 buf = ngx_sprintf(buf, "%T", state[i].expires); | |
874 } | |
875 | |
876 *buf++ = ' '; | |
877 *buf++ = '*'; | |
878 | |
879 if (++i == p->states.nelts) { | |
880 return buf; | |
881 } | |
882 | |
883 *buf++ = ','; | |
884 *buf++ = ' '; | |
885 } | |
866 } | 886 } |
867 | 887 |
868 | 888 |
869 static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, | 889 static u_char *ngx_http_proxy_log_cache_state(ngx_http_request_t *r, |
870 u_char *buf, uintptr_t data) | 890 u_char *buf, uintptr_t data) |
871 { | 891 { |
872 ngx_http_proxy_ctx_t *p; | 892 ngx_uint_t i; |
893 ngx_http_proxy_ctx_t *p; | |
894 ngx_http_proxy_state_t *state; | |
873 | 895 |
874 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module); | 896 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module); |
875 | 897 |
876 if (p == NULL || p->state->cache_state == 0) { | 898 if (p == NULL || p->state->cache_state == 0) { |
899 if (buf == NULL) { | |
900 return (u_char *) 1; | |
901 } | |
902 | |
877 *buf = '-'; | 903 *buf = '-'; |
878 return buf + 1; | 904 return buf + 1; |
879 } | 905 } |
880 | 906 |
881 return ngx_cpymem(buf, cache_states[p->state->cache_state - 1].data, | 907 if (buf == NULL) { |
882 cache_states[p->state->cache_state - 1].len); | 908 /* find the request line length */ |
909 return (u_char *) (p->states.nelts * sizeof("BYPASS") - 1); | |
910 } | |
911 | |
912 i = 0; | |
913 state = p->states.elts; | |
914 | |
915 for ( ;; ) { | |
916 buf = ngx_cpymem(buf, cache_states[state[i].cache_state - 1].data, | |
917 cache_states[state[i].cache_state - 1].len); | |
918 | |
919 if (++i == p->states.nelts) { | |
920 return buf; | |
921 } | |
922 | |
923 *buf++ = ','; | |
924 *buf++ = ' '; | |
925 } | |
883 } | 926 } |
884 | 927 |
885 | 928 |
886 static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf, | 929 static u_char *ngx_http_proxy_log_reason(ngx_http_request_t *r, u_char *buf, |
887 uintptr_t data) | 930 uintptr_t data) |
888 { | 931 { |
889 ngx_http_proxy_ctx_t *p; | 932 ngx_uint_t i; |
933 ngx_http_proxy_ctx_t *p; | |
934 ngx_http_proxy_state_t *state; | |
890 | 935 |
891 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module); | 936 p = ngx_http_get_module_err_ctx(r, ngx_http_proxy_module); |
892 | 937 |
893 if (p == NULL || p->state->reason == 0) { | 938 if (p == NULL || p->state->reason == 0) { |
939 if (buf == NULL) { | |
940 return (u_char *) 1; | |
941 } | |
942 | |
894 *buf = '-'; | 943 *buf = '-'; |
895 return buf + 1; | 944 return buf + 1; |
896 } | 945 } |
897 | 946 |
898 return ngx_cpymem(buf, cache_reasons[p->state->reason - 1].data, | 947 if (buf == NULL) { |
899 cache_reasons[p->state->reason - 1].len); | 948 /* find the request line length */ |
949 return (u_char *) (p->states.nelts * sizeof("BPS") - 1); | |
950 } | |
951 | |
952 i = 0; | |
953 state = p->states.elts; | |
954 | |
955 for ( ;; ) { | |
956 buf = ngx_cpymem(buf, cache_reasons[state[i].reason - 1].data, | |
957 cache_reasons[state[i].reason - 1].len); | |
958 | |
959 if (++i == p->states.nelts) { | |
960 return buf; | |
961 } | |
962 | |
963 *buf++ = ','; | |
964 *buf++ = ' '; | |
965 } | |
900 } | 966 } |
901 | 967 |
902 | 968 |
903 static ngx_int_t ngx_http_proxy_pre_conf(ngx_conf_t *cf) | 969 static ngx_int_t ngx_http_proxy_pre_conf(ngx_conf_t *cf) |
904 { | 970 { |
1385 } | 1451 } |
1386 | 1452 |
1387 | 1453 |
1388 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) | 1454 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) |
1389 { | 1455 { |
1456 #if (NGX_FREEBSD) | |
1390 ssize_t *np = data; | 1457 ssize_t *np = data; |
1391 | |
1392 #if (NGX_FREEBSD) | |
1393 | 1458 |
1394 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { | 1459 if (*np >= ngx_freebsd_net_inet_tcp_sendspace) { |
1395 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1460 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1396 "\"proxy_send_lowat\" must be less than %d " | 1461 "\"proxy_send_lowat\" must be less than %d " |
1397 "(sysctl net.inet.tcp.sendspace)", | 1462 "(sysctl net.inet.tcp.sendspace)", |
1399 | 1464 |
1400 return NGX_CONF_ERROR; | 1465 return NGX_CONF_ERROR; |
1401 } | 1466 } |
1402 | 1467 |
1403 #elif !(NGX_HAVE_SO_SNDLOWAT) | 1468 #elif !(NGX_HAVE_SO_SNDLOWAT) |
1469 ssize_t *np = data; | |
1404 | 1470 |
1405 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, | 1471 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, |
1406 "\"proxy_send_lowat\" is not supported, ignored"); | 1472 "\"proxy_send_lowat\" is not supported, ignored"); |
1407 | 1473 |
1408 *np = 0; | 1474 *np = 0; |