diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-07-19 00:15:31 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-07-19 01:30:17 +0000 |
commit | 313a04bd35534a6cd024149d9f2c9b9487f08165 (patch) | |
tree | c7c5b3db10715ba68a9c09025c26f51785cfae42 /http.c | |
parent | 00d234c6f9362c11938f3b67c03bf208c7638eca (diff) | |
download | cmogstored-313a04bd35534a6cd024149d9f2c9b9487f08165.tar.gz |
Incomplete request headers are uncommon, so if we see them, something is probably off or strange. This should make it easier to maintain probe points to watch for this behavior.
Diffstat (limited to 'http.c')
-rw-r--r-- | http.c | 33 |
1 files changed, 23 insertions, 10 deletions
@@ -236,7 +236,7 @@ http_client_died(struct mog_fd *mfd, size_t buf_len, int save_err) return MOG_NEXT_CLOSE; } -MOG_NOINLINE static char * +static char * http_rbuf_grow(struct mog_fd *mfd, struct mog_rbuf **rbuf, size_t buf_len) { struct mog_http *http = &mfd->as.http; @@ -246,6 +246,24 @@ http_rbuf_grow(struct mog_fd *mfd, struct mog_rbuf **rbuf, size_t buf_len) return *rbuf ? (*rbuf)->rptr : NULL; } +MOG_NOINLINE static bool +http_parse_continue(struct mog_fd *mfd, struct mog_rbuf **rbuf, + char **buf, size_t buf_len, uint32_t *off) +{ + struct mog_http *http = &mfd->as.http; + + assert(http->wbuf == NULL && + "tried to write (and failed) with partial req"); + if (http->_p.buf_off >= (*rbuf)->rcapa) { + *buf = http_rbuf_grow(mfd, rbuf, buf_len); + if (!*buf) + return false; + } + + *off = http->_p.buf_off; + return true; +} + static enum mog_next __http_queue_step(struct mog_fd *mfd) { struct mog_http *http = &mfd->as.http; @@ -295,15 +313,10 @@ parse: case MOG_PARSER_ERROR: goto err507or400; case MOG_PARSER_CONTINUE: - assert(http->wbuf == NULL && - "tried to write (and failed) with partial req"); - if (http->_p.buf_off >= rbuf->rcapa) { - buf = http_rbuf_grow(mfd, &rbuf, buf_len); - if (!buf) - goto err400; - } - off = http->_p.buf_off; - goto reread; + if (http_parse_continue(mfd, &rbuf, &buf, buf_len, + &off)) + goto reread; + goto err400; case MOG_PARSER_DONE: return http_run(mfd, rbuf, buf, buf_len); } |