From e08122141042a70db68d41893fb03b2162299b82 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/support/ios.c b/src/support/ios.c index f05c6128d2f6a..3cd047dde8c7a 100644 --- a/src/support/ios.c +++ b/src/support/ios.c @@ -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;