comparison src/http/ngx_http_request.c @ 372:c9fdfccebc49

nginx-0.0.7-2004-06-29-01:03:14 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 28 Jun 2004 21:03:14 +0000
parents 54f76b0b8dca
children 213f17e9f776
comparison
equal deleted inserted replaced
371:780e93985b93 372:c9fdfccebc49
1706 } 1706 }
1707 1707
1708 1708
1709 void ngx_http_close_connection(ngx_connection_t *c) 1709 void ngx_http_close_connection(ngx_connection_t *c)
1710 { 1710 {
1711 ngx_socket_t fd;
1712
1711 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 1713 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
1712 "close http connection: %d", c->fd); 1714 "close http connection: %d", c->fd);
1713 1715
1714 if (c->pool == NULL) { 1716 if (c->pool == NULL) {
1715 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed"); 1717 ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
1735 if (c->write->active || c->write->posted || c->write->disabled) { 1737 if (c->write->active || c->write->posted || c->write->disabled) {
1736 ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT); 1738 ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
1737 } 1739 }
1738 } 1740 }
1739 1741
1740 if (ngx_close_socket(c->fd) == -1) { 1742 fd = c->fd;
1741 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno,
1742 ngx_close_socket_n " failed");
1743 }
1744 1743
1745 c->fd = (ngx_socket_t) -1; 1744 c->fd = (ngx_socket_t) -1;
1746 c->data = NULL; 1745 c->data = NULL;
1747
1748 ngx_destroy_pool(c->pool); 1746 ngx_destroy_pool(c->pool);
1747
1748 /*
1749 * we has to clean the connection before the closing because another thread
1750 * may reopen the same file descriptor before we clean the connection
1751 */
1752
1753 if (ngx_close_socket(fd) == -1) {
1754
1755 /* we use ngx_cycle->log because c->log was in c->pool */
1756
1757 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, ngx_socket_errno,
1758 ngx_close_socket_n " failed");
1759 }
1749 1760
1750 return; 1761 return;
1751 } 1762 }
1752 1763
1753 1764