git » libjio » commit bfca59e

Fix a very stupid but important bug that didn't update the file pointer after a jwrite() or jwritev().

author Alberto Bertogli
2004-04-02 02:18:33 UTC
committer Alberto Bertogli
2007-07-15 12:31:26 UTC
parent 2f0dd658c407410890ec271b62eec9c9cba5edef

Fix a very stupid but important bug that didn't update the file pointer after a jwrite() or jwritev().

Fix a very stupid but important bug that didn't update the file pointer after
a jwrite() or jwritev().

libjio.c +10 -0

diff --git a/libjio.c b/libjio.c
index a6fa8db..876a255 100644
--- a/libjio.c
+++ b/libjio.c
@@ -554,6 +554,11 @@ ssize_t jwrite(struct jfs *fs, void *buf, size_t count)
 	ts.len = count;
 	
 	rv = jtrans_commit(&ts);
+
+	if (rv >= 0) {
+		/* if success, advance the file pointer */
+		lseek(fs->fd, count, SEEK_CUR);
+	}
 	
 	pthread_mutex_unlock(&(fs->lock));
 	return rv;
@@ -616,6 +621,11 @@ ssize_t jwritev(struct jfs *fs, struct iovec *vector, int count)
 	ts.len = sum;
 	
 	rv = jtrans_commit(&ts);
+
+	if (rv >= 0) {
+		/* if success, advance the file pointer */
+		lseek(fs->fd, count, SEEK_CUR);
+	}
 	
 	pthread_mutex_unlock(&(fs->lock));
 	return rv;