* [PATCH] http_get.c: log filesystem-level errors from sendfile
@ 2018-07-09 7:37 Eric Wong
2018-07-10 20:59 ` [PATCH 2/1] http_get: show hexadecimal device numbers Eric Wong
0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2018-07-09 7:37 UTC (permalink / raw)
To: cmogstored-public
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/1] http_get: show hexadecimal device numbers
2018-07-09 7:37 [PATCH] http_get.c: log filesystem-level errors from sendfile Eric Wong
@ 2018-07-10 20:59 ` Eric Wong
0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2018-07-10 20:59 UTC (permalink / raw)
To: cmogstored-public
It's more obvious distinguish major/minor numbers from
---
http_get.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/http_get.c b/http_get.c
index 154d8c5..156f43f 100644
--- a/http_get.c
+++ b/http_get.c
@@ -268,7 +268,7 @@ static void sendfile_error(struct mog_fd *file_mfd, int sferr)
if (!fstat(file_mfd->fd, &st)) {
errno = sferr;
syslog(LOG_ERR,
-"sendfile on (dev=%lu,ino=%lu) failed at offset=%lld: %m",
+"sendfile on (dev=%#lx,ino=%lu) failed at offset=%lld: %m",
(unsigned long)st.st_dev, (unsigned long)st.st_ino,
(long long)file->foff);
}
--
EW
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-10 20:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-09 7:37 [PATCH] http_get.c: log filesystem-level errors from sendfile Eric Wong
2018-07-10 20:59 ` [PATCH 2/1] http_get: show hexadecimal device numbers Eric Wong
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).