You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ra...@apache.org on 2016/05/13 05:09:32 UTC

thrift git commit: THRIFT-3787: connection close code fix for ssl CLIENT: Node PATCH: JAMES REGGIO james.reggio@gmail.com

Repository: thrift
Updated Branches:
  refs/heads/master 9b954e6a4 -> d7f87aa5f


THRIFT-3787: connection close code fix for ssl
CLIENT: Node
PATCH: JAMES REGGIO james.reggio@gmail.com

This closes #986
commit 449b1d711f91a9252b64351a71e44945e4432911
Author: James Reggio <ja...@gmail.com>
Date: 2016-04-13T23:33:40Z
THRIFT-3787 Fix Node.js Connection object error handling
The `connected` property on a Connection instances was not accurately
maintained if reconnection retries are not enabled.
Furthermore, reconnection retries are not possible with secure sockets,
so this commit returns early in that case, preventing long delays.


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/d7f87aa5
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/d7f87aa5
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/d7f87aa5

Branch: refs/heads/master
Commit: d7f87aa5f2ceca288b9159b2d3e70497c330aa38
Parents: 9b954e6
Author: Randy Abernethy <ra...@apache.org>
Authored: Thu May 12 22:02:58 2016 -0700
Committer: Randy Abernethy <ra...@apache.org>
Committed: Thu May 12 22:02:58 2016 -0700

----------------------------------------------------------------------
 lib/nodejs/lib/thrift/connection.js | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/d7f87aa5/lib/nodejs/lib/thrift/connection.js
----------------------------------------------------------------------
diff --git a/lib/nodejs/lib/thrift/connection.js b/lib/nodejs/lib/thrift/connection.js
index 0ea50d3..23cb01c 100644
--- a/lib/nodejs/lib/thrift/connection.js
+++ b/lib/nodejs/lib/thrift/connection.js
@@ -82,14 +82,12 @@ var Connection = exports.Connection = function(stream, options) {
 
   this.connection.addListener("error", function(err) {
     // Only emit the error if no-one else is listening on the connection
-    // or if someone is listening on us
+    // or if someone is listening on us, because Node turns unhandled
+    // 'error' events into exceptions.
     if (self.connection.listeners('error').length === 1 ||
         self.listeners('error').length > 0) {
       self.emit("error", err);
     }
-    // "error" events get turned into exceptions if they aren't listened for.  If the user handled this error
-    // then we should try to reconnect.
-    self.connection_gone();
   });
 
   // Add a close listener
@@ -185,19 +183,18 @@ Connection.prototype.write = function(data) {
 
 Connection.prototype.connection_gone = function () {
   var self = this;
+  this.connected = false;
 
   // If a retry is already in progress, just let that happen
   if (this.retry_timer) {
     return;
   }
-  if (!this.max_attempts) {
+  // We cannot reconnect a secure socket.
+  if (!this.max_attempts || this.ssl) {
     self.emit("close");
     return;
   }
 
-  this.connected = false;
-  this.ready = false;
-
   if (this.retry_max_delay !== null && this.retry_delay >= this.retry_max_delay) {
     this.retry_delay = this.retry_max_delay;
   } else {