comparison src/http/ngx_http_request.c @ 375:744ccb59062d

nginx-0.0.7-2004-07-02-19:54:34 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 02 Jul 2004 15:54:34 +0000
parents 213f17e9f776
children 41437e4fd9b4
comparison
equal deleted inserted replaced
374:213f17e9f776 375:744ccb59062d
1015 if (r->connection->write->timer_set) { 1015 if (r->connection->write->timer_set) {
1016 r->connection->write->delayed = 0; 1016 r->connection->write->delayed = 0;
1017 ngx_del_timer(r->connection->write); 1017 ngx_del_timer(r->connection->write);
1018 } 1018 }
1019 1019
1020 if (r->connection->read->kq_eof) { 1020 if (r->connection->read->pending_eof) {
1021 #if (NGX_KQUEUE) 1021 #if (NGX_KQUEUE)
1022 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 1022 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log,
1023 r->connection->read->kq_errno, 1023 r->connection->read->kq_errno,
1024 "kevent() reported about an closed connection"); 1024 "kevent() reported about an closed connection");
1025 #endif 1025 #endif
1728 1728
1729 if (ngx_del_conn) { 1729 if (ngx_del_conn) {
1730 ngx_del_conn(c, NGX_CLOSE_EVENT); 1730 ngx_del_conn(c, NGX_CLOSE_EVENT);
1731 1731
1732 } else { 1732 } else {
1733 if (c->read->active || c->read->posted || c->read->disabled) { 1733 if (c->read->active || c->read->disabled) {
1734 ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT); 1734 ngx_del_event(c->read, NGX_READ_EVENT, NGX_CLOSE_EVENT);
1735 } 1735 }
1736 1736
1737 if (c->write->active || c->write->posted || c->write->disabled) { 1737 if (c->write->active || c->write->disabled) {
1738 ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT); 1738 ngx_del_event(c->write, NGX_WRITE_EVENT, NGX_CLOSE_EVENT);
1739 } 1739 }
1740 } 1740 }
1741 1741
1742 /* 1742 /*
1743 * we have to clean the connection information before the closing 1743 * we have to clean the connection information before the closing
1744 * because another thread may reopen the same file descriptor 1744 * because another thread may reopen the same file descriptor
1745 * before we clean the connection 1745 * before we clean the connection
1746 */ 1746 */
1747 1747
1748 #if (NGX_THREADS)
1749
1750 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) {
1751
1752 ngx_unlock(&c->lock);
1753 c->read->locked = 0;
1754 c->write->locked = 0;
1755
1756 c->read->closed = 1;
1757 c->write->closed = 1;
1758
1759 if (c->read->prev) {
1760 ngx_delete_posted_event(c->read);
1761 }
1762
1763 if (c->write->prev) {
1764 ngx_delete_posted_event(c->write);
1765 }
1766
1767 ngx_mutex_unlock(ngx_posted_events_mutex);
1768 }
1769
1770 #else
1771
1772 c->read->closed = 1;
1773 c->write->closed = 1;
1774
1775 if (c->read->prev) {
1776 ngx_delete_posted_event(c->read);
1777 }
1778
1779 if (c->write->prev) {
1780 ngx_delete_posted_event(c->write);
1781 }
1782
1783 #endif
1784
1748 fd = c->fd; 1785 fd = c->fd;
1749 c->fd = (ngx_socket_t) -1; 1786 c->fd = (ngx_socket_t) -1;
1750 c->data = NULL; 1787 c->data = NULL;
1788
1751 ngx_destroy_pool(c->pool); 1789 ngx_destroy_pool(c->pool);
1752
1753 #if (NGX_THREADS)
1754
1755 if (ngx_mutex_lock(ngx_posted_events_mutex) == NGX_OK) {
1756 ngx_unlock(&c->lock);
1757 c->read->locked = 0;
1758 c->write->locked = 0;
1759
1760 ngx_mutex_unlock(ngx_posted_events_mutex);
1761 }
1762
1763 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, ngx_cycle->log, 0,
1764 "connection lock: %d " PTR_FMT, c->lock, &c->lock);
1765
1766 #endif
1767 1790
1768 if (ngx_close_socket(fd) == -1) { 1791 if (ngx_close_socket(fd) == -1) {
1769 1792
1770 /* we use ngx_cycle->log because c->log was in c->pool */ 1793 /* we use ngx_cycle->log because c->log was in c->pool */
1771 1794