Fix for "Remote host closed connection" exception

EINTR errors are recoverable, just need to read() again.
Randomly while looking at files in the file browser the contents view will be empty or files will not be shown when clicking a discloser triangle. Seems to happen more when running in XCode than when running by itself.
This commit is contained in:
Nathan Kinsinger
2010-02-19 22:30:02 -07:00
committed by Dave Grijalva
parent f60f8ad7ad
commit 2e549a18f8
+8 -2
View File
@@ -33,8 +33,14 @@
while (n > 0) {
n = read(fd, buffer + bytesReceived++, 1);
if (n < 0)
[[NSException exceptionWithName:@"Socket error" reason:@"Remote host closed connection" userInfo:nil] raise];
if (n < 0) {
if (errno == EINTR) {
n = 1;
bytesReceived--;
} else {
[[NSException exceptionWithName:@"Socket error" reason:@"Remote host closed connection" userInfo:nil] raise];
}
}
if (bytesReceived >= bufferSize) {
// Make buffer bigger