| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f61a045 commit 2616f12
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -803,13 +803,15 @@ void Http2Session::Close(uint32_t code, bool socket_closed) { | |||
| 803 | 803 | CHECK_EQ(nghttp2_session_terminate_session(session_.get(), code), 0); | |
| 804 | 804 | SendPendingData(); | |
| 805 | 805 | } else if (stream_ != nullptr) { | |
| 806 | + // so that the previous listener of the socket, typically, JS code of a | ||
| 807 | + // (tls) socket will be notified of any activity later | ||
| 806 | 808 | stream_->RemoveStreamListener(this); | |
| 807 | 809 | } | |
| 808 | 810 | ||
| 809 | 811 | set_destroyed(); | |
| 810 | 812 | ||
| 811 | 813 | // If we are writing we will get to make the callback in OnStreamAfterWrite. | |
| 812 | - if (!is_write_in_progress()) { | ||
| 814 | + if (!is_write_in_progress() || !stream_) { | ||
| 813 | 815 | Debug(this, "make done session callback"); | |
| 814 | 816 | HandleScope scope(env()->isolate()); | |
| 815 | 817 | MakeCallback(env()->ondone_string(), 0, nullptr); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,80 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + // Flags: --expose-gc | ||
| 3 | + | ||
| 4 | + const common = require('../common'); | ||
| 5 | + if (!common.hasCrypto) | ||
| 6 | + common.skip('missing crypto'); | ||
| 7 | + const http2 = require('http2'); | ||
| 8 | + const tls = require('tls'); | ||
| 9 | + const fixtures = require('../common/fixtures'); | ||
| 10 | + const assert = require('assert'); | ||
| 11 | + | ||
| 12 | + const registry = new FinalizationRegistry(common.mustCall((name) => { | ||
| 13 | + assert(name, 'session'); | ||
| 14 | + })); | ||
| 15 | + | ||
| 16 | + const server = http2.createSecureServer({ | ||
| 17 | + key: fixtures.readKey('agent1-key.pem'), | ||
| 18 | + cert: fixtures.readKey('agent1-cert.pem'), | ||
| 19 | + }); | ||
| 20 | + | ||
| 21 | + let firstServerStream; | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + server.on('secureConnection', (s) => { | ||
| 25 | + console.log('secureConnection'); | ||
| 26 | + s.on('end', () => { | ||
| 27 | + console.log(s.destroyed); // false !! | ||
| 28 | + s.destroy(); | ||
| 29 | + firstServerStream.session.destroy(); | ||
| 30 | + | ||
| 31 | + firstServerStream = null; | ||
| 32 | + | ||
| 33 | + setImmediate(() => { | ||
| 34 | + global.gc(); | ||
| 35 | + global.gc(); | ||
| 36 | + | ||
| 37 | + server.close(); | ||
| 38 | + }); | ||
| 39 | + }); | ||
| 40 | + }); | ||
| 41 | + | ||
| 42 | + server.on('session', (s) => { | ||
| 43 | + registry.register(s, 'session'); | ||
| 44 | + }); | ||
| 45 | + | ||
| 46 | + server.on('stream', (stream) => { | ||
| 47 | + console.log('stream...'); | ||
| 48 | + stream.write('a'.repeat(1024)); | ||
| 49 | + firstServerStream = stream; | ||
| 50 | + setImmediate(() => console.log('Draining setImmediate after writing')); | ||
| 51 | + }); | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + server.listen(() => { | ||
| 55 | + client(); | ||
| 56 | + }); | ||
| 57 | + | ||
| 58 | + | ||
| 59 | + const h2fstStream = [ | ||
| 60 | + 'UFJJICogSFRUUC8yLjANCg0KU00NCg0K', | ||
| 61 | + // http message (1st stream:) | ||
| 62 | + 'AAAABAAAAAAA', | ||
| 63 | + 'AAAPAQUAAAABhIJBiqDkHROdCbjwHgeG', | ||
| 64 | + ]; | ||
| 65 | + function client() { | ||
| 66 | + const client = tls.connect({ | ||
| 67 | + port: server.address().port, | ||
| 68 | + host: 'localhost', | ||
| 69 | + rejectUnauthorized: false, | ||
| 70 | + ALPNProtocols: ['h2'] | ||
| 71 | + }, () => { | ||
| 72 | + client.end(Buffer.concat(h2fstStream.map((s) => Buffer.from(s, 'base64'))), (err) => { | ||
| 73 | + assert.ifError(err); | ||
| 74 | + }); | ||
| 75 | + }); | ||
| 76 | + | ||
| 77 | + client.on('error', (error) => { | ||
| 78 | + console.error('Connection error:', error); | ||
| 79 | + }); | ||
| 80 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments