aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-12 10:15:23 +0100
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-12-12 10:15:23 +0100
commit273743466fa39a14bf7abf73f30427406684f3d3 (patch)
treedfdc7f8bcaddcaf69534f4b16052944767a7feb5
parent752d0492fa653f8485f38b9f6d9a60a3145fd119 (diff)
Fixed crash on xds-agent or server disconnection (IOT-108)
-rw-r--r--gdb-xds.go24
-rw-r--r--main.go10
2 files changed, 32 insertions, 2 deletions
diff --git a/gdb-xds.go b/gdb-xds.go
index 406e4c6..15f8b6d 100644
--- a/gdb-xds.go
+++ b/gdb-xds.go
@@ -255,6 +255,25 @@ func (g *GdbXds) Init() (int, error) {
}
})
+ // Monitor XDS server configuration changes (and specifically connected status)
+ iosk.On(xaapiv1.EVTServerConfig, func(ev xaapiv1.EventMsg) {
+ svrCfg, err := ev.DecodeServerCfg()
+ if err == nil && !svrCfg.Connected {
+ // TODO: should wait that server will be connected back
+ if g.cbOnExit != nil {
+ g.cbOnExit(-1, fmt.Errorf("XDS Server disconnected"))
+ } else {
+ fmt.Printf("XDS Server disconnected")
+ os.Exit(-1)
+ }
+ }
+ })
+
+ args := xaapiv1.EventRegisterArgs{Name: xaapiv1.EVTServerConfig}
+ if err := g.httpCli.Post("/events/register", args, nil); err != nil {
+ return 0, err
+ }
+
return 0, nil
}
@@ -304,6 +323,11 @@ func (g *GdbXds) Start(inferiorTTY bool) (int, error) {
// except if XDS_GDBSERVER_OUTPUT_NOFIX is defined
_, gdbserverNoFix := os.LookupEnv("XDS_GDBSERVER_OUTPUT_NOFIX")
+ // SDK ID must be set else $GDB cannot be resolved
+ if g.sdkID == "" {
+ return int(syscall.EINVAL), fmt.Errorf("sdkid must be set")
+ }
+
args := xaapiv1.ExecArgs{
ID: g.prjID,
SdkID: g.sdkID,
diff --git a/main.go b/main.go
index 3df9e1a..f7db365 100644
--- a/main.go
+++ b/main.go
@@ -340,7 +340,13 @@ endloop:
})
gdb.OnDisconnect(func(err error) {
- fmt.Println("Disconnection: ", err.Error())
+ errMsg := "\nXDS-Agent disconnected"
+ if err != nil {
+ fmt.Printf("%s: %v\n", errMsg, err.Error())
+ } else {
+ fmt.Println(errMsg)
+ }
+
exitChan <- exitResult{err, int(syscall.ESHUTDOWN)}
})
@@ -461,8 +467,8 @@ endloop:
time.Sleep(time.Millisecond * 200)
}
- gdb.Write(command + "\n")
log.Debugf("Send: <%v>", command)
+ gdb.Write(command + "\n")
}
log.Infof("Stdin scanner exit, close stdin (err=%v)", sc.Err())