From 8d55e394de871134b479ad26cf090f56bd74a45c Mon Sep 17 00:00:00 2001 From: Tracy Wadleigh Date: Thu, 1 Sep 2016 21:10:10 -0700 Subject: [PATCH] Repeatedly divide read buffer size by 8 until success. Fixes #11481. Dividing by 8 leads to success on the second try in the case of the failure of --lisp on Windows 7. --- src/support/ios.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/support/ios.c b/src/support/ios.c index f05c6128d2f6aa..385a24258bfebd 100644 --- a/src/support/ios.c +++ b/src/support/ios.c @@ -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;