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(-)

diff --git a/server/object.c b/server/object.c
index b329c0d..5c0f97f 100644
--- a/server/object.c
+++ b/server/object.c
@@ -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++;
diff --git a/server/tabled.h b/server/tabled.h
index e4dbbd5..fd6142e 100644
--- a/server/tabled.h
+++ b/server/tabled.h
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to