git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37391 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-11-21 16:45:01 +00:00
parent 12f935a8e4
commit 4803d56747
4 changed files with 18 additions and 38 deletions

View file

@ -1,10 +1,3 @@
2013-11-21 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSFileHandle.m: Do an -sslDisconnect while finalising
(before underlying network connection is closed).
* Source/NSFileHandle.m: Add assertion to check that TLS has been
shut down by concrete subclass dealloc.
2013-11-20 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: Fix for bug 40620

View file

@ -214,7 +214,8 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey";
[self ignoreWriteDescriptor];
#if USE_ZLIB
/* The gzDescriptor should always be closed when we have done with it.
/*
* The gzDescriptor should always be closed when we have done with it.
*/
if (gzDescriptor != 0)
{
@ -222,14 +223,6 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey";
gzDescriptor = 0;
}
#endif
/* Ensure any SSL/TLS connection has been properly shut down.
*/
[self sslDisconnect];
/* Close file descriptor if necessary (setting correct non-blocking
* characteristics since we may have changed them).
*/
if (descriptor != -1)
{
[self setNonBlocking: wasNonBlocking];
@ -239,7 +232,6 @@ static NSString* NotificationKey = @"NSFileHandleNotificationKey";
descriptor = -1;
}
}
[super finalize];
}
// Initializing a GSFileHandle Object

View file

@ -953,22 +953,29 @@ GSTLSHandlePush(gnutls_transport_ptr_t handle, const void *buffer, size_t len)
- (void) closeFile
{
[self sslDisconnect]; // Shut down TLS before closing socket
[self sslDisconnect];
[super closeFile];
}
- (void) dealloc
{
/* Any TLS connection needs to be shut down before the network connection
* is closed, which means that the concrete subclass must do that.
* Therefore, the session should be inactive by the time we get here.
*/
NSAssert(NO == [session active], NSInternalInconsistencyException);
DESTROY(session);
DESTROY(opts);
// TLS may need to read data during teardown, and we need to wait for it.
[self setNonBlocking: NO];
// Don't DESTROY ivars below. First release them, then set nil, because
// `session' may need this back-reference during TLS teardown.
TEST_RELEASE(opts);
TEST_RELEASE(session);
opts = nil;
session = nil;
[super dealloc];
}
- (void) finalize
{
[self sslDisconnect];
[super finalize];
}
- (NSInteger) read: (void*)buf length: (NSUInteger)len
{
if (YES == [session active])
@ -980,14 +987,7 @@ GSTLSHandlePush(gnutls_transport_ptr_t handle, const void *buffer, size_t len)
- (void) sslDisconnect
{
if (nil != session)
{
// TLS may need to read data during teardown, and we need to wait for it.
[self setNonBlocking: NO];
[session disconnect];
DESTROY(session);
}
DESTROY(opts);
[session disconnect];
}
- (BOOL) sslHandshakeEstablished: (BOOL*)result outgoing: (BOOL)isOutgoing

View file

@ -270,11 +270,6 @@ getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
gzclose(gzDescriptor);
}
#endif
/* Ensure any SSL/TLS connection has been properly shut down.
*/
[self sslDisconnect];
if (descriptor != -1)
{
[self setNonBlocking: wasNonBlocking];