Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,13 +685,11 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
native_immediates_.ConcatMove(std::move(native_immediates_threadsafe_));
}

NativeImmediateQueue queue;
queue.ConcatMove(std::move(native_immediates_));

auto drain_list = [&]() {
TryCatchScope try_catch(this);
DebugSealHandleScope seal_handle_scope(isolate());
while (std::unique_ptr<NativeImmediateCallback> head = queue.Shift()) {
while (std::unique_ptr<NativeImmediateCallback> head =
native_immediates_.Shift()) {
if (head->is_refed())
ref_count++;

Expand All @@ -709,7 +707,7 @@ void Environment::RunAndClearNativeImmediates(bool only_refed) {
}
return false;
};
while (queue.size() > 0 && drain_list()) {}
while (drain_list()) {}

immediate_info()->ref_count_dec(ref_count);

Expand Down
19 changes: 11 additions & 8 deletions test/parallel/test-http2-buffersize.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,32 @@ const Countdown = require('../common/countdown');
const BUFFER_SIZE = 30;
const server = createServer();

let client;
const countdown = new Countdown(SOCKETS, () => {
client.close();
server.close();
});

// Other `bufferSize` tests for net module and tls module
// don't assert `bufferSize` of server-side sockets.
server.on('stream', mustCall((stream) => {
stream.on('data', mustCall());
stream.on('end', mustCall());

stream.on('close', mustCall(() => {
countdown.dec();
}));
}, SOCKETS));

server.listen(0, mustCall(() => {
const authority = `http://localhost:${server.address().port}`;
const client = connect(authority);
const countdown = new Countdown(SOCKETS, () => {
client.close();
server.close();
});
client = connect(authority);

client.once('connect', mustCall());

for (let j = 0; j < SOCKETS; j += 1) {
const stream = client.request({ ':method': 'POST' });
stream.on('data', () => {});
stream.on('close', mustCall(() => {
countdown.dec();
}));

for (let i = 0; i < TIMES; i += 1) {
stream.write(Buffer.allocUnsafe(BUFFER_SIZE), mustCall());
Expand Down