comparison src/os/unix/ngx_process_cycle.c @ 1718:5b24b2decde8 stable-0.5

r1576, r1578, r1579 merge: avoid segfault if poll is used and endless loop if select is used
author Igor Sysoev <igor@sysoev.ru>
date Wed, 12 Dec 2007 20:35:32 +0000
parents 6b81bbc36eaf
children 2ab8bb66d3d7
comparison
equal deleted inserted replaced
1717:eec1a26a8ca1 1718:5b24b2decde8
1033 1033
1034 static void 1034 static void
1035 ngx_channel_handler(ngx_event_t *ev) 1035 ngx_channel_handler(ngx_event_t *ev)
1036 { 1036 {
1037 ngx_int_t n; 1037 ngx_int_t n;
1038 ngx_socket_t fd;
1039 ngx_channel_t ch; 1038 ngx_channel_t ch;
1040 ngx_connection_t *c; 1039 ngx_connection_t *c;
1041 1040
1042 if (ev->timedout) { 1041 if (ev->timedout) {
1043 ev->timedout = 0; 1042 ev->timedout = 0;
1051 n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log); 1050 n = ngx_read_channel(c->fd, &ch, sizeof(ngx_channel_t), ev->log);
1052 1051
1053 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel: %i", n); 1052 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "channel: %i", n);
1054 1053
1055 if (n == NGX_ERROR) { 1054 if (n == NGX_ERROR) {
1056 1055 ngx_close_connection(c);
1057 ngx_free_connection(c);
1058
1059 fd = c->fd;
1060 c->fd = (ngx_socket_t) -1;
1061
1062 if (close(fd) == -1) {
1063 ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
1064 "close() channel failed");
1065 }
1066
1067 return; 1056 return;
1068 } 1057 }
1069 1058
1070 if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) { 1059 if (ngx_event_flags & NGX_USE_EVENTPORT_EVENT) {
1071 if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) { 1060 if (ngx_add_event(ev, NGX_READ_EVENT, 0) == NGX_ERROR) {