mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
rclone: Better field names for stdio conn
This commit is contained in:
parent
3cd927d180
commit
01b9581453
@ -88,8 +88,8 @@ func run(command string, args ...string) (*StdioConn, *exec.Cmd, *sync.WaitGroup
|
||||
}
|
||||
|
||||
c := &StdioConn{
|
||||
stdin: stdout,
|
||||
stdout: stdin,
|
||||
receive: stdout,
|
||||
send: stdin,
|
||||
cmd: cmd,
|
||||
}
|
||||
|
||||
|
@ -12,28 +12,28 @@ import (
|
||||
|
||||
// StdioConn implements a net.Conn via stdin/stdout.
|
||||
type StdioConn struct {
|
||||
stdin *os.File
|
||||
stdout *os.File
|
||||
receive *os.File
|
||||
send *os.File
|
||||
cmd *exec.Cmd
|
||||
closeIn sync.Once
|
||||
closeOut sync.Once
|
||||
closeRecv sync.Once
|
||||
closeSend sync.Once
|
||||
}
|
||||
|
||||
func (s *StdioConn) Read(p []byte) (int, error) {
|
||||
n, err := s.stdin.Read(p)
|
||||
n, err := s.receive.Read(p)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (s *StdioConn) Write(p []byte) (int, error) {
|
||||
n, err := s.stdout.Write(p)
|
||||
n, err := s.send.Write(p)
|
||||
return n, err
|
||||
}
|
||||
|
||||
// Close closes the stream to the child process.
|
||||
func (s *StdioConn) Close() (err error) {
|
||||
s.closeOut.Do(func() {
|
||||
s.closeSend.Do(func() {
|
||||
debug.Log("close stdio send connection")
|
||||
err = s.stdout.Close()
|
||||
err = s.send.Close()
|
||||
})
|
||||
|
||||
return err
|
||||
@ -43,9 +43,9 @@ func (s *StdioConn) Close() (err error) {
|
||||
func (s *StdioConn) CloseAll() (err error) {
|
||||
err = s.Close()
|
||||
|
||||
s.closeIn.Do(func() {
|
||||
s.closeRecv.Do(func() {
|
||||
debug.Log("close stdio receive connection")
|
||||
err2 := s.stdin.Close()
|
||||
err2 := s.receive.Close()
|
||||
if err == nil {
|
||||
err = err2
|
||||
}
|
||||
@ -66,8 +66,8 @@ func (s *StdioConn) RemoteAddr() net.Addr {
|
||||
|
||||
// SetDeadline sets the read/write deadline.
|
||||
func (s *StdioConn) SetDeadline(t time.Time) error {
|
||||
err1 := s.stdin.SetReadDeadline(t)
|
||||
err2 := s.stdout.SetWriteDeadline(t)
|
||||
err1 := s.receive.SetReadDeadline(t)
|
||||
err2 := s.send.SetWriteDeadline(t)
|
||||
if err1 != nil {
|
||||
return err1
|
||||
}
|
||||
@ -76,12 +76,12 @@ func (s *StdioConn) SetDeadline(t time.Time) error {
|
||||
|
||||
// SetReadDeadline sets the read/write deadline.
|
||||
func (s *StdioConn) SetReadDeadline(t time.Time) error {
|
||||
return s.stdin.SetReadDeadline(t)
|
||||
return s.receive.SetReadDeadline(t)
|
||||
}
|
||||
|
||||
// SetWriteDeadline sets the read/write deadline.
|
||||
func (s *StdioConn) SetWriteDeadline(t time.Time) error {
|
||||
return s.stdout.SetWriteDeadline(t)
|
||||
return s.send.SetWriteDeadline(t)
|
||||
}
|
||||
|
||||
// make sure StdioConn implements net.Conn
|
||||
|
Loading…
Reference in New Issue
Block a user