diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2013-04-07 14:52:16 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2013-04-07 14:52:16 -0700 |
commit | 42497d99325d5f27a90cc82e4e445c1252f87e7c (patch) | |
tree | 1472e8d0e75f860db1a2dccfd05ff47249f15c86 /reader.cpp | |
parent | 3f172d13b28030fb3c91782a662641791186593b (diff) |
Fix for issue where a file may be incompletely read on receipt of a signal.
Diffstat (limited to 'reader.cpp')
-rw-r--r-- | reader.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -3627,22 +3627,23 @@ static int read_ni(int fd, const io_chain_t &io) { if (errno == EINTR) { - /* We got a signal, just keep going */ - continue; + /* We got a signal, just keep going. Be sure that we call insert() below because we may get data as well as EINTR. */ + clearerr(in_stream); } else if ((errno == EAGAIN || errno == EWOULDBLOCK) && make_fd_blocking(des) == 0) { - /* We succeeded in making the fd blocking, try again */ - continue; + /* We succeeded in making the fd blocking, keep going */ + clearerr(in_stream); } - - /* Fatal error */ - debug(1, _(L"Error while reading from file descriptor")); - - /* Reset buffer on error. We won't evaluate incomplete files. */ - acc.clear(); - break; + else + { + /* Fatal error */ + debug(1, _(L"Error while reading from file descriptor")); + /* Reset buffer on error. We won't evaluate incomplete files. */ + acc.clear(); + break; + } } acc.insert(acc.end(), buff, buff + c); |