about summary refs log tree commit homepage
path: root/http.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-07-18 00:25:47 +0000
committerEric Wong <normalperson@yhbt.net>2013-07-19 01:29:49 +0000
commit6d2642bb1a42840e809e7a73896a1631d37b15e6 (patch)
treeadaed302c3370ed83e0c32a1e32343b4631afd20 /http.c
parent48bbaf84da51644451a3dc0c1254d51c035ccce0 (diff)
downloadcmogstored-6d2642bb1a42840e809e7a73896a1631d37b15e6.tar.gz
This should allow easier tracing of rbuf growth, and should
hopefully make the code more explicit and harder to screw up.
Diffstat (limited to 'http.c')
-rw-r--r--http.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/http.c b/http.c
index cc802c3..6f51cf8 100644
--- a/http.c
+++ b/http.c
@@ -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;