comparison src/http/ngx_http_request.c @ 3052:6060225e9261

FreeBSD and Linux AIO support
author Igor Sysoev <igor@sysoev.ru>
date Fri, 28 Aug 2009 08:12:35 +0000
parents 26dfc0fa22c8
children a137de814516
comparison
equal deleted inserted replaced
3051:26dfc0fa22c8 3052:6060225e9261
1866 { 1866 {
1867 if (ngx_http_post_action(r) == NGX_OK) { 1867 if (ngx_http_post_action(r) == NGX_OK) {
1868 return; 1868 return;
1869 } 1869 }
1870 1870
1871 if (r->main->blocked) {
1872 r->write_event_handler = ngx_http_request_finalizer;
1873 }
1874
1871 ngx_http_terminate_request(r, rc); 1875 ngx_http_terminate_request(r, rc);
1872 return; 1876 return;
1873 } 1877 }
1874 1878
1875 if (rc >= NGX_HTTP_SPECIAL_RESPONSE 1879 if (rc >= NGX_HTTP_SPECIAL_RESPONSE
1967 &pr->uri, &pr->args); 1971 &pr->uri, &pr->args);
1968 1972
1969 return; 1973 return;
1970 } 1974 }
1971 1975
1972 if (r->buffered || c->buffered || r->postponed) { 1976 if (r->buffered || c->buffered || r->postponed || r->blocked) {
1973 1977
1974 if (ngx_http_set_write_handler(r) != NGX_OK) { 1978 if (ngx_http_set_write_handler(r) != NGX_OK) {
1975 ngx_http_terminate_request(r, 0); 1979 ngx_http_terminate_request(r, 0);
1976 } 1980 }
1977 1981
2020 ngx_http_request_t *mr; 2024 ngx_http_request_t *mr;
2021 2025
2022 mr = r->main; 2026 mr = r->main;
2023 2027
2024 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 2028 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
2025 "http terminate request count: %d", mr->count); 2029 "http terminate request count:%d", mr->count);
2026 2030
2027 cln = mr->cleanup; 2031 cln = mr->cleanup;
2028 mr->cleanup = NULL; 2032 mr->cleanup = NULL;
2029 2033
2030 while (cln) { 2034 while (cln) {
2033 } 2037 }
2034 2038
2035 cln = cln->next; 2039 cln = cln->next;
2036 } 2040 }
2037 2041
2038 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 2042 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
2039 "http terminate cleanup count: %d", mr->count); 2043 "http terminate cleanup count:%d blk:%d",
2044 mr->count, mr->blocked);
2040 2045
2041 if (mr->write_event_handler) { 2046 if (mr->write_event_handler) {
2047
2048 if (mr->blocked) {
2049 return;
2050 }
2051
2042 mr->posted_requests = NULL; 2052 mr->posted_requests = NULL;
2043 mr->write_event_handler = ngx_http_terminate_handler; 2053 mr->write_event_handler = ngx_http_terminate_handler;
2044 (void) ngx_http_post_request(mr); 2054 (void) ngx_http_post_request(mr);
2045 return; 2055 return;
2046 } 2056 }
2051 2061
2052 static void 2062 static void
2053 ngx_http_terminate_handler(ngx_http_request_t *r) 2063 ngx_http_terminate_handler(ngx_http_request_t *r)
2054 { 2064 {
2055 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 2065 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
2056 "http terminate handler count: %d", r->count); 2066 "http terminate handler count:%d", r->count);
2057 2067
2058 r->count = 1; 2068 r->count = 1;
2059 2069
2060 ngx_http_close_request(r, 0); 2070 ngx_http_close_request(r, 0);
2061 } 2071 }
2159 2169
2160 return; 2170 return;
2161 } 2171 }
2162 2172
2163 } else { 2173 } else {
2164 if (wev->delayed) { 2174 if (wev->delayed || r->aio) {
2165 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, 2175 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0,
2166 "http writer delayed"); 2176 "http writer delayed");
2167 2177
2168 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { 2178 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) {
2169 ngx_http_close_request(r, 0); 2179 ngx_http_close_request(r, 0);
2828 ngx_connection_t *c; 2838 ngx_connection_t *c;
2829 2839
2830 r = r->main; 2840 r = r->main;
2831 c = r->connection; 2841 c = r->connection;
2832 2842
2833 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 2843 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
2834 "http request count: %d", r->count); 2844 "http request count:%d blk:%d", r->count, r->blocked);
2835 2845
2836 if (r->count == 0) { 2846 if (r->count == 0) {
2837 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "http request count is zero"); 2847 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "http request count is zero");
2838 } 2848 }
2839 2849
2840 r->count--; 2850 r->count--;
2841 2851
2842 if (r->count) { 2852 if (r->count || r->blocked) {
2843 return; 2853 return;
2844 } 2854 }
2845 2855
2846 ngx_http_free_request(r, rc); 2856 ngx_http_free_request(r, rc);
2847 ngx_http_close_connection(c); 2857 ngx_http_close_connection(c);