fix for delay in tls write

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37397 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-11-22 16:33:46 +00:00
parent d475f7e0d4
commit 22e7f7bae9
3 changed files with 58 additions and 9 deletions

View file

@ -1,3 +1,10 @@
2013-11-222 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSTLS.m:
Set errno to EAGAIN if TLS layer fails in a non-fatal way during
read/write.
Add more/better debug logging.
2013-11-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: Fix for bug 40620

View file

@ -2047,7 +2047,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
int written;
written = [self write: (char*)ptr+writePos
length: length-writePos];
length: length-writePos];
if (written <= 0)
{
if (written < 0 && errno != EAGAIN && errno != EINTR)

View file

@ -1611,14 +1611,13 @@ static NSMutableDictionary *credentialsCache = nil;
{
NSString *p;
if (GNUTLS_E_WARNING_ALERT_RECEIVED == result)
if (GNUTLS_E_AGAIN == result)
{
if (YES == debug)
{
p = [NSString stringWithFormat: @"%s",
gnutls_alert_get_name(gnutls_alert_get(session))];
NSLog(@"%@ %@", self, p);
}
errno = EAGAIN; // Need to retry.
}
else if (GNUTLS_E_INTERRUPTED == result)
{
errno = EINTR; // Need to retry
}
else if (gnutls_error_is_fatal(result))
{
@ -1629,13 +1628,56 @@ static NSMutableDictionary *credentialsCache = nil;
NSLog(@"%@ %@", self, p);
}
}
else
{
if (GNUTLS_E_WARNING_ALERT_RECEIVED == result)
{
if (YES == debug)
{
p = [NSString stringWithFormat: @"%s",
gnutls_alert_get_name(gnutls_alert_get(session))];
NSLog(@"%@ %@", self, p);
}
}
errno = EAGAIN; // Need to retry.
}
result = -1;
}
return result;
}
- (NSInteger) write: (const void*)buf length: (NSUInteger)len
{
return gnutls_record_send(session, buf, len);
int result = gnutls_record_send(session, buf, len);
if (result < 0)
{
if (GNUTLS_E_AGAIN == result)
{
errno = EAGAIN; // Need to retry.
}
else if (GNUTLS_E_INTERRUPTED == result)
{
errno = EINTR; // Need to retry
}
else if (gnutls_error_is_fatal(result))
{
NSString *p;
p = [NSString stringWithFormat: @"%s", gnutls_strerror(result)];
ASSIGN(problem, p);
if (YES == debug)
{
NSLog(@"%@ %@", self, p);
}
}
else
{
errno = EAGAIN; // Need to retry.
}
result = -1;
}
return result;
}
/* Copied/based on the public domain code provided by gnutls