1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-15 11:41:13 +03:00

Improvements to the xRandomness() method on the default windows VFS.

Ticket #2615. (CVS 4374)

FossilOrigin-Name: 91b50f31e35652a40d51f5d9bf22efce36d515e4
This commit is contained in:
drh
2007-09-03 13:06:11 +00:00
parent ee6c9722cc
commit d1a793126a
3 changed files with 30 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
C Document\sthe\sfact\sthat\sxRandomness\sis\sonly\scalled\sonce\sfrom\sthe\sdefault\sVFS.\nTicket\s#2614.\s(CVS\s4373) C Improvements\sto\sthe\sxRandomness()\smethod\son\sthe\sdefault\swindows\sVFS.\nTicket\s#2615.\s(CVS\s4374)
D 2007-09-03T12:34:57 D 2007-09-03T13:06:12
F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3 F Makefile.in bfcc303429a5d9dcd552d807ee016c77427418c3
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -118,7 +118,7 @@ F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 3b1b9c6d1b09b9cddd19287e6f842d712bf07602 F src/os_unix.c 3b1b9c6d1b09b9cddd19287e6f842d712bf07602
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c ce778c06afcbfd120ede237befece4655e83c8d0 F src/os_win.c 57f9b96e78b98e135c41b985613a448d704f23f0
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c ac52bb1e22f7ce203e1eec8fa666be2cdd695ee9 F src/pager.c ac52bb1e22f7ce203e1eec8fa666be2cdd695ee9
F src/pager.h f204c1a9fe0574953fba89c56d9d9bd1ddfa604a F src/pager.h f204c1a9fe0574953fba89c56d9d9bd1ddfa604a
@@ -568,7 +568,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P e3dd3651421ee723f9b7550fc333a308a83b276d P e89d4131a1b55da1a7f226d7f7b416f02f5e2c6e
R e5bbccd4e7ccaddc79e4352e0f90298b R 70eed1b737d2685751d3043c11b74d10
U drh U drh
Z 5e24864e26a2ac7181c9f9ec2eeb72f5 Z 3dfc552072668685c58ab6fae3991bd7

View File

@@ -1 +1 @@
e89d4131a1b55da1a7f226d7f7b416f02f5e2c6e 91b50f31e35652a40d51f5d9bf22efce36d515e4

View File

@@ -1421,12 +1421,30 @@ void winDlClose(sqlite3_vfs *pVfs, void *pHandle){
** Write up to nBuf bytes of randomness into zBuf. ** Write up to nBuf bytes of randomness into zBuf.
*/ */
static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
if( sizeof(LPSYSTEMTIME)>=nBuf ){ int n = 0;
GetSystemTime((LPSYSTEMTIME)zBuf); if( sizeof(LPSYSTEMTIME)<=nBuf-n ){
return sizeof(LPSYSTEMTIME); SYSTEMTIME x;
}else{ GetSystemTime(&x);
return 0; memcpy(&zBuf[n], &x, sizeof(x));
n += sizeof(x);
} }
if( sizeof(DWORD)<=nBuf-n ){
DWORD pid = GetCurrentProcessId();
memcpy(&zBuf[n], &pid, sizeof(pid));
n += sizeof(pid);
}
if( sizeof(DWORD)<=nBuf-n ){
DWORD cnt = GetTickCount();
memcpy(&zBuf[n], &cnt, sizeof(cnt));
n += sizeof(cnt);
}
if( sizeof(LARGE_INTEGER)<=nBuf-n ){
LARGE_INTEGER i;
QueryPerformanceCounter(&i);
memcpy(&zBuf[n], &i, sizeof(i));
n += sizeof(i);
}
return n;
} }