mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
improve event handling when there is data in the tls buffers
This commit is contained in:
parent
483777bfa9
commit
326da37967
2 changed files with 52 additions and 2 deletions
|
@ -287,6 +287,7 @@ GSPrivateSockaddrSetup(NSString *machine, uint16_t port,
|
|||
- (void) bye; /* Close down the handled session. */
|
||||
- (BOOL) handshake; /* A handshake/hello is in progress. */
|
||||
- (void) hello; /* Start up the session handshake. */
|
||||
- (BOOL) readable; /* is there buffered data to read? */
|
||||
- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len;
|
||||
- (void) remove: (NSStream*)stream; /* Stream no longer available */
|
||||
- (void) stream: (NSStream*)stream handleEvent: (NSStreamEvent)event;
|
||||
|
@ -340,6 +341,11 @@ GSPrivateSockaddrSetup(NSString *machine, uint16_t port,
|
|||
{
|
||||
return ostream;
|
||||
}
|
||||
|
||||
- (BOOL) readable
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len
|
||||
{
|
||||
|
@ -691,6 +697,15 @@ static NSArray *keys = nil;
|
|||
return ostream;
|
||||
}
|
||||
|
||||
- (BOOL) readable
|
||||
{
|
||||
if (NO == active || YES == handshake)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return ([session pending] > 0) ? YES : NO;
|
||||
}
|
||||
|
||||
- (NSInteger) read: (uint8_t *)buffer maxLength: (NSUInteger)len
|
||||
{
|
||||
return [session read: buffer length: len];
|
||||
|
@ -2214,13 +2229,23 @@ setNonBlocking(SOCKET fd)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
- (BOOL) runLoopShouldBlock: (BOOL*)trigger
|
||||
{
|
||||
/* If there is a handler in place which has data buffered for reading
|
||||
* the run loop should trigger immediately so we read it.
|
||||
*/
|
||||
if ([_handler readable])
|
||||
{
|
||||
*trigger = YES;
|
||||
return NO;
|
||||
}
|
||||
#if defined(_WIN32)
|
||||
*trigger = YES;
|
||||
return YES;
|
||||
}
|
||||
#else
|
||||
return [super runLoopShouldBlock: trigger];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -1018,6 +1018,31 @@ GSTLSHandlePush(gnutls_transport_ptr_t handle, const void *buffer, size_t len)
|
|||
return [super read: buf length: len];
|
||||
}
|
||||
|
||||
- (void) watchReadDescriptorForModes: (NSArray*)modes
|
||||
{
|
||||
if (descriptor < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ([session pending] > 0)
|
||||
{
|
||||
NSRunLoop *l = [NSRunLoop currentRunLoop];
|
||||
|
||||
/* The underlying TLS buffers already have data so we signal
|
||||
* an event as soon as possible.
|
||||
*/
|
||||
[l performSelector: @selector(receivedEventRead)
|
||||
target: self
|
||||
argument: nil
|
||||
order: 0
|
||||
modes: modes];
|
||||
}
|
||||
else
|
||||
{
|
||||
[super watchReadDescriptorForModes: modes];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) sslAccept
|
||||
{
|
||||
/* If a server session is over five minutes old, destroy it so that
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue