mirror of
https://github.com/sqlite/sqlite.git
synced 2024-11-21 11:19:14 +01:00
Update the showlocks utility program so that it functions on files with
a huge number of locks without overflowing the stack. FossilOrigin-Name: adb7484f93329c7a94cd84e30bc4a8dbf2d6e901eba17cc3454afb8ba346cbf4
This commit is contained in:
parent
8cda77d44a
commit
0f40e8dd41
11
manifest
11
manifest
@ -1,6 +1,6 @@
|
||||
B 7a876209a678a34c198b54ceef9e3c041f128a14dc73357f6a57cadadaa6cf7b
|
||||
C Add\sthe\sieee754_mantissa()\sand\sieee754_exponent()\sfunctions\sto\sthe\siee754\nextension.\s\sBuild\sthe\sieee754\sextension\sinto\sthe\sCLI.
|
||||
D 2020-06-24T15:06:29.041
|
||||
C Update\sthe\sshowlocks\sutility\sprogram\sso\sthat\sit\sfunctions\son\sfiles\swith\na\shuge\snumber\sof\slocks\swithout\soverflowing\sthe\sstack.
|
||||
D 2020-06-25T23:21:09.249
|
||||
F Makefile.in 19374a5db06c3199ec1bab71ab74a103d8abf21053c05e9389255dc58083f806
|
||||
F Makefile.msc 48f5a3fc32672c09ad73795749f6253e406a31526935fbbffd8f021108d54574
|
||||
F autoconf/Makefile.am a8d1d24affe52ebf8d7ddcf91aa973fa0316618ab95bb68c87cabf8faf527dc8
|
||||
@ -16,7 +16,8 @@ F test/speedtest1.c ea201573f9b27542ea1e74a68e74f121e0eb04c89e67039f40ed68f1b833
|
||||
F tool/mkautoconfamal.sh f62353eb6c06ab264da027fd4507d09914433dbdcab9cb011cdc18016f1ab3b8
|
||||
F tool/mksqlite3c.tcl f4ef476510eca4124c874a72029f1e01bc54a896b1724e8f9eef0d8bfae0e84c
|
||||
F tool/mksqlite3h.tcl 1f5e4a1dbbbc43c83cc6e74fe32c6c620502240b66c7c0f33a51378e78fc4edf
|
||||
P 838817b680f02b3845d6d56f85d5d36fa5ae7453afef7a1a5a24624255f2dc3e
|
||||
R 6e286f8b0cf2dcbbb10b38a65d995df9
|
||||
F tool/showlocks.c 9cc5e66d4ebbf2d194f39db2527ece92077e86ae627ddd233ee48e16e8142564
|
||||
P db2f0836b64cd2e119684f1cf75fa3b19a84ca6aca1a239f7e2b9298016e2c95
|
||||
R 0276be5c8a111d3ffc976288f1457408
|
||||
U drh
|
||||
Z 549c83ceeab0b10ef9bb12772423a56c
|
||||
Z 08b6b193e7afff7dc4e3f0aacc9e50d2
|
||||
|
@ -1 +1 @@
|
||||
db2f0836b64cd2e119684f1cf75fa3b19a84ca6aca1a239f7e2b9298016e2c95
|
||||
adb7484f93329c7a94cd84e30bc4a8dbf2d6e901eba17cc3454afb8ba346cbf4
|
@ -24,23 +24,58 @@
|
||||
static int showLocksInRange(int fd, off_t lwr, off_t upr){
|
||||
int cnt = 0;
|
||||
struct flock x;
|
||||
struct lockRange {
|
||||
off_t lwr;
|
||||
off_t upr;
|
||||
} *aPending = 0;
|
||||
int nAlloc = 1;
|
||||
int nPending = 0;
|
||||
int nDone = 0;
|
||||
|
||||
x.l_type = F_WRLCK;
|
||||
x.l_whence = SEEK_SET;
|
||||
x.l_start = lwr;
|
||||
x.l_len = upr-lwr;
|
||||
fcntl(fd, F_GETLK, &x);
|
||||
if( x.l_type==F_UNLCK ) return 0;
|
||||
printf("start: %-12d len: %-5d pid: %-5d type: %s\n",
|
||||
(int)x.l_start, (int)x.l_len,
|
||||
x.l_pid, x.l_type==F_WRLCK ? "WRLCK" : "RDLCK");
|
||||
cnt++;
|
||||
if( x.l_start>lwr ){
|
||||
cnt += showLocksInRange(fd, lwr, x.l_start-1);
|
||||
nPending = 1;
|
||||
aPending = malloc( sizeof(aPending[0]) );
|
||||
if( aPending==0 ){
|
||||
fprintf(stderr, "out of memory\n");
|
||||
exit(1);
|
||||
}
|
||||
if( x.l_start+x.l_len<upr ){
|
||||
cnt += showLocksInRange(fd, x.l_start+x.l_len+1, upr);
|
||||
aPending[0].lwr = lwr;
|
||||
aPending[0].upr = upr;
|
||||
|
||||
for(nDone=0; nDone<nPending; nDone++){
|
||||
lwr = aPending[nDone].lwr;
|
||||
upr = aPending[nDone].upr;
|
||||
if( lwr>=upr ) continue;
|
||||
x.l_type = F_WRLCK;
|
||||
x.l_whence = SEEK_SET;
|
||||
x.l_start = lwr;
|
||||
x.l_len = upr - lwr;
|
||||
fcntl(fd, F_GETLK, &x);
|
||||
if( x.l_type==F_UNLCK ) continue;
|
||||
printf("start: %-12d len: %-5d pid: %-5d type: %s\n",
|
||||
(int)x.l_start, (int)x.l_len,
|
||||
x.l_pid, x.l_type==F_WRLCK ? "WRLCK" : "RDLCK");
|
||||
cnt++;
|
||||
if( nPending+2 > nAlloc ){
|
||||
nAlloc = nAlloc*2 + 2;
|
||||
aPending = realloc(aPending, sizeof(aPending[0])*nAlloc );
|
||||
}
|
||||
if( aPending==0 ){
|
||||
fprintf(stderr, "unable to realloc for %d bytes\n",
|
||||
(int)sizeof(aPending[0])*(nPending+2));
|
||||
exit(1);
|
||||
}
|
||||
if( lwr<x.l_start ){
|
||||
aPending[nPending].lwr = lwr;
|
||||
aPending[nPending].upr = x.l_start;
|
||||
nPending++;
|
||||
}
|
||||
if( x.l_start+x.l_len<=upr ){
|
||||
aPending[nPending].lwr = x.l_start + x.l_len;
|
||||
aPending[nPending].upr = upr;
|
||||
nPending++;
|
||||
}
|
||||
}
|
||||
free(aPending);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user