about summary refs log tree commit homepage
path: root/http.c
diff options
context:
space:
mode:
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;