store HttpStream buflen as pointer (referencing NSAPISession cursize) webdav

Sat, 07 May 2022 14:13:08 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 07 May 2022 14:13:08 +0200
branch
webdav
changeset 336
fb75473fecca
parent 335
5234c57b8759
child 337
d934c2eb6a76

store HttpStream buflen as pointer (referencing NSAPISession cursize)

src/server/util/io.c file | annotate | diff | comparison | revisions
src/server/util/io.h file | annotate | diff | comparison | revisions
--- a/src/server/util/io.c	Sat May 07 14:08:46 2022 +0200
+++ b/src/server/util/io.c	Sat May 07 14:13:08 2022 +0200
@@ -268,7 +268,7 @@
     http->read = 0;
     http->readbuf = buffer;
     http->bufsize = bufsize;
-    http->buflen = *cursize; // TODO: store buflen as pointer
+    http->buflen = cursize;
     http->bufpos = pos;
     http->chunk_buf_pos = 0;
     return 0;
@@ -364,7 +364,7 @@
     
     // copy available data from st->readbuf to buf
     int pos = *st->bufpos;
-    size_t buf_available = st->buflen - pos;
+    size_t buf_available = *st->buflen - pos;
     if(buf_available) {
         size_t cplen = buf_available > nbytes ? nbytes : buf_available;
         if(read_data) {
@@ -389,12 +389,12 @@
     // to not perform IO, if we have previously copied data from readbuf
     // this ensures we never override non-chunk-header data
     if(*perform_io && ((read_data && nbytes > 0 && st->max_read - st->read) || (!read_data && r == 0))) {
-        if(st->buflen - *st->bufpos > 0) {
+        if(*st->buflen - *st->bufpos > 0) {
             printf("todo: fix, should not happen, remove later\n");
         }
         // fill buffer again
         ssize_t rlen = st->fd->read(st->fd, st->readbuf, st->bufsize);
-        st->buflen = rlen;
+        *st->buflen = rlen;
         *st->bufpos = 0;
         *perform_io = WS_FALSE;
         if(rlen < 0) {
--- a/src/server/util/io.h	Sat May 07 14:08:46 2022 +0200
+++ b/src/server/util/io.h	Sat May 07 14:13:08 2022 +0200
@@ -117,7 +117,7 @@
     /*
      * number of bytes currently stored in readbuf
      */
-    size_t   buflen;  // currently number of bytes in the buffer
+    int      *buflen;  // currently number of bytes in the buffer
     /*
      * current position in the read buffer
      */

mercurial