Skip to content
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
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# The fedora/23-cloud-base and debian/jessie64 boxes are also available for
# The fedora/25-cloud-base and debian/jessie64 boxes are also available for
# the "virtualbox" provider. Set the VAGRANT_PROVIDER environment variable to
# "virtualbox" to use them instead.
#
Vagrant.configure("2") do |config|
config.vm.define "fedora" do |c|
c.vm.box = "fedora/23-cloud-base"
c.vm.box = "fedora/25-cloud-base"
c.vm.synced_folder ".", "/vagrant", type: "rsync",
rsync__exclude: "bundles", rsync__args: "-vadz"
c.vm.provision "shell", inline: <<-SHELL
Expand Down
2 changes: 1 addition & 1 deletion hack/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DEFAULT_BUNDLES=(

test-unit

#gccgo -- failing due to 1.7 incompatibilities
gccgo
cross
)

Expand Down
1 change: 1 addition & 0 deletions hack/make/gccgo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"

source "${MAKEDIR}/.go-autogen"

export GCCGO=${SCRIPTDIR}/../vagrant/gccgo-wrapper.sh
# gccgo require explicit flag -pthread to allow goroutines to work.
go build -compiler=gccgo \
-o "$DEST/$BINARY_FULLNAME" \
Expand Down
71 changes: 0 additions & 71 deletions pkg/ioutils/readers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"crypto/sha256"
"encoding/hex"
"io"

"golang.org/x/net/context"
)

type readCloserWrapper struct {
Expand Down Expand Up @@ -83,72 +81,3 @@ func (r *OnEOFReader) runFunc() {
r.Fn = nil
}
}

// cancelReadCloser wraps an io.ReadCloser with a context for cancelling read
// operations.
type cancelReadCloser struct {
cancel func()
pR *io.PipeReader // Stream to read from
pW *io.PipeWriter
}

// NewCancelReadCloser creates a wrapper that closes the ReadCloser when the
// context is cancelled. The returned io.ReadCloser must be closed when it is
// no longer needed.
func NewCancelReadCloser(ctx context.Context, in io.ReadCloser) io.ReadCloser {
pR, pW := io.Pipe()

// Create a context used to signal when the pipe is closed
doneCtx, cancel := context.WithCancel(context.Background())

p := &cancelReadCloser{
cancel: cancel,
pR: pR,
pW: pW,
}

go func() {
_, err := io.Copy(pW, in)
select {
case <-ctx.Done():
// If the context was closed, p.closeWithError
// was already called. Calling it again would
// change the error that Read returns.
default:
p.closeWithError(err)
}
in.Close()
}()
go func() {
for {
select {
case <-ctx.Done():
p.closeWithError(ctx.Err())
case <-doneCtx.Done():
return
}
}
}()

return p
}

// Read wraps the Read method of the pipe that provides data from the wrapped
// ReadCloser.
func (p *cancelReadCloser) Read(buf []byte) (n int, err error) {
return p.pR.Read(buf)
}

// closeWithError closes the wrapper and its underlying reader. It will
// cause future calls to Read to return err.
func (p *cancelReadCloser) closeWithError(err error) {
p.pW.CloseWithError(err)
p.cancel()
}

// Close closes the wrapper its underlying reader. It will cause
// future calls to Read to return io.EOF.
func (p *cancelReadCloser) Close() error {
p.closeWithError(io.EOF)
return nil
}
22 changes: 2 additions & 20 deletions pkg/ioutils/readers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ package ioutils

import (
"fmt"
"io/ioutil"
"strings"
"testing"
"time"

"golang.org/x/net/context"
)

// Implement io.Reader
type errorReader struct{}

func (r *errorReader) Read(p []byte) (int, error) {
return 0, fmt.Errorf("Error reader always fail.")
return 0, fmt.Errorf("error reader always fail")
}

func TestReadCloserWrapperClose(t *testing.T) {
Expand All @@ -35,7 +31,7 @@ func TestReaderErrWrapperReadOnError(t *testing.T) {
called = true
})
_, err := wrapper.Read([]byte{})
if err == nil || !strings.Contains(err.Error(), "Error reader always fail.") {
if err == nil || !strings.Contains(err.Error(), "error reader always fail") {
t.Fatalf("readErrWrapper should returned an error")
}
if !called {
Expand Down Expand Up @@ -78,17 +74,3 @@ func (p *perpetualReader) Read(buf []byte) (n int, err error) {
}
return len(buf), nil
}

func TestCancelReadCloser(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond)
cancelReadCloser := NewCancelReadCloser(ctx, ioutil.NopCloser(&perpetualReader{}))
for {
var buf [128]byte
_, err := cancelReadCloser.Read(buf[:])
if err == context.DeadlineExceeded {
break
} else if err != nil {
t.Fatalf("got unexpected error: %v", err)
}
}
}
9 changes: 9 additions & 0 deletions vagrant/gccgo-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
additional=
for arg in "$@" ; do
if test -d "$arg"/github.com/containers/storage ; then
additional="$additional -I $arg/github.com/containers/storage/vendor"
fi
done
echo gccgo $additional "$@" > /tmp/gccgo
gccgo $additional "$@"
12 changes: 5 additions & 7 deletions vagrant/provision.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/bin/bash
set -xe

GO_VERSION=1.7.4

source /etc/os-release

case "${ID_LIKE:-${ID:-unknown}}" in
Expand All @@ -16,14 +14,13 @@ case "${ID_LIKE:-${ID:-unknown}}" in
apt-get -q -y install systemd curl
apt-get -q -y install apt make git btrfs-progs libdevmapper-dev
apt-get -q -y install zfs-dkms zfsutils-linux
curl -sSL https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz | tar -xvz -C /usr/local
modprobe aufs
modprobe zfs
apt-get -q -y install golang gccgo
;;
fedora)
dnf -y clean all
dnf -y install make git gcc btrfs-progs-devel device-mapper-devel
curl -sSL https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz | tar -xvz -C /usr/local
dnf -y install golang gcc-go
alternatives --set go /usr/lib/golang/bin/go
;;
unknown)
echo Unknown box OS, unsure of how to install required packages.
Expand All @@ -34,5 +31,6 @@ mkdir -p /go/src/github.com/containers
rm -f /go/src/github.com/containers/storage
ln -s /vagrant /go/src/github.com/containers/storage
export GOPATH=/go
export PATH=/usr/local/go/bin:/go/bin:${PATH}
export PATH=/go/bin:${PATH}
go get github.com/golang/lint/...
exit 0
2 changes: 2 additions & 0 deletions vagrant/runinvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ if ${IN_VAGRANT_MACHINE:-false} ; then
unset AUTO_GOPATH
export GOPATH=/go
export PATH=${GOPATH}/bin:/go/src/${PKG}/vendor/src/github.com/golang/lint/golint:${PATH}
sudo modprobe aufs || true
sudo modprobe zfs || true
"$@"
else
vagrant up --provider ${VAGRANT_PROVIDER}
Expand Down
156 changes: 0 additions & 156 deletions vendor/golang.org/x/net/context/context.go

This file was deleted.

Loading