Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
K
koko
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
koko
Commits
b1bafab3
Commit
b1bafab3
authored
Nov 04, 2019
by
Eric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] fix unclosed fd
parent
ce9add91
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
0 deletions
+27
-0
client.go
pkg/common/client.go
+1
-0
utils.go
pkg/common/utils.go
+2
-0
session.go
pkg/handler/session.go
+12
-0
wrappersession.go
pkg/handler/wrappersession.go
+12
-0
No files found.
pkg/common/client.go
View file @
b1bafab3
...
...
@@ -238,6 +238,7 @@ func (c *Client) UploadFile(url string, gFile string, res interface{}, params ..
if
err
!=
nil
{
return
err
}
defer
f
.
Close
()
buf
:=
new
(
bytes
.
Buffer
)
bodyWriter
:=
multipart
.
NewWriter
(
buf
)
gName
:=
filepath
.
Base
(
gFile
)
...
...
pkg/common/utils.go
View file @
b1bafab3
...
...
@@ -28,10 +28,12 @@ func GzipCompressFile(srcPath, dstPath string) error {
if
err
!=
nil
{
return
err
}
defer
sf
.
Close
()
df
,
err
:=
os
.
Create
(
dstPath
)
if
err
!=
nil
{
return
err
}
defer
df
.
Close
()
writer
:=
gzip
.
NewWriter
(
df
)
writer
.
Name
=
dstPath
writer
.
ModTime
=
time
.
Now
()
.
UTC
()
...
...
pkg/handler/session.go
View file @
b1bafab3
...
...
@@ -129,10 +129,22 @@ func (h *interactiveHandler) watchWinSizeChange() {
}
func
(
h
*
interactiveHandler
)
pauseWatchWinSize
()
{
select
{
case
<-
h
.
sess
.
Sess
.
Context
()
.
Done
()
:
return
default
:
}
h
.
winWatchChan
<-
false
}
func
(
h
*
interactiveHandler
)
resumeWatchWinSize
()
{
select
{
case
<-
h
.
sess
.
Sess
.
Context
()
.
Done
()
:
return
default
:
}
h
.
winWatchChan
<-
true
}
...
...
pkg/handler/wrappersession.go
View file @
b1bafab3
...
...
@@ -15,10 +15,13 @@ type WrapperSession struct {
inWriter
io
.
WriteCloser
outReader
io
.
ReadCloser
mux
*
sync
.
RWMutex
closed
chan
struct
{}
}
func
(
w
*
WrapperSession
)
initial
()
{
w
.
initReadPip
()
w
.
closed
=
make
(
chan
struct
{})
go
w
.
readLoop
()
}
...
...
@@ -37,11 +40,20 @@ func (w *WrapperSession) readLoop() {
break
}
}
w
.
mux
.
RLock
()
_
=
w
.
inWriter
.
Close
()
_
=
w
.
outReader
.
Close
()
w
.
mux
.
RUnlock
()
close
(
w
.
closed
)
}
func
(
w
*
WrapperSession
)
Read
(
p
[]
byte
)
(
int
,
error
)
{
select
{
case
<-
w
.
closed
:
return
0
,
io
.
EOF
default
:
}
w
.
mux
.
RLock
()
defer
w
.
mux
.
RUnlock
()
return
w
.
outReader
.
Read
(
p
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment