You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2016/11/14 16:22:05 UTC
thrift git commit: THRIFT-3953 TSSLSocket::close should handle
exceptions from waitForEvent because it is called by the destructor Client:
C++ Patch: ted.wang@ni.com
Repository: thrift
Updated Branches:
refs/heads/master 7656793d0 -> 220d5f842
THRIFT-3953 TSSLSocket::close should handle exceptions from waitForEvent because it is called by the destructor
Client: C++
Patch: ted.wang@ni.com
This closes #1118
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/220d5f84
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/220d5f84
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/220d5f84
Branch: refs/heads/master
Commit: 220d5f8422ffeecf94f4b46a9dc3c004fd251766
Parents: 7656793
Author: James E. King, III <jk...@apache.org>
Authored: Mon Nov 14 11:19:56 2016 -0500
Committer: James E. King, III <jk...@apache.org>
Committed: Mon Nov 14 11:19:56 2016 -0500
----------------------------------------------------------------------
lib/cpp/src/thrift/transport/TSSLSocket.cpp | 56 ++++++++++++++----------
1 file changed, 32 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/220d5f84/lib/cpp/src/thrift/transport/TSSLSocket.cpp
----------------------------------------------------------------------
diff --git a/lib/cpp/src/thrift/transport/TSSLSocket.cpp b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
index 1a37716..0af20cb 100644
--- a/lib/cpp/src/thrift/transport/TSSLSocket.cpp
+++ b/lib/cpp/src/thrift/transport/TSSLSocket.cpp
@@ -293,33 +293,41 @@ void TSSLSocket::open() {
void TSSLSocket::close() {
if (ssl_ != NULL) {
- int rc;
+ try {
+ int rc;
+
+ do {
+ rc = SSL_shutdown(ssl_);
+ if (rc <= 0) {
+ int errno_copy = THRIFT_GET_SOCKET_ERROR;
+ int error = SSL_get_error(ssl_, rc);
+ switch (error) {
+ case SSL_ERROR_SYSCALL:
+ if ((errno_copy != THRIFT_EINTR)
+ && (errno_copy != THRIFT_EAGAIN)) {
+ break;
+ }
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ waitForEvent(error == SSL_ERROR_WANT_READ);
+ rc = 2;
+ default:;// do nothing
+ }
+ }
+ } while (rc == 2);
- do {
- rc = SSL_shutdown(ssl_);
- if (rc <= 0) {
+ if (rc < 0) {
int errno_copy = THRIFT_GET_SOCKET_ERROR;
- int error = SSL_get_error(ssl_, rc);
- switch (error) {
- case SSL_ERROR_SYSCALL:
- if ((errno_copy != THRIFT_EINTR)
- && (errno_copy != THRIFT_EAGAIN)) {
- break;
- }
- case SSL_ERROR_WANT_READ:
- case SSL_ERROR_WANT_WRITE:
- waitForEvent(error == SSL_ERROR_WANT_READ);
- rc = 2;
- default:;// do nothing
- }
+ string errors;
+ buildErrors(errors, errno_copy);
+ GlobalOutput(("SSL_shutdown: " + errors).c_str());
}
- } while (rc == 2);
-
- if (rc < 0) {
- int errno_copy = THRIFT_GET_SOCKET_ERROR;
- string errors;
- buildErrors(errors, errno_copy);
- GlobalOutput(("SSL_shutdown: " + errors).c_str());
+ } catch (TTransportException& te) {
+ // Don't emit an exception because this method is called by the
+ // destructor. There's also not much that a user can do to recover, so
+ // just clean up as much as possible without throwing, similar to the rc
+ // < 0 case above.
+ GlobalOutput.printf("SSL_shutdown: %s", te.what());
}
SSL_free(ssl_);
ssl_ = NULL;