From: Eric Wong <e@80x24.org>
To: cmogstored-public@bogomips.org
Subject: [PATCH] http_get.c: log filesystem-level errors from sendfile
Date: Mon, 9 Jul 2018 07:37:52 +0000 [thread overview]
Message-ID: <20180709073752.21514-1-e@80x24.org> (raw)
Socket errors are too common to log (especially from malicous
clients), but filesystem errors are rare and important.
---
http_get.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
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 */
--
EW
next reply other threads:[~2018-07-09 7:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-09 7:37 Eric Wong [this message]
2018-07-10 20:59 ` [PATCH 2/1] http_get: show hexadecimal device numbers Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/cmogstored/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180709073752.21514-1-e@80x24.org \
--to=e@80x24.org \
--cc=cmogstored-public@bogomips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/cmogstored.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).