From: short <> Date: Thu, 6 Nov 2003 10:44:30 +0000 (+0000) Subject: Fixed LUFS read()/write() atomicity. X-Git-Tag: captive-1_0_2~9 X-Git-Url: http://git.jankratochvil.net/?p=captive.git;a=commitdiff_plain;h=a0081ab30a504894829909ba7a3cf3b5e7bc56ae;hp=a73a9e87fba2ac850ed0393cd6762461498af73d Fixed LUFS read()/write() atomicity. - Do not unlock 'libcaptive' between seek() and read()/write()! --- diff --git a/src/client/lufs/captivefs-file.c b/src/client/lufs/captivefs-file.c index 63f9ffe..d570ae8 100644 --- a/src/client/lufs/captivefs-file.c +++ b/src/client/lufs/captivefs-file.c @@ -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)