From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: cmogstored-public@bogomips.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 69A9963383F for ; Mon, 9 Nov 2015 05:34:14 +0000 (UTC) From: Eric Wong 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 Message-Id: <20151109053414.17669-1-e@80x24.org> List-Id: 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