diff options
author | drh <drh@noemail.net> | 2011-08-19 14:54:12 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2011-08-19 14:54:12 +0000 |
commit | bd1e50c920319c78dc09c19b86c5dec42e472e29 (patch) | |
tree | 7641d74c85629b25f6997b5429bd51ab09216569 /src | |
parent | d5f12cd54d91fc857890cb846f62f3f65a1d3f36 (diff) | |
download | sqlite-bd1e50c920319c78dc09c19b86c5dec42e472e29.tar.gz sqlite-bd1e50c920319c78dc09c19b86c5dec42e472e29.zip |
When retrying a write() after an EINTR error on unix, be sure to also
rerun the previous lseek(). Ticket [e59bdf6116036a]
FossilOrigin-Name: 21452f3ae6b5882b03c7cc41e661c7b8144cc3df
Diffstat (limited to 'src')
-rw-r--r-- | src/os_unix.c | 22 | ||||
-rw-r--r-- | src/test_syscall.c | 2 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/os_unix.c b/src/os_unix.c index 857ed58a9..83bf7b142 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3039,17 +3039,19 @@ static int seekAndWrite(unixFile *id, i64 offset, const void *pBuf, int cnt){ #elif defined(USE_PREAD64) do{ got = osPwrite64(id->h, pBuf, cnt, offset);}while( got<0 && errno==EINTR); #else - newOffset = lseek(id->h, offset, SEEK_SET); - SimulateIOError( newOffset-- ); - if( newOffset!=offset ){ - if( newOffset == -1 ){ - ((unixFile*)id)->lastErrno = errno; - }else{ - ((unixFile*)id)->lastErrno = 0; + do{ + newOffset = lseek(id->h, offset, SEEK_SET); + SimulateIOError( newOffset-- ); + if( newOffset!=offset ){ + if( newOffset == -1 ){ + ((unixFile*)id)->lastErrno = errno; + }else{ + ((unixFile*)id)->lastErrno = 0; + } + return -1; } - return -1; - } - do{ got = osWrite(id->h, pBuf, cnt); }while( got<0 && errno==EINTR ); + got = osWrite(id->h, pBuf, cnt); + }while( got<0 && errno==EINTR ); #endif TIMER_END; if( got<0 ){ diff --git a/src/test_syscall.c b/src/test_syscall.c index b8b05c590..d484f22db 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -325,6 +325,7 @@ static int ts_pread64(int fd, void *aBuf, size_t nBuf, off_t off){ */ static int ts_write(int fd, const void *aBuf, size_t nBuf){ if( tsIsFailErrno("write") ){ + if( tsErrno("write")==EINTR ) orig_write(fd, aBuf, nBuf/2); return -1; } return orig_write(fd, aBuf, nBuf); @@ -671,4 +672,3 @@ int SqlitetestSyscall_Init(Tcl_Interp *interp){ return TCL_OK; } #endif - |