Fixed LUFS read()/write() atomicity.
authorshort <>
Thu, 6 Nov 2003 10:44:30 +0000 (10:44 +0000)
committershort <>
Thu, 6 Nov 2003 10:44:30 +0000 (10:44 +0000)
 - Do not unlock 'libcaptive' between seek() and read()/write()!

src/client/lufs/captivefs-file.c

index 63f9ffe..d570ae8 100644 (file)
@@ -358,13 +358,14 @@ GnomeVFSResult errvfsresult;
        if (!(captive_file_object=FileHandle_lookup(file)))
                return -1;
 
+       /* Do not unlock 'libcaptive' between seek() and read()! */
        G_LOCK(libcaptive);
        errvfsresult=captive_file_seek(captive_file_object,GNOME_VFS_SEEK_START,offset);
-       G_UNLOCK(libcaptive);
-       if (errvfsresult!=GNOME_VFS_OK)
+       if (errvfsresult!=GNOME_VFS_OK) {
+               G_UNLOCK(libcaptive);
                return -1;
+               }
 
-       G_LOCK(libcaptive);
        errvfsresult=captive_file_read(captive_file_object,buf,count,&bytes_read);
        G_UNLOCK(libcaptive);
        if (errvfsresult!=GNOME_VFS_OK)
@@ -399,13 +400,14 @@ GnomeVFSResult errvfsresult;
        if (!(captive_file_object=FileHandle_lookup(file)))
                return -1;
 
+       /* Do not unlock 'libcaptive' between seek() and write()! */
        G_LOCK(libcaptive);
        errvfsresult=captive_file_seek(captive_file_object,GNOME_VFS_SEEK_START,offset);
-       G_UNLOCK(libcaptive);
-       if (errvfsresult!=GNOME_VFS_OK)
+       if (errvfsresult!=GNOME_VFS_OK) {
+               G_UNLOCK(libcaptive);
                return -1;
+               }
 
-       G_LOCK(libcaptive);
        errvfsresult=captive_file_write(captive_file_object,buf,count,&bytes_written);
        G_UNLOCK(libcaptive);
        if (errvfsresult!=GNOME_VFS_OK)