diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2009-04-07 16:28:30 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2009-04-07 16:28:30 +0000 |
commit | 0d399f97dd227989c657ad080e9ad829f113ce2a (patch) | |
tree | 9319755d0dee17685baf1455424bdd9cfa4ebb7c /ssl/s3_lib.c | |
parent | 3fdc2c906d9cc710bde85804838b3ace3117a02c (diff) |
Submitted by: Darryl Miles <darryl-mailinglists@netbauds.net>
Approved by: steve@openssl.org
Handle non-blocking I/O properly in SSL_shutdown() call.
Diffstat (limited to 'ssl/s3_lib.c')
-rw-r--r-- | ssl/s3_lib.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 8916a0b1b3..8fa4ab02c3 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -2458,6 +2458,7 @@ int ssl3_get_req_cert_type(SSL *s, unsigned char *p) int ssl3_shutdown(SSL *s) { + int ret; /* Don't do anything much if we have not done the handshake or * we don't want to send messages :-) */ @@ -2475,18 +2476,32 @@ int ssl3_shutdown(SSL *s) #endif /* our shutdown alert has been sent now, and if it still needs * to be written, s->s3->alert_dispatch will be true */ + if (s->s3->alert_dispatch) + return(-1); /* return WANT_WRITE */ } else if (s->s3->alert_dispatch) { /* resend it if not sent */ #if 1 - s->method->ssl_dispatch_alert(s); + ret=s->method->ssl_dispatch_alert(s); + if(ret == -1) + { + /* we only get to return -1 here the 2nd/Nth + * invocation, we must have already signalled + * return 0 upon a previous invoation, + * return WANT_WRITE */ + return(ret); + } #endif } else if (!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) { /* If we are waiting for a close from our peer, we are closed */ s->method->ssl_read_bytes(s,0,NULL,0,0); + if(!(s->shutdown & SSL_RECEIVED_SHUTDOWN)) + { + return(-1); /* return WANT_READ */ + } } if ((s->shutdown == (SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN)) && |