diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-07-18 00:25:47 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-07-19 01:29:49 +0000 |
commit | 6d2642bb1a42840e809e7a73896a1631d37b15e6 (patch) | |
tree | adaed302c3370ed83e0c32a1e32343b4631afd20 | |
parent | 48bbaf84da51644451a3dc0c1254d51c035ccce0 (diff) | |
download | cmogstored-6d2642bb1a42840e809e7a73896a1631d37b15e6.tar.gz |
This should allow easier tracing of rbuf growth, and should hopefully make the code more explicit and harder to screw up.
-rw-r--r-- | http.c | 16 | ||||
-rw-r--r-- | mgmt.c | 15 |
2 files changed, 23 insertions, 8 deletions
@@ -236,6 +236,16 @@ http_client_died(struct mog_fd *mfd, size_t buf_len, int save_err) return MOG_NEXT_CLOSE; } +MOG_NOINLINE static char * +http_rbuf_grow(struct mog_fd *mfd, struct mog_rbuf **rbuf, size_t buf_len) +{ + struct mog_http *http = &mfd->as.http; + + (*rbuf)->rsize = buf_len; + http->rbuf = *rbuf = mog_rbuf_grow(*rbuf); + return *rbuf ? (*rbuf)->rptr : NULL; +} + static enum mog_next __http_queue_step(struct mog_fd *mfd) { struct mog_http *http = &mfd->as.http; @@ -288,11 +298,9 @@ parse: assert(http->wbuf == NULL && "tried to write (and failed) with partial req"); if (http->_p.buf_off >= rbuf->rcapa) { - rbuf->rsize = buf_len; - http->rbuf = rbuf = mog_rbuf_grow(rbuf); - if (!rbuf) + buf = http_rbuf_grow(mfd, &rbuf, buf_len); + if (!buf) goto err400; - buf = rbuf->rptr; } off = http->_p.buf_off; goto reread; @@ -214,6 +214,15 @@ static enum mog_next mgmt_run(struct mog_fd *mfd, struct mog_rbuf *rbuf, return mgmt->wbuf ? MOG_NEXT_WAIT_WR : MOG_NEXT_ACTIVE; } +MOG_NOINLINE static char * +mgmt_rbuf_grow(struct mog_fd *mfd, struct mog_rbuf **rbuf, size_t buf_len) +{ + struct mog_mgmt *mgmt = &mfd->as.mgmt; + (*rbuf)->rsize = buf_len; + mgmt->rbuf = *rbuf = mog_rbuf_grow(*rbuf); + return *rbuf ? (*rbuf)->rptr : NULL; +} + /* * this is the main event callback and called whenever mgmt * is pulled out of a queue (either idle or active) @@ -265,11 +274,9 @@ parse: assert(mgmt->wbuf == NULL && "tried to write (and failed) with partial req"); if (mgmt->buf_off >= rbuf->rcapa) { - rbuf->rsize = buf_len; - mgmt->rbuf = rbuf = mog_rbuf_grow(rbuf); - if (!rbuf) + buf = mgmt_rbuf_grow(mfd, &rbuf, buf_len); + if (!buf) goto too_large; - buf = rbuf->rptr; } off = mgmt->buf_off; goto reread; |