From: Eric Wong <e@80x24.org>
To: cmogstored-public@bogomips.org
Subject: [HOLD] http: use ENOSPC instead of ERANGE to signal 507 errors
Date: Mon, 9 Nov 2015 05:34:14 +0000 [thread overview]
Message-ID: <20151109053414.17669-1-e@80x24.org> (raw)
It makes a bit more sense this way for returning 507 errors,
since we may also be using ERANGE for the next commit.
In retrospect, relying on errno like this probably wasn't a great
idea and future changes may clean this up.
---
chunk_parser.rl | 2 +-
http.c | 2 +-
http_parser.rl | 2 +-
http_put.c | 5 ++---
4 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/chunk_parser.rl b/chunk_parser.rl
index 0eb2e22..f482444 100644
--- a/chunk_parser.rl
+++ b/chunk_parser.rl
@@ -82,7 +82,7 @@ static inline off_t hexchar2off(int xdigit)
http->_p.content_len *= 16;
http->_p.content_len += hexchar2off(fc);
if (http->_p.content_len < prev) {
- errno = ERANGE;
+ errno = ENOSPC;
http->_p.content_len = -1;
fbreak;
}
diff --git a/http.c b/http.c
index 1914d18..316b2d1 100644
--- a/http.c
+++ b/http.c
@@ -342,7 +342,7 @@ parse:
assert(0 && "compiler bug?");
err507or400:
- if (errno == ERANGE) {
+ if (errno == ENOSPC) {
mog_http_resp(mfd, "507 Insufficient Storage", false);
} else {
err400:
diff --git a/http_parser.rl b/http_parser.rl
index 8e82828..fdfbd97 100644
--- a/http_parser.rl
+++ b/http_parser.rl
@@ -15,7 +15,7 @@ static bool length_incr(off_t *len, unsigned c)
if (*len >= prev)
return true;
- errno = ERANGE;
+ errno = ENOSPC;
*len = -1;
return false;
diff --git a/http_put.c b/http_put.c
index 3334d56..6055572 100644
--- a/http_put.c
+++ b/http_put.c
@@ -97,7 +97,6 @@ MOG_NOINLINE static enum mog_next
write_err(struct mog_fd *mfd, const char *default_msg)
{
switch (errno) {
- case ERANGE:
case ENOSPC:
case EFBIG:
return stop(mfd, "507 Insufficient Storage");
@@ -263,14 +262,14 @@ identity_body_after_header(struct mog_fd *mfd, char *buf, size_t buf_len)
static bool lengths_ok(struct mog_http *http)
{
if (http->_p.content_len < 0)
- return false; /* ERANGE */
+ return false; /* ENOSPC */
if (http->_p.has_content_range) {
if (http->_p.chunked)
return false;
if (http->_p.range_end < 0 || http->_p.range_beg < 0)
- return false; /* ERANGE */
+ return false; /* ENOSPC */
assert(http->_p.range_end >= 0 && http->_p.range_beg >= 0 &&
"bad range, http_parser.rl broken");
--
EW
reply other threads:[~2015-11-09 5:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20151109053414.17669-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).