Skip to content

Commit 0f910d5

Browse files
committed
Removed spinlocks
1 parent fd4a0f5 commit 0f910d5

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

cp.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func TarFromSource(api *ScalewayAPI, source string) (*io.ReadCloser, error) {
8080
if err != nil {
8181
return nil, err
8282
}
83-
defer tarOutputStream.Close()
8483

8584
tarErrorStream, err := spawnSrc.StderrPipe()
8685
if err != nil {
@@ -102,7 +101,6 @@ func TarFromSource(api *ScalewayAPI, source string) (*io.ReadCloser, error) {
102101
if source == "-" {
103102
log.Debugf("Streaming tarball from stdin")
104103
tarOutputStream = os.Stdin
105-
defer tarOutputStream.Close()
106104
return &tarOutputStream, nil
107105
}
108106

@@ -127,7 +125,6 @@ func TarFromSource(api *ScalewayAPI, source string) (*io.ReadCloser, error) {
127125
if err != nil {
128126
return nil, err
129127
}
130-
defer tarOutputStream.Close()
131128
return &tarOutputStream, nil
132129
}
133130

@@ -167,27 +164,15 @@ func UntarToDest(api *ScalewayAPI, sourceStream *io.ReadCloser, destination stri
167164
}
168165
defer untarInputStream.Close()
169166

170-
untarErrorStream, err := spawnDst.StderrPipe()
171-
if err != nil {
172-
return err
173-
}
174-
defer untarErrorStream.Close()
175-
176-
untarOutputStream, err := spawnDst.StdoutPipe()
177-
if err != nil {
178-
return err
179-
}
180-
defer untarOutputStream.Close()
167+
// spawnDst.Stderr = os.Stderr
168+
// spawnDst.Stdout = os.Stdout
181169

182170
err = spawnDst.Start()
183171
if err != nil {
184172
return err
185173
}
186-
defer spawnDst.Wait()
187174

188-
io.Copy(untarInputStream, *sourceStream)
189-
io.Copy(os.Stderr, untarErrorStream)
190-
_, err = io.Copy(os.Stdout, untarOutputStream)
175+
_, err = io.Copy(untarInputStream, *sourceStream)
191176
return err
192177
}
193178

@@ -223,6 +208,6 @@ func runCp(cmd *Command, args []string) {
223208

224209
err = UntarToDest(cmd.API, sourceStream, args[1])
225210
if err != nil {
226-
log.Fatalf("Cannot untar to destionation '%s': %v", args[1], err)
211+
log.Fatalf("Cannot untar to destination '%s': %v", args[1], err)
227212
}
228213
}

0 commit comments

Comments
 (0)