about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-07-09 07:37:52 +0000
committerEric Wong <e@80x24.org>2018-07-09 07:38:11 +0000
commit6567228f718578373e771f92dd69daaa716fbbed (patch)
tree05c9c4695cc3993067f8299b5af3341da247070a
parent4a62891c7487a6776ed7112184ef54091e04a6a1 (diff)
downloadcmogstored-6567228f718578373e771f92dd69daaa716fbbed.tar.gz
Socket errors are too common to log (especially from malicous
clients), but filesystem errors are rare and important.
-rw-r--r--http_get.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/http_get.c b/http_get.c
index 23140de..154d8c5 100644
--- a/http_get.c
+++ b/http_get.c
@@ -260,6 +260,25 @@ forbidden:
         } while(0));
 }
 
+static void sendfile_error(struct mog_fd *file_mfd, int sferr)
+{
+        struct mog_file *file = &file_mfd->as.file;
+        struct stat st;
+
+        if (!fstat(file_mfd->fd, &st)) {
+                errno = sferr;
+                syslog(LOG_ERR,
+"sendfile on (dev=%lu,ino=%lu) failed at offset=%lld: %m",
+                        (unsigned long)st.st_dev, (unsigned long)st.st_ino,
+                        (long long)file->foff);
+        }
+        else {
+                syslog(LOG_ERR,
+"sendfile failed at offset=%lld: %s (fstat error: %m)",
+                        (long long)file->foff, strerror(sferr));
+        }
+}
+
 enum mog_next mog_http_get_in_progress(struct mog_fd *mfd)
 {
         struct mog_http *http = &mfd->as.http;
@@ -289,6 +308,12 @@ retry:
                 switch (errno) {
                 case_EAGAIN: return MOG_NEXT_WAIT_WR;
                 case EINTR: goto retry;
+                case EPIPE:
+                case ENOTCONN:
+                case ECONNRESET:
+                        break;
+                default:
+                        sendfile_error(file_mfd, errno);
                 }
                 http->_p.persistent = 0;
         } else { /* w == 0 */