mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-30 15:15:07 +03:00
simplify writeMsg slightly
This commit is contained in:
parent
58c97df6a0
commit
807c12453c
2 changed files with 5 additions and 6 deletions
2
go.mod
2
go.mod
|
@ -17,3 +17,5 @@ require (
|
||||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
|
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a
|
||||||
golang.org/x/text v0.3.2
|
golang.org/x/text v0.3.2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
go 1.13
|
||||||
|
|
|
@ -38,12 +38,9 @@ func (s *stream) init(rwc io.ReadWriteCloser) {
|
||||||
func (s *stream) writeMsg(bs []byte) (int, error) {
|
func (s *stream) writeMsg(bs []byte) (int, error) {
|
||||||
s.outputBuffer.Write(streamMsg[:])
|
s.outputBuffer.Write(streamMsg[:])
|
||||||
s.outputBuffer.Write(wire_encode_uint64(uint64(len(bs))))
|
s.outputBuffer.Write(wire_encode_uint64(uint64(len(bs))))
|
||||||
n, err := s.outputBuffer.Write(bs)
|
s.outputBuffer.Write(bs)
|
||||||
err2 := s.outputBuffer.Flush()
|
s.outputBuffer.Flush() // TODO? delay flushing until we're idle
|
||||||
if err == nil {
|
return len(bs), nil // TODO? return an error? its not like we check for it...
|
||||||
err = err2
|
|
||||||
}
|
|
||||||
return n, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// readMsg reads a message from the stream, accounting for stream padding, and is *not* thread safe.
|
// readMsg reads a message from the stream, accounting for stream padding, and is *not* thread safe.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue