From c92d6b22be44f20cb1ddcb0ea0738498b2802bd5 Mon Sep 17 00:00:00 2001 From: rfm Date: Sat, 22 Sep 2012 05:55:09 +0000 Subject: [PATCH] avoid unnecessary reset of descriptor during connect/accept git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35590 72102866-910b-0410-8b05-ffd578937521 --- SSL/GSSSLHandle.m | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/SSL/GSSSLHandle.m b/SSL/GSSSLHandle.m index 88d9545d9..129315200 100644 --- a/SSL/GSSSLHandle.m +++ b/SSL/GSSSLHandle.m @@ -401,7 +401,7 @@ static NSString *cipherList = nil; /* * Ensure we have a context and handle to connect with. */ - if (ctx == 0) + if (0 == ctx) { ctx = SSL_CTX_new(SSLv23_client_method()); if (permitSSLv2 == NO) @@ -413,16 +413,22 @@ static NSString *cipherList = nil; SSL_CTX_set_cipher_list(ctx, [cipherList UTF8String]); } } - if (ssl == 0) + if (0 == ssl) { ssl = SSL_new(ctx); } - /* - * Set non-blocking so accept won't hang if remote end goes wrong. - */ - [self setNonBlocking: YES]; - ret = SSL_set_fd(ssl, descriptor); + if (SSL_get_fd(ssl) == descriptor) + { + ret = 1; + } + else + { + /* Set non-blocking so accept won't hang if remote end goes wrong. + */ + [self setNonBlocking: YES]; + ret = SSL_set_fd(ssl, descriptor); + } if (1 == ret) { if (YES == isOutgoing)