Skip to content

Switch from Github Actions to Travis #192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 18, 2020
Merged
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
55 changes: 0 additions & 55 deletions .github/workflows/ci.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
language: go
go: 1.x
dist: bionic

env:
global:
- SHFMT_URL=https://github.com/mvdan/sh/releases/download/v3.0.1/shfmt_v3.0.1_linux_amd64
- GOFLAGS="-mod=readonly"

jobs:
include:
- name: Format
before_script:
- sudo apt-get install -y npm
- sudo npm install -g prettier
- sudo curl -L "$SHFMT_URL" > /usr/local/bin/shfmt && sudo chmod +x /usr/local/bin/shfmt
- go get golang.org/x/tools/cmd/stringer
- go get golang.org/x/tools/cmd/goimports
script: make -j16 fmt
- name: Lint
before_script:
- sudo apt-get install -y shellcheck
- go get golang.org/x/lint/golint
script: make -j16 lint
- name: Test
before_script:
- sudo apt-get install -y chromium-browser
- go get github.com/agnivade/wasmbrowsertest
- go get github.com/mattn/goveralls
script: make -j16 test

addons:
apt:
update: true

cache:
npm: true
directories:
- ~/.cache
- ~/gopath/pkg
18 changes: 0 additions & 18 deletions ci/image/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions close_notjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ func (c *Conn) waitCloseHandshake() error {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()

err := c.readMu.Lock(ctx)
err := c.readMu.lock(ctx)
if err != nil {
return err
}
defer c.readMu.Unlock()
defer c.readMu.unlock()

if c.readCloseFrameErr != nil {
return c.readCloseFrameErr
Expand Down
23 changes: 14 additions & 9 deletions conn_notjs.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,9 @@ func (c *Conn) close(err error) {
c.rwc.Close()

go func() {
if c.client {
c.writeFrameMu.Lock(context.Background())
putBufioWriter(c.bw)
}
c.msgWriterState.close()

c.msgReader.close()
if c.client {
putBufioReader(c.br)
}
}()
}

Expand Down Expand Up @@ -237,7 +230,11 @@ func newMu(c *Conn) *mu {
}
}

func (m *mu) Lock(ctx context.Context) error {
func (m *mu) forceLock() {
m.ch <- struct{}{}
}

func (m *mu) lock(ctx context.Context) error {
select {
case <-m.c.closed:
return m.c.closeErr
Expand All @@ -246,11 +243,19 @@ func (m *mu) Lock(ctx context.Context) error {
m.c.close(err)
return err
case m.ch <- struct{}{}:
// To make sure the connection is certainly alive.
// As it's possible the send on m.ch was selected
// the receive on closed.
select {
case <-m.c.closed:
return m.c.closeErr
default:
}
return nil
}
}

func (m *mu) Unlock() {
func (m *mu) unlock() {
select {
case <-m.ch:
default:
Expand Down
4 changes: 4 additions & 0 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ func TestConn(t *testing.T) {
func TestWasm(t *testing.T) {
t.Parallel()

if os.Getenv("CI") != "" {
t.Skip("skipping on CI")
}

var wg sync.WaitGroup
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
wg.Add(1)
Expand Down
12 changes: 6 additions & 6 deletions dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ func verifyServerExtensions(copts *compressionOptions, h http.Header) (*compress
return copts, nil
}

var readerPool sync.Pool
var bufioReaderPool sync.Pool

func getBufioReader(r io.Reader) *bufio.Reader {
br, ok := readerPool.Get().(*bufio.Reader)
br, ok := bufioReaderPool.Get().(*bufio.Reader)
if !ok {
return bufio.NewReader(r)
}
Expand All @@ -265,13 +265,13 @@ func getBufioReader(r io.Reader) *bufio.Reader {
}

func putBufioReader(br *bufio.Reader) {
readerPool.Put(br)
bufioReaderPool.Put(br)
}

var writerPool sync.Pool
var bufioWriterPool sync.Pool

func getBufioWriter(w io.Writer) *bufio.Writer {
bw, ok := writerPool.Get().(*bufio.Writer)
bw, ok := bufioWriterPool.Get().(*bufio.Writer)
if !ok {
return bufio.NewWriter(w)
}
Expand All @@ -280,5 +280,5 @@ func getBufioWriter(w io.Writer) *bufio.Writer {
}

func putBufioWriter(bw *bufio.Writer) {
writerPool.Put(bw)
bufioWriterPool.Put(bw)
}
15 changes: 10 additions & 5 deletions read.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,17 @@ func (mr *msgReader) putFlateReader() {
}

func (mr *msgReader) close() {
mr.c.readMu.Lock(context.Background())
mr.c.readMu.forceLock()
mr.putFlateReader()
mr.dict.close()
if mr.flateBufio != nil {
putBufioReader(mr.flateBufio)
}

if mr.c.client {
putBufioReader(mr.c.br)
mr.c.br = nil
}
}

func (mr *msgReader) flateContextTakeover() bool {
Expand Down Expand Up @@ -292,11 +297,11 @@ func (c *Conn) handleControl(ctx context.Context, h header) (err error) {
func (c *Conn) reader(ctx context.Context) (_ MessageType, _ io.Reader, err error) {
defer errd.Wrap(&err, "failed to get reader")

err = c.readMu.Lock(ctx)
err = c.readMu.lock(ctx)
if err != nil {
return 0, nil, err
}
defer c.readMu.Unlock()
defer c.readMu.unlock()

if !c.msgReader.fin {
return 0, nil, errors.New("previous message not read to completion")
Expand Down Expand Up @@ -368,11 +373,11 @@ func (mr *msgReader) Read(p []byte) (n int, err error) {
errd.Wrap(&err, "failed to read")
}()

err = mr.c.readMu.Lock(mr.ctx)
err = mr.c.readMu.lock(mr.ctx)
if err != nil {
return 0, err
}
defer mr.c.readMu.Unlock()
defer mr.c.readMu.unlock()

n, err = mr.limitReader.Read(p)
if mr.flate && mr.flateContextTakeover() {
Expand Down
15 changes: 10 additions & 5 deletions write.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (c *Conn) write(ctx context.Context, typ MessageType, p []byte) (int, error
}

if !c.flate() {
defer c.msgWriterState.mu.Unlock()
defer c.msgWriterState.mu.unlock()
return c.writeFrame(ctx, true, false, c.msgWriterState.opcode, p)
}

Expand All @@ -139,7 +139,7 @@ func (c *Conn) write(ctx context.Context, typ MessageType, p []byte) (int, error
}

func (mw *msgWriterState) reset(ctx context.Context, typ MessageType) error {
err := mw.mu.Lock(ctx)
err := mw.mu.lock(ctx)
if err != nil {
return err
}
Expand Down Expand Up @@ -204,11 +204,16 @@ func (mw *msgWriterState) Close() (err error) {
if mw.flate && !mw.flateContextTakeover() {
mw.dict.close()
}
mw.mu.Unlock()
mw.mu.unlock()
return nil
}

func (mw *msgWriterState) close() {
if mw.c.client {
mw.c.writeFrameMu.forceLock()
putBufioWriter(mw.c.bw)
}

mw.writeMu.Lock()
mw.dict.close()
}
Expand All @@ -226,11 +231,11 @@ func (c *Conn) writeControl(ctx context.Context, opcode opcode, p []byte) error

// frame handles all writes to the connection.
func (c *Conn) writeFrame(ctx context.Context, fin bool, flate bool, opcode opcode, p []byte) (int, error) {
err := c.writeFrameMu.Lock(ctx)
err := c.writeFrameMu.lock(ctx)
if err != nil {
return 0, err
}
defer c.writeFrameMu.Unlock()
defer c.writeFrameMu.unlock()

select {
case <-c.closed:
Expand Down