Skip to content
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

fix: check errors before defering a close #200

Merged
merged 1 commit into from
Aug 5, 2021
Merged
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
7 changes: 5 additions & 2 deletions testplans/graphsync/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@ func runProvider(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitC
var svr *http.Server
if runHTTPTest {
if useLibP2p {
listener, _ := gostream.Listen(h, p2phttp.DefaultP2PProtocol)
listener, err := gostream.Listen(h, p2phttp.DefaultP2PProtocol)
if err != nil {
return err
}
defer listener.Close()
// start an http server on port 8080
runenv.RecordMessage("creating http server at libp2p://%s", h.ID().String())
Expand Down Expand Up @@ -538,10 +541,10 @@ func runProvider(ctx context.Context, runenv *runtime.RunEnv, initCtx *run.InitC
// set up http server to send file
http.HandleFunc(fmt.Sprintf("/%s", node.Cid()), func(w http.ResponseWriter, r *http.Request) {
fileReader, err := os.Open(file.Name())
defer func() { _ = fileReader.Close() }()
if err != nil {
panic(err)
}
defer fileReader.Close()
_, err = io.Copy(w, fileReader)
if err != nil {
panic(err)
Expand Down