Skip to content

Commit

Permalink
Repeatedly divide read buffer size by 8 until success. Fixes #11481.
Browse files Browse the repository at this point in the history
Dividing by 8 leads to success on the second try in the case of the failure of --lisp on Windows 7.
  • Loading branch information
twadleigh committed Sep 2, 2016
1 parent cd94c99 commit e081221
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/support/ios.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ static int _os_read(long fd, void *buf, size_t n, size_t *nread)
{
ssize_t r;

unsigned int sz = LIMIT_IO_SIZE(n);
while (1) {
set_io_wait_begin(1);
r = read((int)fd, buf, LIMIT_IO_SIZE(n));
r = read((int)fd, buf, sz);
set_io_wait_begin(0);
if (r > -1) {
*nread = (size_t)r;
return 0;
}
if (errno == ENOMEM && sz > 80) {
sz >>= 3;
continue;
}
if (!_enonfatal(errno)) {
*nread = 0;
return errno;
Expand Down

0 comments on commit e081221

Please sign in to comment.