You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/02/01 01:01:38 UTC
[GitHub] vrahane commented on a change in pull request #65: Fix null pointer dereference
vrahane commented on a change in pull request #65: Fix null pointer dereference
URL: https://github.com/apache/mynewt-newtmgr/pull/65#discussion_r165234465
##########
File path: newtmgr/bll/bll_sesn.go
##########
@@ -67,22 +67,39 @@ func NewBllSesn(cfg BllSesnCfg) *BllSesn {
}
}
+func (s *BllSesn) getCln() (ble.Client, error) {
+ s.mtx.Lock()
+ defer s.mtx.Unlock()
+
+ if s.cln == nil {
+ return nil, fmt.Errorf("disconnected")
+ }
+
+ return s.cln, nil
+}
+
+func (s *BllSesn) setCln(c ble.Client) {
+ s.mtx.Lock()
+ defer s.mtx.Unlock()
+
+ s.cln = c
+}
+
func (s *BllSesn) listenDisconnect() {
go func() {
- <-s.cln.Disconnected()
+ cln, err := s.getCln()
+ if err != nil {
+ return
+ }
- s.mtx.Lock()
+ <-cln.Disconnected()
s.txvr.ErrorAll(fmt.Errorf("disconnected"))
s.txvr.Stop()
- s.cln = nil
- s.mtx.Unlock()
+ s.setCln(nil)
}()
}
func (s *BllSesn) txConnect(f ble.AdvFilter) (ble.Client, error) {
- s.mtx.Lock()
- defer s.mtx.Unlock()
-
ctx := ble.WithSigHandler(context.WithTimeout(context.Background(),
Review comment:
Should this be added here:
```
cln, err := s.getCln()
if err != nil {
return nil, err
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services