From 831045dd33e524aee3ee86bd974e0310734dbec3 Mon Sep 17 00:00:00 2001 From: aswift Date: Fri, 22 Aug 2008 00:25:52 +0000 Subject: [PATCH] Deferring file descriptor closing to avoid trashing locks when directly manipulating sqlite db file contents (causes errors on AFP testing) (CVS 5587) FossilOrigin-Name: e28a2870b49509502529892ff8ddb9fcf3a27173 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/exclusive2.test | 28 +++++++++++++++++----------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index c69609b71f..00e122cb06 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Added\sSQLITE_IOERR_LOCK\sextended\serror\scode\sand\ssupport\sfor\sdetecting\sand\sreturning\serrors\sin\sthe\sos_unix\slock,\sunlock\sand\scheck\sreserved\slock\svariants,\salso\sadded\ssupport\sfor\spopulating\sand\sreturning\ssystem\serror\scodes\sso\sthat\sthey\scan\sbe\saccessed\svia\sxGetLastError,\sunfortunately\sxGetLastError\scan't\sseem\sto\saccess\sthe\sunixFile\sstructure\swhere\sthe\slastErrno\sis\srecorded.\s(CVS\s5586) -D 2008-08-22T00:22:35 +C Deferring\sfile\sdescriptor\sclosing\sto\savoid\strashing\slocks\swhen\sdirectly\smanipulating\ssqlite\sdb\sfile\scontents\s(causes\serrors\son\sAFP\stesting)\s(CVS\s5587) +D 2008-08-22T00:25:53 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 51b727303f84cf055e29514d8248e5eaf9701379 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -283,7 +283,7 @@ F test/enc2.test 6d91a5286f59add0cfcbb2d0da913b76f2242398 F test/enc3.test 5c550d59ff31dccdba5d1a02ae11c7047d77c041 F test/eval.test 020a21a236667bd4c56205d999c9992f1d944cac F test/exclusive.test 5390ddf1f90a6d055111c0ebe6311045dd3035e1 -F test/exclusive2.test d13bf66753dca46e61241d35d36ab7c868b0d313 +F test/exclusive2.test 7d2b1c0370f1e1dac4a728bd653f2dea5100fcf6 F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7 F test/expr.test a47d304a90c75def083cce3b1cd6c282842e6bbe F test/filectrl.test 524853082d5d7fb442599730ec3a0f3f84a3a936 @@ -622,7 +622,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e -P 80d6a31cb3851704c09ac9d99fe4bc241df3c180 -R 7431cc71998a6f7b8eb2579a2fd9f22d +P c1af14e2b6bf5af0aff3df3adbe8cb9aabe1c4a3 +R 020594f125bbbdb48c5aa062c24e5325 U aswift -Z 6c65e4f8868dab6fff3ca3acb52662f8 +Z 6df8c751714bfb1ec9bdc42c787ab3b8 diff --git a/manifest.uuid b/manifest.uuid index 8aadbed121..5eddc5cea0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c1af14e2b6bf5af0aff3df3adbe8cb9aabe1c4a3 \ No newline at end of file +e28a2870b49509502529892ff8ddb9fcf3a27173 \ No newline at end of file diff --git a/test/exclusive2.test b/test/exclusive2.test index d0eeb19b3d..a78f2a91cb 100644 --- a/test/exclusive2.test +++ b/test/exclusive2.test @@ -10,7 +10,7 @@ #*********************************************************************** # This file implements regression tests for SQLite library. # -# $Id: exclusive2.test,v 1.8 2007/08/12 20:07:59 drh Exp $ +# $Id: exclusive2.test,v 1.9 2008/08/22 00:25:53 aswift Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -25,9 +25,14 @@ ifcapable {!pager_pragmas} { # sqlite3_soft_heap_limit 0 -proc pagerChangeCounter {filename {new ""}} { - set fd [open $filename RDWR] - fconfigure $fd -translation binary -encoding binary +proc pagerChangeCounter {filename new {fd ""}} { + if {$fd==""} { + set fd [open $filename RDWR] + fconfigure $fd -translation binary -encoding binary + set needClose 1 + } else { + set needClose 0 + } if {$new ne ""} { seek $fd 24 set a [expr {($new&0xFF000000)>>24}] @@ -46,7 +51,7 @@ proc pagerChangeCounter {filename {new ""}} { incr ret [expr ($c&0x000000FF)<<8] incr ret [expr ($d&0x000000FF)<<0] - close $fd + if {$needClose} {close $fd} return $ret } @@ -207,16 +212,16 @@ do_test exclusive2-2.3 { } $::sig do_test exclusive2-2.4 { - set fd [open test.db RDWR] - seek $fd 1024 - puts -nonewline $fd [string repeat [binary format c 0] 10000] - flush $fd - close $fd + set ::fd [open test.db RDWR] + fconfigure $::fd -translation binary + seek $::fd 1024 + puts -nonewline $::fd [string repeat [binary format c 0] 10000] + flush $::fd t1sig } $::sig do_test exclusive2-2.5 { - pagerChangeCounter test.db 5 + pagerChangeCounter test.db 5 $::fd } {5} do_test exclusive2-2.6 { t1sig @@ -240,6 +245,7 @@ do_test exclusive2-2.8 { db close db2 close +catch {close $::fd} file delete -force test.db file delete -force test.db-journal