Code Review
/
src
/
xds
/
xds-server.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
review
|
tree
raw
|
patch
|
inline
| side by side (from parent 1:
985b32b
)
Always close gdb pty/tty even if an error rises.
author
Sebastien Douheret
<sebastien.douheret@iot.bzh>
Tue, 21 Nov 2017 14:24:45 +0000
(15:24 +0100)
committer
Sebastien Douheret
<sebastien.douheret@iot.bzh>
Tue, 21 Nov 2017 14:24:45 +0000
(15:24 +0100)
lib/apiv1/exec.go
patch
|
blob
|
history
diff --git
a/lib/apiv1/exec.go
b/lib/apiv1/exec.go
index
30444c1
..
2adb473
100644
(file)
--- a/
lib/apiv1/exec.go
+++ b/
lib/apiv1/exec.go
@@
-299,6
+299,16
@@
func (s *APIService) execCmd(c *gin.Context) {
execWS.ExitCB = func(e *eows.ExecOverWS, code int, err error) {
s.log.Debugf("Command [Cmd ID %s] exited: code %d, error: %v", e.CmdID, code, err)
execWS.ExitCB = func(e *eows.ExecOverWS, code int, err error) {
s.log.Debugf("Command [Cmd ID %s] exited: code %d, error: %v", e.CmdID, code, err)
+ // Close client tty
+ defer func() {
+ if gdbPty != nil {
+ gdbPty.Close()
+ }
+ if gdbTty != nil {
+ gdbTty.Close()
+ }
+ }()
+
// IO socket can be nil when disconnected
so := s.sessions.IOSocketGet(e.Sid)
if so == nil {
// IO socket can be nil when disconnected
so := s.sessions.IOSocketGet(e.Sid)
if so == nil {
@@
-331,14
+341,6
@@
func (s *APIService) execCmd(c *gin.Context) {
}
}
}
}
- // Close client tty
- if gdbPty != nil {
- gdbPty.Close()
- }
- if gdbTty != nil {
- gdbTty.Close()
- }
-
// FIXME replace by .BroadcastTo a room
errSoEmit := (*so).Emit(ExecExitEvent, ExecExitMsg{
CmdID: e.CmdID,
// FIXME replace by .BroadcastTo a room
errSoEmit := (*so).Emit(ExecExitEvent, ExecExitMsg{
CmdID: e.CmdID,