Tamir Duberstein
df31d48636
Parallelize benchmarks
2016-07-14 22:03:14 -07:00
Tamir Duberstein
59b6f01712
Replace buffer with bufferedReader
...
bufferedReader is an optimized implementation of io.Reader that behaves
like
```
io.MultiReader(bytes.NewReader(buffer.Bytes()), io.TeeReader(source, buffer))
```
without allocating.
This has a measurable effect on benchmarks:
```
name old time/op new time/op delta
CMuxConn-4 1.09µs ± 4% 0.99µs ±19% -9.32% (p=0.000 n=17+19)
name old alloc/op new alloc/op delta
CMuxConn-4 240B ± 0% 260B ± 0% +8.33% (p=0.000 n=20+20)
name old allocs/op new allocs/op delta
CMuxConn-4 9.00 ± 0% 5.00 ± 0% -44.44% (p=0.000 n=20+20)
```
Note that appropriate test coverage is provided by `TestRead`.
2016-02-28 19:41:37 -05:00
Tamir Duberstein
49c66ff242
(*MuxConn).Read: fix erroneous io.EOF return
...
This fixes a bug where (*MuxConn).Read would return io.EOF if the
buffer was exactly the right size to fill the passed-in slice.
2016-02-25 21:59:10 -05:00
Tamir Duberstein
180c9ac049
go tool vet --shadow .
2016-02-25 11:47:10 -05:00
Tamir Duberstein
48443df968
buffer: do not retain passed-in memory
...
This is in violation of the io.Writer interface specification.
2016-02-25 11:40:31 -05:00
Tamir Duberstein
204cc45a24
http2: use io.ReadFull
...
This fixes an issue where an earlier matcher does not sufficiently
populate the buffer, preventing HTTP2 from reading enough bytes on the
Read call.
2016-02-23 11:25:36 -05:00
Tamir Duberstein
235d98b021
Tweak shutdown behaviour
...
When the root listener is closed, child listeners will not be closed
until all parked connections are served. This prevents losing
connections that have been read from.
This also allows moving the main test to package cmux_test, but that
will happen in a separate change.
2016-02-23 11:13:16 -05:00
Tamir Duberstein
9a9119af9d
fix flaky test TestErrorHandler
...
Before this change, this test would fail after about 50 runs. After
this change, I was able to run it 200 times without failure.
2016-02-23 11:06:01 -05:00
Tamir Duberstein
6490dea199
Reduce the number of calls needed to (*MuxConn).Read
...
Also affects (*buffer).Read.
2016-02-23 09:49:37 -05:00
Tamir Duberstein
15b1cf90b1
TestErrorHandler: assert that the error handler runs
...
Also fixes a race condition using an atomic and adds the race detector
to Travis CI.
2016-02-22 22:33:02 -05:00
Tamir Duberstein
e5e53dfc73
avoid (*testing.T).FailNow in non-main goroutines
2016-02-22 22:13:34 -05:00
Tamir Duberstein
ffd8d50a7c
fix test-only goroutine leaks
...
This makes real test failures' stack traces much easier to read.
2016-02-22 22:13:34 -05:00
Tamir Duberstein
5746da9df6
DRY
2016-02-21 12:59:08 -05:00
Tamir Duberstein
93090fcbbc
Add go vet to Travis CI
2016-02-21 12:39:43 -05:00
Tamir Duberstein
b5e73ea381
remove named returns and useless closures
2016-02-21 12:09:02 -05:00
Tamir Duberstein
ecc37f82cd
let the kernel assign ports
2016-02-21 12:07:55 -05:00
Tamir Duberstein
4f1b8abafd
Add Go 1.5 & 1.6 to Travis CI
2016-02-21 12:02:55 -05:00
Tamir Duberstein
92a63c4fce
errcheck
...
go/src/github.com/soheilhy/cmux/cmux.go:127:13 c.Close()
go/src/github.com/soheilhy/cmux/cmux.go:134:9 c.Close()
go/src/github.com/soheilhy/cmux/cmux.go:137:15 m.root.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:43:9 s.Serve(l)
go/src/github.com/soheilhy/cmux/cmux_test.go:52:20 defer r.Body.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:72:12 s.Register(TestRPCRcvr{})
go/src/github.com/soheilhy/cmux/cmux_test.go:103:15 defer l.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:109:15 go muxl.Serve()
go/src/github.com/soheilhy/cmux/cmux_test.go:116:20 defer r.Body.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:125:15 defer l.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:133:15 go muxl.Serve()
go/src/github.com/soheilhy/cmux/cmux_test.go:141:15 defer l.Close()
go/src/github.com/soheilhy/cmux/cmux_test.go:147:15 go muxl.Serve()
go/src/github.com/soheilhy/cmux/example_recursive_test.go:27:9 s.Serve(l)
go/src/github.com/soheilhy/cmux/example_recursive_test.go:56:12 s.Register(&RecursiveRPCRcvr{})
go/src/github.com/soheilhy/cmux/example_recursive_test.go:88:15 go tlsm.Serve()
go/src/github.com/soheilhy/cmux/example_recursive_test.go:89:12 tcpm.Serve()
go/src/github.com/soheilhy/cmux/example_test.go:30:9 s.Serve(l)
go/src/github.com/soheilhy/cmux/example_test.go:34:9 io.Copy(ws, ws)
go/src/github.com/soheilhy/cmux/example_test.go:41:9 s.Serve(l)
go/src/github.com/soheilhy/cmux/example_test.go:53:12 s.Register(&ExampleRPCRcvr{})
go/src/github.com/soheilhy/cmux/example_test.go:68:13 grpcs.Serve(l)
go/src/github.com/soheilhy/cmux/example_test.go:97:9 m.Serve()
go/src/github.com/soheilhy/cmux/example_tls_test.go:24:9 s.Serve(l)
go/src/github.com/soheilhy/cmux/example_tls_test.go:69:9 m.Serve()
go/src/github.com/soheilhy/cmux/matchers.go:151:14 hdec.Write(f.HeaderBlockFragment())
2016-02-21 12:02:37 -05:00
Tamir Duberstein
6c298ce7b1
Simplify formatting in patricia.go
...
`gofmt -s -w .`
2016-02-21 10:41:14 -05:00
Tamir Duberstein
48deeb47a3
golint
...
cmux.go:28:1: exported method ErrNotMatched.Temporary should have comment or be unexported
cmux.go:29:1: exported method ErrNotMatched.Timeout should have comment or be unexported
cmux.go:38:2: exported var ErrListenerClosed should have comment or be unexported
cmux.go:165:6: exported type MuxConn should have comment or be unexported
2016-02-21 10:34:32 -05:00
Tamir Duberstein
05566d752e
vet: buffer_test.go:65: possible formatting directive in Fatal call
2016-02-21 10:33:47 -05:00
Tamir Duberstein
4239e597d0
README: clarify why TLS is limited
2015-12-11 15:22:57 -05:00