Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use the F_FULLFSYNC fctrl if it is available. Record the name of files that are opened in the OsFile structure. (CVS 1799) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1d30d0dd46c2bd12ce3f7dc06492f3e2 |
User & Date: | drh 2004-07-17 21:44:57.000 |
Context
2004-07-17
| ||
21:56 | mprintf() correctly handles "%s","". Fix for ticket #812. (CVS 1800) (check-in: 4f56db1149 user: drh tags: trunk) | |
21:44 | Use the F_FULLFSYNC fctrl if it is available. Record the name of files that are opened in the OsFile structure. (CVS 1799) (check-in: 1d30d0dd46 user: drh tags: trunk) | |
2004-07-15
| ||
20:08 | Added tests for sqlite3_changes after a DELETE. (CVS 1798) (check-in: c01f13267f user: drh tags: trunk) | |
Changes
Changes to src/os_unix.c.
︙ | ︙ | |||
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | */ int sqlite3OsSeek(OsFile *id, off_t offset){ assert( id->isOpen ); SEEK(offset/1024 + 1); lseek(id->h, offset, SEEK_SET); return SQLITE_OK; } /* ** Make sure all writes to a particular file are committed to disk. ** ** Under Unix, also make sure that the directory entry for the file ** has been created by fsync-ing the directory that contains the file. ** If we do not do this and we encounter a power failure, the directory ** entry for the journal might not exist after we reboot. The next ** SQLite to access the file will not know that the journal exists (because ** the directory entry for the journal was never created) and the transaction ** will not roll back - possibly leading to database corruption. */ int sqlite3OsSync(OsFile *id){ assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE2("SYNC %-3d\n", id->h); | > > > > > > > > > > > > > > > > | | | 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 | */ int sqlite3OsSeek(OsFile *id, off_t offset){ assert( id->isOpen ); SEEK(offset/1024 + 1); lseek(id->h, offset, SEEK_SET); return SQLITE_OK; } /* ** The fsync() system call does not work as advertised on many ** unix systems. The following procedure is an attempt to make ** it work better. */ static int full_fsync(int fd){ int rc; #ifdef F_FULLFSYNC rc = fcntl(fd, F_FULLFSYNC, 0); if( rc ) rc = fsync(fd); #else rc = fsync(fd); #endif return rc; } /* ** Make sure all writes to a particular file are committed to disk. ** ** Under Unix, also make sure that the directory entry for the file ** has been created by fsync-ing the directory that contains the file. ** If we do not do this and we encounter a power failure, the directory ** entry for the journal might not exist after we reboot. The next ** SQLite to access the file will not know that the journal exists (because ** the directory entry for the journal was never created) and the transaction ** will not roll back - possibly leading to database corruption. */ int sqlite3OsSync(OsFile *id){ assert( id->isOpen ); SimulateIOError(SQLITE_IOERR); TRACE2("SYNC %-3d\n", id->h); if( full_fsync(id->h) ){ return SQLITE_IOERR; } if( id->dirfd>=0 ){ TRACE2("DIRSYNC %-3d\n", id->dirfd); full_fsync(id->dirfd); close(id->dirfd); /* Only need to sync once, so close the directory */ id->dirfd = -1; /* when we are done. */ } return SQLITE_OK; } /* |
︙ | ︙ | |||
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | } /* ** Close a file. */ int sqlite3OsClose(OsFile *id){ if( !id->isOpen ) return SQLITE_OK; sqlite3OsUnlock(id, NO_LOCK); if( id->dirfd>=0 ) close(id->dirfd); id->dirfd = -1; sqlite3OsEnterMutex(); if( id->pOpen->nLock ){ /* If there are outstanding locks, do not actually close the file just ** yet because that would clear those locks. Instead, add the file | > | 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 | } /* ** Close a file. */ int sqlite3OsClose(OsFile *id){ if( !id->isOpen ) return SQLITE_OK; id->zFilename = 0; sqlite3OsUnlock(id, NO_LOCK); if( id->dirfd>=0 ) close(id->dirfd); id->dirfd = -1; sqlite3OsEnterMutex(); if( id->pOpen->nLock ){ /* If there are outstanding locks, do not actually close the file just ** yet because that would clear those locks. Instead, add the file |
︙ | ︙ |
Changes to src/os_unix.h.
︙ | ︙ | |||
61 62 63 64 65 66 67 68 69 70 71 72 73 74 | ** PENDING_LOCK or EXCLUSIVE_LOCK. */ typedef struct OsFile OsFile; struct OsFile { struct openCnt *pOpen; /* Info about all open fd's on this inode */ struct lockInfo *pLock; /* Info about locks on this inode */ int h; /* The file descriptor */ unsigned char locktype; /* The type of lock held on this fd */ unsigned char isOpen; /* True if needs to be closed */ int dirfd; /* File descriptor for the directory */ }; /* ** Maximum number of characters in a temporary file name | > | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | ** PENDING_LOCK or EXCLUSIVE_LOCK. */ typedef struct OsFile OsFile; struct OsFile { struct openCnt *pOpen; /* Info about all open fd's on this inode */ struct lockInfo *pLock; /* Info about locks on this inode */ int h; /* The file descriptor */ const char *zFilename; /* Name passed to open() */ unsigned char locktype; /* The type of lock held on this fd */ unsigned char isOpen; /* True if needs to be closed */ int dirfd; /* File descriptor for the directory */ }; /* ** Maximum number of characters in a temporary file name |
︙ | ︙ |