cmogstored dev/user discussion/issues/patches/etc
 help / color / mirror / code / Atom feed
* [HOLD] http: use ENOSPC instead of ERANGE to signal 507 errors
@ 2015-11-09  5:34 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-11-09  5:34 UTC (permalink / raw)
  To: cmogstored-public

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-09  5:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-09  5:34 [HOLD] http: use ENOSPC instead of ERANGE to signal 507 errors 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).