add(pipe.go): pipe.Finish to call underlying send.Finish #33
@@ -77,7 +77,7 @@ func send(e *iroh.Endpoint, id string) {
|
||||
}
|
||||
|
||||
// mark send stream as done
|
||||
stream.Send().Finish()
|
||||
p.Finish()
|
||||
exit(conn)
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ type Pipe struct {
|
||||
recv *RecvStream
|
||||
send *SendStream
|
||||
totalBytesRead int
|
||||
finished bool
|
||||
}
|
||||
|
||||
func NewPipe(stream *BiStream) *Pipe {
|
||||
@@ -56,6 +57,10 @@ func (p *Pipe) Read(buf []byte) (int, error) {
|
||||
}
|
||||
|
||||
func (p *Pipe) Write(buf []byte) (int, error) {
|
||||
if p.finished {
|
||||
return 0, errors.New("Pipe.Write: Write called after Finish()")
|
||||
}
|
||||
|
||||
n64, err := p.send.Write(buf)
|
||||
n := int(n64)
|
||||
|
||||
@@ -65,3 +70,8 @@ func (p *Pipe) Write(buf []byte) (int, error) {
|
||||
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (p *Pipe) Finish() error {
|
||||
p.finished = true
|
||||
return p.send.Finish()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user