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 2016/09/30 21:06:19 UTC
[2/3] incubator-mynewt-newt git commit: Adding missing connection
close calls
Adding missing connection close calls
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/6c88f4ea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/6c88f4ea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/6c88f4ea
Branch: refs/heads/develop
Commit: 6c88f4ea1736b615b392c632de8a8c1cef25578f
Parents: 791640d
Author: admin <vr...@gmail.com>
Authored: Fri Sep 30 12:03:33 2016 -0700
Committer: admin <vr...@gmail.com>
Committed: Fri Sep 30 14:01:39 2016 -0700
----------------------------------------------------------------------
newtmgr/cli/image.go | 7 +++++++
newtmgr/cli/split.go | 1 +
newtmgr/protocol/cmdrunner.go | 12 ++++++------
3 files changed, 14 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/6c88f4ea/newtmgr/cli/image.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go
index 04ee6df..453f4ce 100644
--- a/newtmgr/cli/image.go
+++ b/newtmgr/cli/image.go
@@ -49,6 +49,7 @@ func imageListCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
imageList, err := protocol.NewImageList2()
if err != nil {
@@ -223,6 +224,7 @@ func imageBootCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
imageBoot, err := protocol.NewImageBoot2()
if err != nil {
@@ -277,6 +279,7 @@ func fileUploadCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
err = echoCtrl(runner, "0")
if err != nil {
@@ -348,6 +351,7 @@ func fileDownloadCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
var currOff uint32 = 0
var cnt int = 0
@@ -431,6 +435,7 @@ func coreDownloadCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
tmpName := args[0] + ".tmp"
file, err := os.OpenFile(tmpName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0660)
@@ -483,6 +488,7 @@ func coreListCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
coreList, err := protocol.NewCoreList()
if err != nil {
@@ -521,6 +527,7 @@ func coreEraseCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
coreErase, err := protocol.NewCoreErase()
if err != nil {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/6c88f4ea/newtmgr/cli/split.go
----------------------------------------------------------------------
diff --git a/newtmgr/cli/split.go b/newtmgr/cli/split.go
index a8c77a5..bd16a52 100644
--- a/newtmgr/cli/split.go
+++ b/newtmgr/cli/split.go
@@ -32,6 +32,7 @@ func splitStatusCmd(cmd *cobra.Command, args []string) {
if err != nil {
nmUsage(cmd, err)
}
+ defer runner.Conn.Close()
split, err := protocol.NewSplit()
if err != nil {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/6c88f4ea/newtmgr/protocol/cmdrunner.go
----------------------------------------------------------------------
diff --git a/newtmgr/protocol/cmdrunner.go b/newtmgr/protocol/cmdrunner.go
index 4670086..cbb8427 100644
--- a/newtmgr/protocol/cmdrunner.go
+++ b/newtmgr/protocol/cmdrunner.go
@@ -32,7 +32,7 @@ type CmdRunner struct {
}
func (cr *CmdRunner) ReadResp() (*NmgrReq, error) {
- var nmr NmgrReq
+ var nmr NmgrReq
for {
pkt, err := cr.Conn.ReadPacket()
if err != nil {
@@ -47,12 +47,12 @@ func (cr *CmdRunner) ReadResp() (*NmgrReq, error) {
return nil, err
}
if nmrfrag.Op == NMGR_OP_READ_RSP || nmrfrag.Op == NMGR_OP_WRITE_RSP {
- nmr.Data = append(nmr.Data, nmrfrag.Data...)
- nmr.Len += nmrfrag.Len
- if nmrfrag.Flags & NMGR_F_JSON_RSP_COMPLETE == NMGR_F_JSON_RSP_COMPLETE {
+ nmr.Data = append(nmr.Data, nmrfrag.Data...)
+ nmr.Len += nmrfrag.Len
+ if nmrfrag.Flags&NMGR_F_JSON_RSP_COMPLETE == NMGR_F_JSON_RSP_COMPLETE {
return &nmr, nil
- }
- }
+ }
+ }
}
}