nginx-0.0.1-2004-01-05-23:55:48 import
diff --git a/src/os/unix/ngx_recv.c b/src/os/unix/ngx_recv.c
index 7cb949a..1ebbe69 100644
--- a/src/os/unix/ngx_recv.c
+++ b/src/os/unix/ngx_recv.c
@@ -17,8 +17,9 @@
rev = c->read;
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
- ngx_log_debug(c->log, "recv: eof:%d, avail:%d, err:%d" _
- rev->kq_eof _ rev->available _ rev->kq_errno);
+ ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
+ "recv: eof:%d, avail:%d, err:%d",
+ rev->kq_eof, rev->available, rev->kq_errno);
if (rev->available == 0) {
if (rev->kq_eof) {
@@ -28,7 +29,16 @@
if (rev->kq_errno) {
rev->error = 1;
ngx_set_socket_errno(rev->kq_errno);
- return ngx_unix_recv_error(rev, rev->kq_errno);
+ ngx_log_error(NGX_LOG_INFO, c->log, rev->kq_errno,
+ "kevent() reported about closed connection");
+
+ if (rev->kq_errno == NGX_ECONNRESET
+ && rev->log_error == NGX_ERROR_IGNORE_ECONNRESET)
+ {
+ return 0;
+ }
+
+ return NGX_ERROR;
}
return 0;
@@ -42,7 +52,7 @@
do {
n = recv(c->fd, buf, size, 0);
- ngx_log_debug(c->log, "recv: %d:%d" _ n _ size);
+ ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,"recv: %d:%d", n, size);
if (n >= 0) {
if (ngx_event_flags & NGX_HAVE_KQUEUE_EVENT) {
@@ -104,7 +114,7 @@
do {
n = recv(c->fd, buf, size, 0);
- ngx_log_debug(c->log, "recv: %d:%d" _ n _ size);
+ ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,"recv: %d:%d", n, size);
if (n >= 0) {
if ((size_t) n < size) {
@@ -138,21 +148,33 @@
static int ngx_unix_recv_error(ngx_event_t *rev, ngx_err_t err)
{
- if (err == NGX_ECONNRESET && rev->ignore_econnreset) {
- return 0;
- }
+ ngx_int_t level;
- if (err == NGX_EAGAIN) {
- ngx_log_error(NGX_LOG_INFO, rev->log, err, "recv() returned EAGAIN");
+ if (err == NGX_EAGAIN || err == NGX_EINTR) {
+ ngx_log_debug0(NGX_LOG_DEBUG_EVENT, rev->log, err, "recv() not ready");
return NGX_AGAIN;
}
- if (err == NGX_EINTR) {
- ngx_log_error(NGX_LOG_INFO, rev->log, err, "recv() returned EINTR");
- return NGX_EINTR;
+ if (err == NGX_ECONNRESET) {
+
+ switch (rev->log_error) {
+ case NGX_ERROR_IGNORE_ECONNRESET:
+ return 0;
+ case NGX_ERROR_INFO:
+ level = NGX_LOG_INFO;
+ break;
+ case NGX_ERROR_ERR:
+ level = NGX_LOG_ERR;
+ break;
+ default:
+ level = NGX_LOG_CRIT;
+ }
+
+ } else {
+ level = NGX_LOG_CRIT;
}
- ngx_log_error(NGX_LOG_ERR, rev->log, err, "recv() failed");
+ ngx_log_error(level, rev->log, err, "recv() failed");
return NGX_ERROR;
}