Skip to content

Commit

Permalink
p2p/sim: handle error when socket buffer size update fails
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Nov 13, 2017
1 parent 1bf1ea0 commit 3a74282
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions p2p/simulations/adapters/inproc.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,24 +370,32 @@ func socketPipe() (net.Conn, net.Conn, error) {
return nil, nil, err
}

setSocketBuffer(pipe1)
setSocketBuffer(pipe2)
err = setSocketBuffer(pipe1)
if err != nil {
return nil, nil, err
}

err = setSocketBuffer(pipe2)
if err != nil {
return nil, nil, err
}

return pipe1, pipe2, nil
}

func setSocketBuffer(conn net.Conn) {
func setSocketBuffer(conn net.Conn) error {
switch v := conn.(type) {
case *net.UnixConn:
err := v.SetReadBuffer(socketReadBuffer)
if err != nil {
panic(err)
return err
}
err = v.SetWriteBuffer(socketWriteBuffer)
if err != nil {
panic(err)
return err
}
}
return nil
}

// netPipe wraps net.Pipe in a signature returning an error
Expand Down

0 comments on commit 3a74282

Please sign in to comment.