diff options
author | mistachkin <mistachkin@noemail.net> | 2012-04-18 05:57:38 +0000 |
---|---|---|
committer | mistachkin <mistachkin@noemail.net> | 2012-04-18 05:57:38 +0000 |
commit | a749486e31f49b468fb48c9b42ac9d44530bae1a (patch) | |
tree | d8a33079142317e5fe70a9ed52bf604477af6e3a /src/os_unix.c | |
parent | a6ff857437e621761348a2148418ca1b41308ecd (diff) | |
parent | 374fdce485ab55739dfd307ac00a59ebe8ce8d25 (diff) | |
download | sqlite-a749486e31f49b468fb48c9b42ac9d44530bae1a.tar.gz sqlite-a749486e31f49b468fb48c9b42ac9d44530bae1a.zip |
Import all the latest trunk changes into the WinRT branch. Refactor and/or remove WinCE-specific macros and functions used for file locking to improve clarity of presentation.
FossilOrigin-Name: ad5cd15f49b286896f94ab1ff207077beee40e12
Diffstat (limited to 'src/os_unix.c')
-rw-r--r-- | src/os_unix.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 48c130935..c85e9b53a 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -165,8 +165,8 @@ #endif /* - ** Default permissions when creating auto proxy dir - */ +** Default permissions when creating auto proxy dir +*/ #ifndef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS # define SQLITE_DEFAULT_PROXYDIR_PERMISSIONS 0755 #endif @@ -512,7 +512,7 @@ static const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){ /* ** Invoke open(). Do so multiple times, until it either succeeds or -** files for some reason other than EINTR. +** fails for some reason other than EINTR. ** ** If the file creation mode "m" is 0 then set it to the default for ** SQLite. The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally @@ -528,7 +528,7 @@ static const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){ ** recover the hot journals. */ static int robust_open(const char *z, int f, mode_t m){ - int rc; + int fd; mode_t m2; mode_t origM = 0; if( m==0 ){ @@ -537,11 +537,20 @@ static int robust_open(const char *z, int f, mode_t m){ m2 = m; origM = osUmask(0); } - do{ rc = osOpen(z,f,m2); }while( rc<0 && errno==EINTR ); + do{ +#if defined(O_CLOEXEC) + fd = osOpen(z,f|O_CLOEXEC,m2); +#else + fd = osOpen(z,f,m2); +#endif + }while( fd<0 && errno==EINTR ); if( m ){ osUmask(origM); } - return rc; +#if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0) + if( fd>=0 ) osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); +#endif + return fd; } /* @@ -3336,9 +3345,6 @@ static int openDirectory(const char *zFilename, int *pFd){ zDirname[ii] = '\0'; fd = robust_open(zDirname, O_RDONLY|O_BINARY, 0); if( fd>=0 ){ -#ifdef FD_CLOEXEC - osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); -#endif OSTRACE(("OPENDIR %-3d %s\n", fd, zDirname)); } } @@ -3421,7 +3427,7 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){ ** actual file size after the operation may be larger than the requested ** size). */ - if( pFile->szChunk ){ + if( pFile->szChunk>0 ){ nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk; } @@ -5183,10 +5189,6 @@ static int unixOpen( } #endif -#ifdef FD_CLOEXEC - osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); -#endif - noLock = eType!=SQLITE_OPEN_MAIN_DB; |