mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
retry after interrupts
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34111 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4152d0fe77
commit
d0807c3dec
2 changed files with 39 additions and 26 deletions
|
@ -4,6 +4,7 @@
|
|||
buffer must be aligned so that any datatype can go in it.
|
||||
* Source/cifframe.m: Fix buffer size for small scalar values on
|
||||
64bit sparc
|
||||
* Source/GSFileHandle.m: Modify read/write to cope with interrupts.
|
||||
|
||||
2011-11-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -107,22 +107,28 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey";
|
|||
*/
|
||||
- (NSInteger) read: (void*)buf length: (NSUInteger)len
|
||||
{
|
||||
int result;
|
||||
|
||||
do
|
||||
{
|
||||
#if USE_ZLIB
|
||||
if (gzDescriptor != 0)
|
||||
{
|
||||
len = gzread(gzDescriptor, buf, len);
|
||||
}
|
||||
else
|
||||
if (gzDescriptor != 0)
|
||||
{
|
||||
result = gzread(gzDescriptor, buf, len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (isSocket)
|
||||
{
|
||||
len = recv(descriptor, buf, len, 0);
|
||||
if (isSocket)
|
||||
{
|
||||
result = recv(descriptor, buf, len, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = read(descriptor, buf, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = read(descriptor, buf, len);
|
||||
}
|
||||
return len;
|
||||
while (result < 0 && EINTR == errno);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,22 +137,28 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey";
|
|||
*/
|
||||
- (NSInteger) write: (const void*)buf length: (NSUInteger)len
|
||||
{
|
||||
int result;
|
||||
|
||||
do
|
||||
{
|
||||
#if USE_ZLIB
|
||||
if (gzDescriptor != 0)
|
||||
{
|
||||
len = gzwrite(gzDescriptor, (char*)buf, len);
|
||||
}
|
||||
else
|
||||
if (gzDescriptor != 0)
|
||||
{
|
||||
result = gzwrite(gzDescriptor, (char*)buf, len);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (isSocket)
|
||||
{
|
||||
len = send(descriptor, buf, len, 0);
|
||||
if (isSocket)
|
||||
{
|
||||
result = send(descriptor, buf, len, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = write(descriptor, buf, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
len = write(descriptor, buf, len);
|
||||
}
|
||||
return len;
|
||||
while (result < 0 && EINTR == errno);
|
||||
return result;
|
||||
}
|
||||
|
||||
+ (id) allocWithZone: (NSZone*)z
|
||||
|
|
Loading…
Reference in a new issue