From: drh Date: Fri, 4 Mar 2011 15:43:57 +0000 (+0000) Subject: Handle EINTR errors from open(). X-Git-Tag: version-3.7.6~112^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fsyscall-override;p=thirdparty%2Fsqlite.git Handle EINTR errors from open(). FossilOrigin-Name: a7d176b27cd73791d45eb3a31df78187ae10ce20 --- diff --git a/manifest b/manifest index 615bc1ff8d..a064a0b5e5 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sadditional\sVFS\smethods\sto\sretrieve\ssystem\scall\spointers\sand\sto\sget\sa\nlist\sof\sall\schangeable\ssystem\scalls. -D 2011-03-02T19:06:42.724 +C Handle\sEINTR\serrors\sfrom\sopen(). +D 2011-03-04T15:43:57.699 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 27701a1653595a1f2187dc61c8117e00a6c1d50f F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -165,7 +165,7 @@ F src/os.c 22ac61d06e72a0dac900400147333b07b13d8e1d F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9 F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f F src/os_os2.c 2e452c9f2ca507623ad351c33a8a8b27849b1863 -F src/os_unix.c 3d38767952d504486d182dea7b77279688011896 +F src/os_unix.c cb94e52f705b8e0ae2b2ddd387f71d6c4e08cd71 F src/os_win.c 24d72407a90551969744cf9bcbb1b4c72c5fa845 F src/pager.c 6aa906b60a59664ba58d3f746164bb010d407ce1 F src/pager.h 3f8c783de1d4706b40b1ac15b64f5f896bcc78d1 @@ -913,14 +913,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 80fac2a6e07221bb67613af84ab9dda3e18b5ceb -R 469544ed72ad6cc0fd2ce66bb41ae458 +P 38558363494e3a736dcb091dd859e76b7ccd78b0 +R dd2dabc15bf7d4925fef6d097c8b1859 U drh -Z 4fd425550526c290567641a06db348a6 +Z 534640ef6b55077422a57e880c660f80 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFNbpVGoxKgR168RlERAiVlAJ9CbY/F1l/3wLXTOWVbVMt3PK4e2wCfXCEX -gkP0SmX/m93Upo7bU9m9XaA= -=DBkJ +iD8DBQFNcQjAoxKgR168RlERAg0SAJ9rCSURrs0OHohp+icweWOPgtvSxQCdHnS5 +3mAQcVk63NipJkS+azKbo50= +=vPdf -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 0f06d09f05..49190d1535 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -38558363494e3a736dcb091dd859e76b7ccd78b0 \ No newline at end of file +a7d176b27cd73791d45eb3a31df78187ae10ce20 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index c5261bb111..79038a5846 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -450,6 +450,14 @@ static const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){ return 0; } +/* +** Retry open() calls that fail due to EINTR +*/ +static int robust_open(const char *z, int f, int m){ + int rc; + do{ rc = osOpen(z,f,m); }while( rc<0 && errno==EINTR ); + return rc; +} /* ** Helper functions to obtain and relinquish the global mutex. The @@ -556,20 +564,14 @@ static int lockTrace(int fd, int op, struct flock *p){ #define osFcntl lockTrace #endif /* SQLITE_LOCK_TRACE */ - /* ** Retry ftruncate() calls that fail due to EINTR */ -#ifdef EINTR static int robust_ftruncate(int h, sqlite3_int64 sz){ int rc; do{ rc = osFtruncate(h,sz); }while( rc<0 && errno==EINTR ); return rc; } -#else -# define robust_ftruncate(a,b) osFtruncate(a,b) -#endif - /* ** This routine translates a standard POSIX errno code into something @@ -1861,7 +1863,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) { } /* grab an exclusive lock */ - fd = osOpen(zLockFile,O_RDONLY|O_CREAT|O_EXCL,0600); + fd = robust_open(zLockFile,O_RDONLY|O_CREAT|O_EXCL,0600); if( fd<0 ){ /* failed to open/create the file, someone else may have stolen the lock */ int tErrno = errno; @@ -3686,7 +3688,8 @@ static int unixOpenSharedMemory(unixFile *pDbFd){ goto shm_open_err; } - pShmNode->h = osOpen(zShmFilename, O_RDWR|O_CREAT, (sStat.st_mode & 0777)); + pShmNode->h = robust_open(zShmFilename, O_RDWR|O_CREAT, + (sStat.st_mode & 0777)); if( pShmNode->h<0 ){ rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zShmFilename); goto shm_open_err; @@ -4514,7 +4517,7 @@ static int openDirectory(const char *zFilename, int *pFd){ for(ii=(int)strlen(zDirname); ii>1 && zDirname[ii]!='/'; ii--); if( ii>0 ){ zDirname[ii] = '\0'; - fd = osOpen(zDirname, O_RDONLY|O_BINARY, 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); @@ -4853,7 +4856,7 @@ static int unixOpen( assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL ); return rc; } - fd = osOpen(zName, openFlags, openMode); + fd = robust_open(zName, openFlags, openMode); OSTRACE(("OPENX %-3d %s 0%o\n", fd, zName, openFlags)); if( fd<0 && errno!=EISDIR && isReadWrite && !isExclusive ){ /* Failed to open the file for read/write access. Try read-only. */ @@ -4861,7 +4864,7 @@ static int unixOpen( openFlags &= ~(O_RDWR|O_CREAT); flags |= SQLITE_OPEN_READONLY; openFlags |= O_RDONLY; - fd = osOpen(zName, openFlags, openMode); + fd = robust_open(zName, openFlags, openMode); } if( fd<0 ){ rc = unixLogError(SQLITE_CANTOPEN_BKPT, "open", zName); @@ -5188,7 +5191,7 @@ static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){ #if !defined(SQLITE_TEST) { int pid, fd; - fd = osOpen("/dev/urandom", O_RDONLY, 0); + fd = robust_open("/dev/urandom", O_RDONLY, 0); if( fd<0 ){ time_t t; time(&t); @@ -5597,17 +5600,17 @@ static int proxyCreateUnixFile( } } if( fd<0 ){ - fd = osOpen(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); + fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); terrno = errno; if( fd<0 && errno==ENOENT && islockfile ){ if( proxyCreateLockPath(path) == SQLITE_OK ){ - fd = osOpen(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); + fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); } } } if( fd<0 ){ openFlags = O_RDONLY; - fd = osOpen(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); + fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); terrno = errno; } if( fd<0 ){ @@ -5727,7 +5730,8 @@ static int proxyBreakConchLock(unixFile *pFile, uuid_t myHostID){ goto end_breaklock; } /* write it out to the temporary break file */ - fd = osOpen(tPath, (O_RDWR|O_CREAT|O_EXCL), SQLITE_DEFAULT_FILE_PERMISSIONS); + fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), + SQLITE_DEFAULT_FILE_PERMISSIONS); if( fd<0 ){ sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); goto end_breaklock; @@ -6002,7 +6006,7 @@ static int proxyTakeConch(unixFile *pFile){ robust_close(pFile, pFile->h, __LINE__); } pFile->h = -1; - int fd = osOpen(pCtx->dbPath, pFile->openFlags, + int fd = robust_open(pCtx->dbPath, pFile->openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); OSTRACE(("TRANSPROXY: OPEN %d\n", fd)); if( fd>=0 ){