You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2017/08/24 01:15:28 UTC

[mynewt-newtmgr] 02/03: nmxact - Minor comment changes.

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git

commit 3f8b260bcfe8490897a44137d151ad0100425e9b
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Wed Aug 23 18:13:06 2017 -0700

    nmxact - Minor comment changes.
---
 nmxact/nmble/conn.go   | 11 +++++++----
 nmxact/nmble/listen.go |  4 ++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/nmxact/nmble/conn.go b/nmxact/nmble/conn.go
index e82b35e..f76907a 100644
--- a/nmxact/nmble/conn.go
+++ b/nmxact/nmble/conn.go
@@ -75,8 +75,9 @@ func (c *Conn) DisconnectChan() <-chan error {
 }
 
 func (c *Conn) abortNotifyListeners(err error) {
-	// No need to lock mutex; this should only be called after all go routines
-	// have terminated.
+	c.mtx.Lock()
+	defer c.mtx.Unlock()
+
 	for _, nl := range c.notifyMap {
 		nl.ErrChan <- err
 		close(nl.NotifyChan)
@@ -378,6 +379,7 @@ func (c *Conn) Connect(bx *BleXport, ownAddrType BleAddrType, peer BleDev,
 	return nil
 }
 
+// Opens the session for an already-established BLE connection.
 func (c *Conn) Inherit(connHandle uint16, bl *Listener) error {
 	if err := c.startConnecting(); err != nil {
 		return err
@@ -546,13 +548,14 @@ func (c *Conn) Profile() *Profile {
 	return &c.profile
 }
 
+// Indicates whether an error reported during MTU exchange is a "real" error or
+// not.  If the error was reported because MTU exchange already took place,
+// that isn't considered a real error.
 func isExchangeMtuError(err error) bool {
 	if err == nil {
 		return false
 	}
 
-	// If the operation failed because the peer already initiated the
-	// exchange, just pretend it was successful.
 	bhe := nmxutil.ToBleHost(err)
 	if bhe == nil {
 		return true
diff --git a/nmxact/nmble/listen.go b/nmxact/nmble/listen.go
index 19a1f2a..fe8ee61 100644
--- a/nmxact/nmble/listen.go
+++ b/nmxact/nmble/listen.go
@@ -81,8 +81,8 @@ func (bl *Listener) AfterTimeout(tmo time.Duration) <-chan time.Time {
 func (bl *Listener) Close() {
 	// This provokes a race condition.  The timer may get initialized at any
 	// time.
-	if bl.timer != nil {
-		bl.timer.Stop()
+	if t := bl.timer; t != nil {
+		nmxutil.StopAndDrainTimer(t)
 	}
 
 	// Mark the command as acked in case the race condition mentioned above

-- 
To stop receiving notification emails like this one, please contact
"commits@mynewt.apache.org" <co...@mynewt.apache.org>.