diff --git a/src/ngx_http_lua_util.c b/src/ngx_http_lua_util.c index 47768c003b..f4f9d8d513 100644 --- a/src/ngx_http_lua_util.c +++ b/src/ngx_http_lua_util.c @@ -3419,6 +3419,45 @@ ngx_http_lua_check_broken_connection(ngx_http_request_t *r, ngx_event_t *ev) return NGX_HTTP_CLIENT_CLOSED_REQUEST; } +#endif + +#if (NGX_HAVE_EPOLLRDHUP) + + if ((ngx_event_flags & NGX_USE_EPOLL_EVENT) && ngx_use_epoll_rdhup) { + socklen_t len; + + if (!ev->pending_eof) { + return NGX_OK; + } + + ev->eof = 1; + c->error = 1; + + err = 0; + len = sizeof(ngx_err_t); + + /* + * BSDs and Linux return 0 and set a pending error in err + * Solaris returns -1 and sets errno + */ + + if (getsockopt(c->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len) + == -1) + { + err = ngx_socket_errno; + } + + if (err) { + ev->error = 1; + } + + ngx_log_error(NGX_LOG_INFO, ev->log, err, + "epoll_wait() reported that client prematurely closed " + "connection"); + + return NGX_HTTP_CLIENT_CLOSED_REQUEST; + } + #endif n = recv(c->fd, buf, 1, MSG_PEEK);