From: drh Date: Thu, 15 Dec 2011 17:42:35 +0000 (+0000) Subject: Use _commit() rather than FlushFileBuffers() as a substitute for fsync() X-Git-Tag: version-3.7.10~19^2~56^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fquota-stdio;p=thirdparty%2Fsqlite.git Use _commit() rather than FlushFileBuffers() as a substitute for fsync() on windows. Also cast for C++ and add support for SQLITE_FCNTL_VFSNAME. FossilOrigin-Name: e85cfe9a17a2943ee0cf7915451ff6cc05908030 --- diff --git a/manifest b/manifest index eb499cd1b5..90096462db 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Harden\sthe\sutf8-to-mbcs\sconverter\sin\sthe\squota\smodule\sagainst\sfailures. -D 2011-12-14T00:04:52.373 +C Use\s_commit()\srather\sthan\sFlushFileBuffers()\sas\sa\ssubstitute\sfor\sfsync()\non\swindows.\s\sAlso\scast\sfor\sC++\sand\sadd\ssupport\sfor\sSQLITE_FCNTL_VFSNAME. +D 2011-12-15T17:42:35.299 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5b4a3e12a850b021547e43daf886b25133b44c07 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -220,7 +220,7 @@ F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec F src/test_osinst.c 62b0b8ef21ce754cc94e17bb42377ed8795dba32 F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 -F src/test_quota.c 2552dfd897d2d74ecc368487fa5859e9a2b254ab +F src/test_quota.c 1a5874e3ee9074426f43b37e8d7404948065b585 F src/test_quota.h 9ffa1d3ad6d0a6a24e8670ea64b909c717ec3358 F src/test_rtree.c 6d06306e29946dc36f528a3a2cdc3add794656f1 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 @@ -979,7 +979,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 92f4188f90e3cdd71f1457a6e0eb22615e4a54f4 -R 628f1bcc3bb63f06518edb62745f94e5 +P 1cda511deb625868395a23c95346e14d0c300670 +R b97a14183d24f2ef8a473c4b8d89de75 U drh -Z 2cf614ef38a2cb741ec717409dbd005d +Z 78d66bb3da81c929977c8b164844aeef diff --git a/manifest.uuid b/manifest.uuid index 1cd189003e..39ac2ffec5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1cda511deb625868395a23c95346e14d0c300670 \ No newline at end of file +e85cfe9a17a2943ee0cf7915451ff6cc05908030 \ No newline at end of file diff --git a/src/test_quota.c b/src/test_quota.c index e2c0808969..4529bd3028 100644 --- a/src/test_quota.c +++ b/src/test_quota.c @@ -409,6 +409,7 @@ static quotaFile *quotaFindFile( #endif #if SQLITE_OS_WIN # include +# include #endif /* @@ -428,12 +429,12 @@ static char *quota_utf8_to_mbcs(const char *zUtf8){ n = strlen(zUtf8); nWide = MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, NULL, 0); if( nWide==0 ) return 0; - zTmpWide = sqlite3_malloc( (nWide+1)*sizeof(zTmpWide[0]) ); + zTmpWide = (LPWSTR)sqlite3_malloc( (nWide+1)*sizeof(zTmpWide[0]) ); if( zTmpWide==0 ) return 0; MultiByteToWideChar(CP_UTF8, 0, zUtf8, -1, zTmpWide, nWide); codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; nMbcs = WideCharToMultiByte(codepage, 0, zTmpWide, nWide, 0, 0, 0, 0); - zMbcs = nMbcs ? sqlite3_malloc( nMbcs+1 ) : 0; + zMbcs = nMbcs ? (char*)sqlite3_malloc( nMbcs+1 ) : 0; if( zMbcs ){ WideCharToMultiByte(codepage, 0, zTmpWide, nWide, zMbcs, nMbcs, 0, 0); } @@ -714,7 +715,13 @@ static int quotaCheckReservedLock(sqlite3_file *pConn, int *pResOut){ */ static int quotaFileControl(sqlite3_file *pConn, int op, void *pArg){ sqlite3_file *pSubOpen = quotaSubOpen(pConn); - return pSubOpen->pMethods->xFileControl(pSubOpen, op, pArg); + int rc = pSubOpen->pMethods->xFileControl(pSubOpen, op, pArg); +#if defined(SQLITE_FCNTL_VFSNAME) + if( op==SQLITE_FCNTL_VFSNAME && rc==SQLITE_OK ){ + *(char**)pArg = sqlite3_mprintf("quota/%z", *(char**)pArg); + } +#endif + return rc; } /* Pass xSectorSize requests through to the original VFS unchanged. @@ -1093,10 +1100,10 @@ int sqlite3_quota_fflush(quota_FILE *p, int doFsync){ rc = fsync(fileno(p->f)); #endif #if SQLITE_OS_WIN - rc = 0==FlushFileBuffers((HANDLE)_fileno(p->f)); + rc = _commit(_fileno(p->f)); #endif } - return rc; + return rc!=0; } /*