

Check fsync()'s return value inside jsync(), and avoid the cleanup if it
failed.

---

 cur-root/libjio.h |    2 +-
 cur-root/trans.c  |   17 +++++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff -puN trans.c~check_fsync_in_jsync trans.c
--- cur/trans.c~check_fsync_in_jsync	2004-07-14 23:22:51.413118448 -0300
+++ cur-root/trans.c	2004-07-14 23:22:51.418117688 -0300
@@ -558,11 +558,16 @@ int jopen(struct jfs *fs, const char *na
 }
 
 /* sync a file (makes sense only if using lingering transactions) */
-void jsync(struct jfs *fs)
+int jsync(struct jfs *fs)
 {
+	int rv;
 	struct jlinger *linger, *ltmp;
 
-	fsync(fs->fd);
+	pthread_mutex_lock(&(fs->lock));
+
+	rv = fsync(fs->fd);
+	if (rv != 0)
+		goto exit;
 
 	linger = fs->ltrans;
 	while (linger != NULL) {
@@ -575,13 +580,17 @@ void jsync(struct jfs *fs)
 
 		linger = ltmp;
 	}
+
+exit:
+	pthread_mutex_unlock(&(fs->lock));
+	return rv;
 }
 
 /* close a file */
 int jclose(struct jfs *fs)
 {
-	jsync(fs);
-
+	if (jsync(fs))
+		return -1;
 	if (close(fs->fd))
 		return -1;
 	if (close(fs->jfd))
diff -puN libjio.h~check_fsync_in_jsync libjio.h
--- cur/libjio.h~check_fsync_in_jsync	2004-07-14 23:22:51.414118296 -0300
+++ cur-root/libjio.h	2004-07-14 23:22:51.418117688 -0300
@@ -98,7 +98,7 @@ int jtrans_add(struct jtrans *ts, const 
 int jtrans_commit(struct jtrans *ts);
 int jtrans_rollback(struct jtrans *ts);
 void jtrans_free(struct jtrans *ts);
-void jsync(struct jfs *fs);
+int jsync(struct jfs *fs);
 int jclose(struct jfs *fs);
 
 
_
