1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

Fix wg ref counting for fetch.

This commit is contained in:
Ryan Dahl 2018-05-28 14:56:13 -04:00
parent 46117017c4
commit 666a0f3a3e
2 changed files with 14 additions and 8 deletions

View file

@ -80,7 +80,6 @@ func PubMsg(channel string, msg *Msg) {
} }
func DispatchLoop() { func DispatchLoop() {
// runtime.LockOSThread()
wg.Add(1) wg.Add(1)
first := true first := true
@ -96,7 +95,6 @@ func DispatchLoop() {
for { for {
select { select {
case msg := <-resChan: case msg := <-resChan:
wg.Done()
out, err := proto.Marshal(msg) out, err := proto.Marshal(msg)
if err != nil { if err != nil {
panic(err) panic(err)
@ -105,6 +103,7 @@ func DispatchLoop() {
stats.v8workerSend++ stats.v8workerSend++
stats.v8workerBytesSent += len(out) stats.v8workerBytesSent += len(out)
exitOnError(err) exitOnError(err)
wg.Done() // Corresponds to the wg.Add(1) in Pub().
case <-doneChan: case <-doneChan:
// All goroutines have completed. Now we can exit main(). // All goroutines have completed. Now we can exit main().
return return

View file

@ -1,13 +1,25 @@
// This test is executed as part of integration_test.go // This test is executed as part of integration_test.go
// But it can also be run manually: // But it can also be run manually:
// ./deno tests.ts // ./deno tests.ts
// There must also be a static file http server running on localhost:4545
// serving the deno project directory. Try this:
// http-server -p 4545 --cors .
import { test, assert, assertEqual } from "./deno_testing/testing.ts"; import { test, assert, assertEqual } from "./deno_testing/testing.ts";
import { readFileSync, writeFileSync } from "deno"; import {
readFileSync,
writeFileSync
} from "deno";
test(async function tests_test() { test(async function tests_test() {
assert(true); assert(true);
}); });
test(async function tests_fetch() {
const response = await fetch('http://localhost:4545/package.json');
const json = await response.json();
assertEqual(json.name, "deno");
});
test(async function tests_readFileSync() { test(async function tests_readFileSync() {
let data = readFileSync("package.json"); let data = readFileSync("package.json");
if (!data.byteLength) { if (!data.byteLength) {
@ -33,8 +45,3 @@ test(async function tests_writeFileSync() {
assertEqual("Hello", actual); assertEqual("Hello", actual);
}); });
test(async function tests_fetch() {
const response = await fetch("http://localhost:4545/package.json");
const json = await response.json();
assertEqual(json.name, "deno");
});