From 18839217da40e2ca4da0ec7920dac941fa8900b0 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 26 Nov 2005 03:43:23 +0000 Subject: [PATCH] Add an OS method for making copies of file descriptors. This fixes the crash tests. (CVS 2786) FossilOrigin-Name: 57a674fc71512f11393b8eb595961ec9465ba4e1 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/os.h | 1 + src/os_unix.c | 7 +++++++ src/os_win.c | 9 +++++++++ src/pager.c | 4 ++-- src/test6.c | 9 +++++++++ 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 4724112ce0..02c6f3ecdd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\sOS\slayer\sso\sthat\sI/O\sroutines\sare\scalled\sthrough\sa\svirtual\sfunction\ntable.\s\sThe\sos_test.c\smodule\shas\sbeen\sreplaced\sby\stest6.c.\s\sThe\scrash\stests\nare\sbusted\snow\sand\sneed\sto\sbe\sfixed.\s(CVS\s2785) -D 2005-11-26T00:25:01 +C Add\san\sOS\smethod\sfor\smaking\scopies\sof\sfile\sdescriptors.\s\sThis\sfixes\sthe\ncrash\stests.\s(CVS\s2786) +D 2005-11-26T03:43:23 F Makefile.in 28a2772cd9e03ba758c2a052813092cdb9da73bf F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -50,15 +50,15 @@ F src/insert.c da031c3ed8e1675fac891990095d277c2ba6e205 F src/legacy.c d58ea507bce885298a2c8c3cbb0f4bff5d47830b F src/main.c 97bb830cdbd378d1f87469618471f52d9d263d09 F src/md5.c 7ae1c39044b95de2f62e066f47bb1deb880a1070 -F src/os.h 64564ddc5b70f8968d1df5039810a2e68cebe769 +F src/os.h 101564686bffe1825f7c66a712acb52e3ff3530d F src/os_common.h d74a11728ad2444b6b695b94c28c06881f049e49 F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 -F src/os_unix.c 57f47fd9172991550b2af15b18d8cc9ccb90d307 +F src/os_unix.c 09f174975fe054ed73117ee17c5650f55773fbe3 F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e -F src/os_win.c 5d282b4fb2afdeefd0857357206510e72192302c +F src/os_win.c a3762efcc6eebbf8a38d25ff80e0e510ec7afead F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b -F src/pager.c 561657a20ecbc5fa4c8e1fcfe019006553fd39a1 +F src/pager.c 8231fb8d947d5c524763de34174380684bb801d1 F src/pager.h e7b41ce8e7b5f629d456708b7ad9a8c8ede37140 F src/parse.y e4d57c2fd5cc02f19822ec41f6dc2bfc9bc85609 F src/pragma.c e278b3f722379ab9d630a1569ac05f586f01f4db @@ -76,7 +76,7 @@ F src/test2.c 360cfa7fe17a4fe67f6d19699cd6d59fca4ff09f F src/test3.c f4e6a16a602091696619a1171bda25c0e3df49f7 F src/test4.c a8fd681e139e1c61f22a77d07fc3a99cb28fff3f F src/test5.c 64f08b2a50ef371a1bd68ff206829e7b1b9997f5 -F src/test6.c d86ca78abd3c37149add00efc6538128e776714c +F src/test6.c d8501501dbd257b88b3ecfa5c46d5e2ac230e0f9 F src/tokenize.c bdb79702217af49eba44c2a3b4f5fc7bd9ed2917 F src/trigger.c aea0283a3ef729a3e9c8dc5dc1a11c9fcc0a12a7 F src/update.c fec7665138ccf2a2133f11dcd24c1134c6b33526 @@ -322,7 +322,7 @@ F www/tclsqlite.tcl ddcf912ea48695603c8ed7efb29f0812ef8d1b49 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P dba2cc0d0e0c648c1a4798bc72913e3b19acba6e -R 0354953fb5e466e6ce44febcde77bb5c +P 1f69aec285dd8e26bd739d5e44bb50fe03a9682a +R 4253512b789e7bb7309536d870bf771b U drh -Z e7c0bd1253129b8abe29fc40e7e0d238 +Z 5555b9dd495cd99105a3717d675a6704 diff --git a/manifest.uuid b/manifest.uuid index 948ee9f5e3..0e9e6fcccc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1f69aec285dd8e26bd739d5e44bb50fe03a9682a \ No newline at end of file +57a674fc71512f11393b8eb595961ec9465ba4e1 \ No newline at end of file diff --git a/src/os.h b/src/os.h index 3646308776..0dce6578e2 100644 --- a/src/os.h +++ b/src/os.h @@ -197,6 +197,7 @@ extern struct sqlite3IoVtbl { int (*xLock)(OsFile*, int); int (*xUnlock)(OsFile*, int); int (*xCheckReservedLock)(OsFile *id); + void (*xCopyOsFile)(OsFile *pDest, OsFile *pSrc); } sqlite3Io; /* The interface for file I/O is above. Other miscellaneous functions diff --git a/src/os_unix.c b/src/os_unix.c index 33185ed82c..b6ef2081f8 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1350,6 +1350,12 @@ static char *unixFullPathname(const char *zRelative){ return zFull; } +/* +** Make a copy of an OsFile object. +*/ +static void unixCopyOsFile(OsFile *pDest, OsFile *pSrc){ + *pDest = *pSrc; +} /* ** This is the structure that defines all of the I/O routines. @@ -1375,6 +1381,7 @@ struct sqlite3IoVtbl sqlite3Io = { unixLock, unixUnlock, unixCheckReservedLock, + unixCopyOsFile, }; diff --git a/src/os_win.c b/src/os_win.c index b3715c74f5..45ff7af62e 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -829,6 +829,14 @@ static char *winFullPathname(const char *zRelative){ return zFull; } +/* +** Make a copy of an OsFile object. +*/ +static void winCopyOsFile(OsFile *pDest, OsFile *pSrc){ + *pDest = *pSrc; +} + + /* ** This is the structure that defines all of the I/O routines. */ @@ -853,6 +861,7 @@ struct sqlite3IoVtbl sqlite3Io = { winLock, winUnlock, winCheckReservedLock, + winCopyOsFile, }; #endif /* SQLITE_OMIT_DISKIO */ diff --git a/src/pager.c b/src/pager.c index 07e728d800..9398e99500 100644 --- a/src/pager.c +++ b/src/pager.c @@ -18,7 +18,7 @@ ** file simultaneously, or one process from reading the database while ** another is writing. ** -** @(#) $Id: pager.c,v 1.218 2005/11/26 00:25:03 drh Exp $ +** @(#) $Id: pager.c,v 1.219 2005/11/26 03:43:23 drh Exp $ */ #ifndef SQLITE_OMIT_DISKIO #include "sqliteInt.h" @@ -1659,7 +1659,7 @@ int sqlite3pager_open( strcpy(pPager->zJournal, zFullPathname); sqliteFree(zFullPathname); strcpy(&pPager->zJournal[nameLen], "-journal"); - pPager->fd = fd; + sqlite3Io.xCopyOsFile(&pPager->fd,&fd); pPager->journalOpen = 0; pPager->useJournal = useJournal && !memDb; pPager->noReadlock = noReadlock && readOnly; diff --git a/src/test6.c b/src/test6.c index f0c5a06e0d..414480ba0a 100644 --- a/src/test6.c +++ b/src/test6.c @@ -428,6 +428,14 @@ static int crashOpenReadOnly(const char *zFilename, OsFile *id){ return origIo.xOpenReadOnly(zFilename, id); } +/* +** Make a copy of an OsFile object +*/ +static void crashCopyOsFile(OsFile *pDest, OsFile *pSrc){ + *pDest = *pSrc; + ((OsTestFile*)(pDest->pAux))->pBase = pDest; +} + /* ** tclcmd: sqlite_crashparams DELAY CRASHFILE ** @@ -464,6 +472,7 @@ static int crashParamsObjCmd( sqlite3Io.xOpenReadWrite = crashOpenReadWrite; sqlite3Io.xOpenExclusive = crashOpenExclusive; sqlite3Io.xOpenReadOnly = crashOpenReadOnly; + sqlite3Io.xCopyOsFile = crashCopyOsFile; return TCL_OK; }