Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update the showlocks utility program so that it functions on files with a huge number of locks without overflowing the stack. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
adb7484f93329c7a94cd84e30bc4a8db |
User & Date: | drh 2020-06-25 23:21:09.249 |
Context
2020-06-26
| ||
04:34 | Fix a possible null pointer deref following OOM. Discovered by dbsqlfuzz. (check-in: cc888878ea user: drh tags: trunk) | |
2020-06-25
| ||
23:21 | Update the showlocks utility program so that it functions on files with a huge number of locks without overflowing the stack. (check-in: adb7484f93 user: drh tags: trunk) | |
2020-06-24
| ||
15:06 | Add the ieee754_mantissa() and ieee754_exponent() functions to the iee754 extension. Build the ieee754 extension into the CLI. (check-in: db2f0836b6 user: drh tags: trunk) | |
Changes
Changes to tool/showlocks.c.
︙ | ︙ | |||
20 21 22 23 24 25 26 27 | /* ** Print all locks on the inode of "fd" that occur in between ** lwr and upr, inclusive. */ static int showLocksInRange(int fd, off_t lwr, off_t upr){ int cnt = 0; struct flock x; | > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | > > > > > > > > > | > | > | | | > > | > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /* ** Print all locks on the inode of "fd" that occur in between ** lwr and upr, inclusive. */ 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; nPending = 1; aPending = malloc( sizeof(aPending[0]) ); if( aPending==0 ){ fprintf(stderr, "out of memory\n"); exit(1); } 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; } int main(int argc, char **argv){ int fd; int cnt; |
︙ | ︙ |