On Mon, Oct 31, 2011 at 5:44 PM, Richard Hipp <d...@sqlite.org> wrote: > On Mon, Oct 31, 2011 at 5:40 PM, Pavel Ivanov <paiva...@gmail.com> wrote: > >> > Error code 522 is SQLITE_IOERR_SHORT_READ. It is generated here: >> > >> > http://www.sqlite.org/src/artifact/07acbb3e074e?ln=3012 >> > >> > SQLite was trying to read N bytes and got back M byes where M>0 and M<N. >> >> Could it be that N bytes cannot be read atomically and operation was >> interrupted in the middle by some signal? This scenario can explain >> short read even if database is not truncated or corrupted. > > If an interrupt occurs that stops the read before it can complete, then the > read should be tried again. > http://www.sqlite.org/src/artifact/07acbb3e074e?ln=2968
http://linux.die.net/man/2/read "On success, the number of bytes read is returned (zero indicates end of file), and the file position is advanced by this number. It is not an error if this number is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal), or because read() was interrupted by a signal." So the condition "got <0 && errno == EINTR" will be true only when signal came before any data were read. If signal comes when some data already have been read then got will be greater than 0 and errno will be 0, although got will be less than requested. Pavel _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users