Commit Graph

14 Commits

Author SHA1 Message Date
haoyun
bbe46b8c43 feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
2022-01-07 10:27:03 +08:00
Sebastiaan van Stijn
7a468a3f3f
cio.copyIO: refactor to use cio.Close() (windows)
Use the existing `.Close()` method instead of implementing the same
logic in this function.

The defer sets `cios` to `nil` if an error occurred to preserve the
existing behavior.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-01 11:22:08 +01:00
Sebastiaan van Stijn
219fa3d0a5
cio.copyIO: fix pipes potentially not being closed (Windows)
The defer functions were checking the local variable, and would therefore
not be executed, as the function returned if an error occurred.

Perhaps best illustrated when renaming the local variables;

    if fifos.Stdin != "" {
        l, err1 := winio.ListenPipe(fifos.Stdin, nil)
        if err1 != nil {
            return nil, errors.Wrapf(err1, "failed to create stdin pipe %s", fifos.Stdin)
        }
        defer func(l net.Listener) {
            if err1 != nil {
                l.Close()
            }
        }(l)
        // ...
    }

    if fifos.Stdout != "" {
        l, err2 := winio.ListenPipe(fifos.Stdout, nil)
        if err2 != nil {
            return nil, errors.Wrapf(err2, "failed to create stdout pipe %s", fifos.Stdout)
        }
        defer func(l net.Listener) {
            if err2 != nil {
                l.Close()
            }
        }(l)
        // ....
    }

This patch changes the function to use a named return variable, and to use
a single `defer()` that closes all pipes.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-02-01 11:19:50 +01:00
Justin Terry (VM)
277147135d Fix issue with NewFIFOSetInDir with Terminal true
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-02-28 10:35:26 -08:00
John Howard
90caf6f6a7 Windows:NewDirectIOFromFIFOSet
Signed-off-by: John Howard <jhoward@microsoft.com>
2019-01-15 10:04:43 -08:00
Michael Crosby
07e2b63d69 Send stderr on windows Terminal
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-22 13:34:08 -04:00
Justin Terry (VM)
019b0c34de Introduce containerd-shim-runhcs-v1 on Windows
Implements the containerd-shim-runhcs-v1 shim on Windows for the runtime
v2 shim API.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-22 08:15:43 -07:00
Justin Terry (VM)
6a252a7141 IO Windows remove unused wait group
Removes an unused and unneeded wait group.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-01 09:54:31 -07:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Stephen J Day
cd72819b53
archive, cio, cmd, linux: use buffer pools
To avoid buffer bloat in long running processes, we try to use buffer
pools where possible. This is meant to address shim memory usage issues,
but may not be the root cause.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-01-22 13:52:06 -08:00
Daniel Nephin
7d4337e738 Reduce the number of IO constructors
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-12-11 15:07:09 -05:00
Daniel Nephin
3146019918 Refactor cio.DirectIO
New code duplication
Better re-use from consumers of the cio package

TODO: io_windows.go

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-12-08 14:26:10 -05:00
Daniel Nephin
f79ec5b55f Cleanup cio.FIFOSet interface
Remove duplication with cio.Config
unexport newFIFOSetTempDir() since it includes hardcoded paths
Expose os.RemoveAll() as part of FIFOSet instead of a Dir

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-12-08 14:26:10 -05:00
Daniel Nephin
298dabc6c2 Move io.go into cio package
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-17 17:04:45 -05:00