Try to cope with failure of remote end to respond to tls shutdown.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37417 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-11-27 12:26:33 +00:00
parent 872cbe7627
commit 73a23ba709
5 changed files with 50 additions and 26 deletions

View file

@ -1281,13 +1281,32 @@ static NSMutableDictionary *credentialsCache = nil;
[super dealloc];
}
- (void) disconnect
- (BOOL) disconnect: (BOOL)reusable
{
BOOL ok = YES;
if (YES == active || YES == handshake)
{
active = NO;
handshake = NO;
gnutls_bye(session, GNUTLS_SHUT_RDWR);
if (NO == reusable)
{
gnutls_bye(session, GNUTLS_SHUT_WR);
}
else
{
int result;
do
{
result = gnutls_bye(session, GNUTLS_SHUT_RDWR);
}
while (GNUTLS_E_AGAIN == result || GNUTLS_E_INTERRUPTED == result);
if (result < 0)
{
ok = NO;
}
}
}
if (YES == setup)
{
@ -1295,11 +1314,12 @@ static NSMutableDictionary *credentialsCache = nil;
gnutls_db_remove_session(session);
gnutls_deinit(session);
}
return ok;
}
- (void) finalize
{
[self disconnect];
[self disconnect: NO];
[super finalize];
}
@ -1545,7 +1565,7 @@ static NSMutableDictionary *credentialsCache = nil;
ASSIGN(problem, p);
NSLog(@"%@ %@", self, p);
}
[self disconnect];
[self disconnect: NO];
return YES; // Failed ... not active.
}
else
@ -1591,7 +1611,7 @@ static NSMutableDictionary *credentialsCache = nil;
self, gnutls_strerror(ret));
NSLog(@"%@ %@", self, [self sessionInfo]);
}
[self disconnect];
[self disconnect: NO];
}
}
return YES; // Handshake complete