From d52c87dee3aac4af66ad2e1a86094ca27209d816 Mon Sep 17 00:00:00 2001
From: fujuntang <fujuntang@smartai.com>
Date: 星期二, 16 十一月 2021 16:19:45 +0800
Subject: [PATCH] Fix the service manager exits exceptionally issue.
---
api/bhsgo/bhome_node.go | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/api/bhsgo/bhome_node.go b/api/bhsgo/bhome_node.go
index 16a5349..7fcb43c 100644
--- a/api/bhsgo/bhome_node.go
+++ b/api/bhsgo/bhome_node.go
@@ -4,7 +4,7 @@
#include "../../src/bh_api.h"
*/
-// #cgo LDFLAGS: -L/usr/local/lib -lbhome_shmq -lstdc++ -lpthread -lrt
+// #cgo LDFLAGS: -L/usr/local/lib -lshm_queue -lstdc++ -lpthread -lrt
import "C"
import (
@@ -149,8 +149,11 @@
r := C.BHReadSub(&cpid, &cpid_len, &creply, &creply_len, C.int(timeout_ms)) > 0
defer C.BHFree(cpid, cpid_len)
defer C.BHFree(creply, creply_len)
- *proc_id = string(C.GoBytes(cpid, cpid_len))
- pub.Unmarshal(C.GoBytes(creply, creply_len))
+ if r {
+ *proc_id = string(C.GoBytes(cpid, cpid_len))
+ pub.Unmarshal(C.GoBytes(creply, creply_len))
+ }
+
return r
}
@@ -197,7 +200,7 @@
r := C.BHReadRequest(&cpid, &cpid_len, &creply, &creply_len, psrc, C.int(timeout_ms)) > 0
defer C.BHFree(cpid, cpid_len)
defer C.BHFree(creply, creply_len)
- if r {
+ if r {
*proc_id = string(C.GoBytes(cpid, cpid_len))
req.Unmarshal(C.GoBytes(creply, creply_len))
}
@@ -206,6 +209,7 @@
func SendReply(src unsafe.Pointer, rep *bh.MsgRequestTopicReply) bool {
data, _ := rep.Marshal()
+ defer C.BHFree(src, 0)
return C.BHSendReply(src, getPtr(&data), C.int(len(data))) > 0
}
--
Gitblit v1.8.0