[ 
https://issues.apache.org/jira/browse/THRIFT-3950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16546839#comment-16546839
 ] 

ASF GitHub Bot commented on THRIFT-3950:
----------------------------------------

jeking3 closed pull request #1568: THRIFT-3950: Memory leak while calling 
oneway methods
URL: https://github.com/apache/thrift/pull/1568
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc 
b/compiler/cpp/src/thrift/generate/t_js_generator.cc
index 57baa9b76d..4d1cea6d25 100644
--- a/compiler/cpp/src/thrift/generate/t_js_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc
@@ -1565,7 +1565,14 @@ void t_js_generator::generate_service_client(t_service* 
tservice) {
                << ".writeMessageEnd();" << endl;
 
     if (gen_node_) {
-      f_service_ << indent() << "return this.output.flush();" << endl;
+      if((*f_iter)->is_oneway()) {
+        f_service_ << indent() << "this.output.flush();" << endl;
+        f_service_ << indent() << "var callback = this._reqs[this.seqid()] || 
function() {};" << endl;
+        f_service_ << indent() << "delete this._reqs[this.seqid()];" << endl;
+        f_service_ << indent() << "callback(null);" << endl;
+      } else {
+        f_service_ << indent() << "return this.output.flush();" << endl;
+      }
     } else {
       if (gen_jquery_) {
         f_service_ << indent() << "return 
this.output.getTransport().flush(callback);" << endl;
diff --git a/lib/nodejs/test/test_driver.js b/lib/nodejs/test/test_driver.js
index 03ec5138b5..4612a326a3 100644
--- a/lib/nodejs/test/test_driver.js
+++ b/lib/nodejs/test/test_driver.js
@@ -125,7 +125,8 @@ exports.ThriftTestDriver = function(client, callback) {
     });
 
     client.testOneway(0, function(err, response) {
-      assert.fail('testOneway should not answer');
+      assert.error(err, 'testOneway: no callback error');
+      assert.strictEqual(response, undefined, 'testOneway: void response');
     });
 
     checkOffByOne(function(done) {
@@ -223,7 +224,11 @@ exports.ThriftTestDriverPromise = function(client, 
callback) {
       })
       .fail(fail('testException'));
 
-    client.testOneway(0, fail('testOneway: should not answer'));
+    client.testOneway(0)
+      .then(function(response) {
+        assert.strictEqual(response, undefined, 'testOneway: void response')
+      })
+      .fail(fail('testOneway: should not reject'));
 
     checkOffByOne(function(done) {
       client.testI32(-1)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Memory leak while calling oneway method
> ---------------------------------------
>
>                 Key: THRIFT-3950
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3950
>             Project: Thrift
>          Issue Type: Bug
>          Components: Node.js - Compiler
>    Affects Versions: 0.9.3
>            Reporter: Sangmin Yoon
>            Priority: Major
>
> When you call oneway methods in Node.js, Service._reqs object is bloated.
> There is no chance to 'delete this._reqs[rseqid];' because no return from 
> server.
> Also Connection.seqId2Service is bloated.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to