comparison src/http/ngx_http_request.c @ 417:0526206251f6

nginx-0.0.10-2004-09-07-19:29:22 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 07 Sep 2004 15:29:22 +0000
parents b9bd635011de
children 47709bff4468
comparison
equal deleted inserted replaced
416:b9bd635011de 417:0526206251f6
1897 #endif 1897 #endif
1898 1898
1899 1899
1900 void ngx_http_close_connection(ngx_connection_t *c) 1900 void ngx_http_close_connection(ngx_connection_t *c)
1901 { 1901 {
1902 ngx_socket_t fd;
1903
1904 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 1902 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
1905 "close http connection: %d", c->fd); 1903 "close http connection: %d", c->fd);
1906 1904
1907 if (c->pool == NULL) { 1905 ngx_close_connection(c);
1908 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
1909 return;
1910 }
1911
1912 #if (NGX_HTTP_SSL)
1913
1914 if (c->ssl) {
1915 if (ngx_ssl_shutdown(c) == NGX_AGAIN) {
1916 c->read->event_handler = ngx_ssl_close_handler;
1917 c->write->event_handler = ngx_ssl_close_handler;
1918 return;
1919 }
1920 }
1921
1922 #endif
1923
1924 if (c->read->timer_set) {
1925 ngx_del_timer(c->read);
1926 }
1927
1928 if (c->write->timer_set) {
1929 ngx_del_timer(c->write);
1930 }
1931
1932 if (ngx_del_conn) {
1933 ngx_del_conn(c, NGX_CLOSE_EVENT);
1934
1935 } else {
1936 if (c->read->active || c->read->disabled) {
1937 ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
1938 }
1939
1940 if (c->write->active || c->write->disabled) {
1941 ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
1942 }
1943 }
1944
1945 /*
1946 * we have to clean the connection information before the closing
1947 * because another thread may reopen the same file descriptor
1948 * before we clean the connection
1949 */
1950
1951 #if (NGX_THREADS)
1952
1953 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) {
1954
1955 if (c->read->prev) {
1956 ngx_delete_posted_event(c->read);
1957 }
1958
1959 if (c->write->prev) {
1960 ngx_delete_posted_event(c->write);
1961 }
1962
1963 c->read->closed = 1;
1964 c->write->closed = 1;
1965
1966 if (c->single_connection) {
1967 ngx_unlock(&c->lock);
1968 c->read->locked = 0;
1969 c->write->locked = 0;
1970 }
1971
1972 ngx_mutex_unlock(ngx_posted_events_mutex);
1973 }
1974
1975 #else
1976
1977 if (c->read->prev) {
1978 ngx_delete_posted_event(c->read);
1979 }
1980
1981 if (c->write->prev) {
1982 ngx_delete_posted_event(c->write);
1983 }
1984
1985 c->read->closed = 1;
1986 c->write->closed = 1;
1987
1988 #endif
1989
1990 fd = c->fd;
1991 c->fd = (ngx_socket_t) -1;
1992 c->data = NULL;
1993
1994 ngx_destroy_pool(c->pool);
1995
1996 if (ngx_close_socket(fd) == -1) {
1997
1998 /* we use ngx_cycle->log because c->log was in c->pool */
1999
2000 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno,
2001 ngx_close_socket_n " failed");
2002 }
2003
2004 return;
2005 } 1906 }
2006 1907
2007 1908
2008 static void ngx_http_client_error(ngx_http_request_t *r, 1909 static void ngx_http_client_error(ngx_http_request_t *r,
2009 int client_error, int error) 1910 int client_error, int error)