Skip to content

Commit

Permalink
Merge pull request #18332 from twadleigh/fix-lisp-on-windows
Browse files Browse the repository at this point in the history
Repeatedly divide read buffer size by 8 until success. Fixes #11481.
  • Loading branch information
vtjnash committed Sep 5, 2016
2 parents c7ae73c + 0440507 commit 79a7172
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/support/ios.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,20 @@ static int _os_read(long fd, void *buf, size_t n, size_t *nread)
{
ssize_t r;

n = 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, n);
set_io_wait_begin(0);
if (r > -1) {
*nread = (size_t)r;
return 0;
}
// This test is a hack to fix #11481 for Windows 7. Unnecessary for Windows 10.
if (errno == ENOMEM && n > 80) {
n >>= 3;
continue;
}
if (!_enonfatal(errno)) {
*nread = 0;
return errno;
Expand Down

0 comments on commit 79a7172

Please sign in to comment.