mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-22 05:02:00 +00:00
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:
parent
872cbe7627
commit
73a23ba709
5 changed files with 50 additions and 26 deletions
|
@ -366,24 +366,26 @@ static GSTcpTune *tune = nil;
|
|||
[self ignoreReadDescriptor];
|
||||
[self ignoreWriteDescriptor];
|
||||
|
||||
#if USE_ZLIB
|
||||
/*
|
||||
* The gzDescriptor should always be closed when we have done with it.
|
||||
*/
|
||||
if (gzDescriptor != 0)
|
||||
if (closeOnDealloc == YES && descriptor != -1)
|
||||
{
|
||||
gzclose(gzDescriptor);
|
||||
gzDescriptor = 0;
|
||||
[self closeFile];
|
||||
}
|
||||
#endif
|
||||
if (descriptor != -1)
|
||||
else
|
||||
{
|
||||
[self setNonBlocking: wasNonBlocking];
|
||||
if (closeOnDealloc == YES)
|
||||
{
|
||||
close(descriptor);
|
||||
descriptor = -1;
|
||||
}
|
||||
#if USE_ZLIB
|
||||
/*
|
||||
* The gzDescriptor should always be closed when we have done with it.
|
||||
*/
|
||||
if (gzDescriptor != 0)
|
||||
{
|
||||
gzclose(gzDescriptor);
|
||||
gzDescriptor = 0;
|
||||
}
|
||||
#endif
|
||||
if (descriptor != -1)
|
||||
{
|
||||
[self setNonBlocking: wasNonBlocking];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ static NSArray *keys = nil;
|
|||
{
|
||||
handshake = NO;
|
||||
active = NO;
|
||||
[session disconnect];
|
||||
[session disconnect: NO];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
|
|
@ -197,9 +197,13 @@ typedef ssize_t (*GSTLSIOW)(gnutls_transport_ptr_t, const void *, size_t);
|
|||
*/
|
||||
- (BOOL) active;
|
||||
|
||||
/* Disconnects and closes down the session.
|
||||
/* Disconnects and closes down the session.<br />
|
||||
* The reusable flag specifies whether we intend to reuse the underlying
|
||||
* connection.<br />
|
||||
* Returns YES on success, NO if the shutdown did not complete cleanly
|
||||
* and the underlying connection cannot be reused.
|
||||
*/
|
||||
- (void) disconnect;
|
||||
- (BOOL) disconnect: (BOOL)reusable;
|
||||
|
||||
/* Try to complete a handshake ... return YES if complete, NO if we need
|
||||
* to try again (would have to wait for the remote end).<br />
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -985,9 +985,7 @@ GSTLSHandlePush(gnutls_transport_ptr_t handle, const void *buffer, size_t len)
|
|||
|
||||
- (void) sslDisconnect
|
||||
{
|
||||
// TLS may need to read data during teardown, and we need to wait for it.
|
||||
[self setNonBlocking: NO];
|
||||
[session disconnect];
|
||||
[session disconnect: NO];
|
||||
}
|
||||
|
||||
- (BOOL) sslHandshakeEstablished: (BOOL*)result outgoing: (BOOL)isOutgoing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue