tabled: Fix buffer pointer confusion in object.c
PATCH 4/7 tabled: Fix buffer pointer confusion in object.c
This bug leads to object's data corrupt whenever the write is partial.
Signed-off-by Pete Zaitcev <[email protected]>
--- server/object.c | 5 ++++- server/tabled.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
server/object.c +4 -1
@@ -547,7 +547,7 @@ static void object_put_event(struct open_chunk *ochunk)return ; } - bytes =stor_put_buf (ochunk, cli->out_buf, cli->out_bcnt); + bytes =stor_put_buf (ochunk, ochunk->wbuf, ochunk->wcnt);if (bytes <0 ) {if (debugging) applog(LOG_DEBUG, "write(2) error: %s",
@@ -569,6 +569,7 @@ static void object_put_event(struct open_chunk *ochunk)free (ochunk);return ; } + ochunk->wbuf += bytes; ochunk->wcnt -= bytes;if (ochunk->wcnt ==0 ) {
@@ -592,6 +593,7 @@ static int object_put_buf(struct client *cli, struct open_chunk *ochunk, {ssize_t bytes; + ochunk->wbuf = buf; ochunk->wcnt = len; bytes =stor_put_buf (ochunk, buf, len);
@@ -603,6 +605,7 @@ static int object_put_buf(struct client *cli, struct open_chunk *ochunk,return -EIO ; } ochunk->wcnt -= bytes; + ochunk->wbuf += bytes;if (ochunk->wcnt !=0 ) cli->out_nput++;
server/tabled.h +1 -0
@@ -123,6 +123,7 @@ struct open_chunk {int wfd;bool w_armed;struct event wevt; +void *wbuf;size_t wcnt;/* in current buffer */ uint64_t roff;
Jeff Garzik
AppliedQuoted 3 lines · Pete Zaitcev
This bug leads to object's data corrupt whenever the write is partial.
Signed-off-by Pete Zaitcev<[email protected]>
applied