Closed Bug 956328 (stream.js) Opened 10 years ago Closed 10 years ago

/lib/sdk/io/net.js -- Stream.resume triggers a resume on an unpaused stream pump.

Categories

(Add-on SDK Graveyard :: General, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: rodneyd.teal, Assigned: rodneyd.teal)

References

()

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 5.1; rv:29.0) Gecko/20100101 Firefox/29.0 (Beta/Release)
Build ID: 20131228030204

Steps to reproduce:

    var net = require('sdk/io/net');
    var server = net.createServer(function(c) { //'connection' listener
      console.log('server connected');
      c.on('end', function() {
        console.log('server disconnected');
      });
      //c.write('hello\r\n');
      c.pipe(c);
    });
    server.listen(8124, function() { //'listening' listener
      console.log('server bound');
    });
    function test() {
    var client = net.connect({port: 8124},
        function() { //'connect' listener
      console.log('client connected');
      client.write('world!\r\n');
    });
    client.on('data', function(data) {
      console.log(data.toString());
      client.end();
    });
    client.on('end', function() {
      console.log('client disconnected');
    });
    }
    test();
    test();
    test();


Actual results:

nsIInputStreamPump.resume throws NS_ERROR_UNEXPECTED
Patch attached.
Summary: /lib/io/net.js Stream.resume triggers a resume on an unpaused stream pump. → /lib/sdk/io/net.js Stream.resume triggers a resume on an unpaused stream pump.
Alias: stream.js
Summary: /lib/sdk/io/net.js Stream.resume triggers a resume on an unpaused stream pump. → /lib/sdk/io/net.js -- Stream.resume triggers a resume on an unpaused stream pump.
Comment on attachment 8355568 [details]
patch.diff.js Stream.pipe defines an onResume listener on target stream

Irakli, can you help decipher get this fixed?
Attachment #8355568 - Flags: review?(rFobic)
I think proper fix would be to fix InputStream.resume instead:
https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/io/stream.js#L193

probably by checking if underlying request is pending before resuming it:
https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/NsIRequest#isPending%28%29

We should also add a test case to ensure no regressions are introduced in a future, which
may be tricky without net module, but still probably possible using fs.createReadStream.

@rodneyd do you wanna make a pull request and send it our way ?
Attachment #8355568 - Flags: review?(rFobic) → review-
Assignee: nobody → rodneyd.teal
Attachment #8486936 - Flags: review?(rFobic) → review+
Commit pushed to master at https://github.com/mozilla/addon-sdk

https://github.com/mozilla/addon-sdk/commit/0d878a2eb711f79fd96da962098554a9829755a7
Merge pull request #1339 from DecipherCode/master

Bug 956328 Stream.resume triggers a resume on an unpaused stream pump r=@gozala
Blocks: 1114752
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: