/ Check-in [21452f3a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:When retrying a write() after an EINTR error on unix, be sure to also rerun the previous lseek(). Ticket [e59bdf6116036a]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 21452f3ae6b5882b03c7cc41e661c7b8144cc3df
User & Date: drh 2011-08-19 14:54:12
Context
2011-08-22
09:54
Fix for [b1d3a2e531]. check-in: 3f3acee4 user: dan tags: trunk
2011-08-19
18:15
Experimental change: If SQLITE_PAGECACHE_BLOCKALLOC is defined, instead of allocating pages one at a time, allocate blocks of between 15 and 63 pages in a single allocation. check-in: 63597097 user: dan tags: pager-blockalloc
14:54
When retrying a write() after an EINTR error on unix, be sure to also rerun the previous lseek(). Ticket [e59bdf6116036a] check-in: 21452f3a user: drh tags: trunk
2011-08-18
17:47
Ensure that the Tcl "db onecolumn" command returns an empty string if the SELECT statement returns zero rows. check-in: 928bcaf0 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

3035
3036
3037
3038
3039
3040
3041

3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052

3053
3054
3055
3056
3057
3058
3059
#endif
  TIMER_START;
#if defined(USE_PREAD)
  do{ got = osPwrite(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
#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;			
    }
    return -1;
  }
  do{ got = osWrite(id->h, pBuf, cnt); }while( got<0 && errno==EINTR );

#endif
  TIMER_END;
  if( got<0 ){
    ((unixFile*)id)->lastErrno = errno;
  }

  OSTRACE(("WRITE   %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED));







>
|
|
|
|
|
|
|
|
|
|
|
>







3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
#endif
  TIMER_START;
#if defined(USE_PREAD)
  do{ got = osPwrite(id->h, pBuf, cnt, offset); }while( got<0 && errno==EINTR );
#elif defined(USE_PREAD64)
  do{ got = osPwrite64(id->h, pBuf, cnt, offset);}while( got<0 && errno==EINTR);
#else
  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;
    }
    got = osWrite(id->h, pBuf, cnt);
  }while( got<0 && errno==EINTR );
#endif
  TIMER_END;
  if( got<0 ){
    ((unixFile*)id)->lastErrno = errno;
  }

  OSTRACE(("WRITE   %-3d %5d %7lld %llu\n", id->h, got, offset, TIMER_ELAPSED));

Changes to src/test_syscall.c.

321
322
323
324
325
326
327

328
329
330
331
332
333
334
...
667
668
669
670
671
672
673
674
}

/*
** A wrapper around write().
*/
static int ts_write(int fd, const void *aBuf, size_t nBuf){
  if( tsIsFailErrno("write") ){

    return -1;
  }
  return orig_write(fd, aBuf, nBuf);
}

/*
** A wrapper around pwrite().
................................................................................
  return TCL_OK;
}
#else
int SqlitetestSyscall_Init(Tcl_Interp *interp){
  return TCL_OK;
}
#endif








>







 







<
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
...
668
669
670
671
672
673
674

}

/*
** A wrapper around write().
*/
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);
}

/*
** A wrapper around pwrite().
................................................................................
  return TCL_OK;
}
#else
int SqlitetestSyscall_Init(Tcl_Interp *interp){
  return TCL_OK;
}
#endif