X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=E2Manager%2FrmrCgo%2FrmrCgoApi.go;h=308ab635ac94c0c17115c139de1995d25235c13c;hb=refs%2Fchanges%2F57%2F2157%2F1;hp=f65d10dfbfae1470daf31ceb66091a9c9e44faa9;hpb=372a275602ae05da22130a4601709291c7fbbaa6;p=ric-plt%2Fe2mgr.git diff --git a/E2Manager/rmrCgo/rmrCgoApi.go b/E2Manager/rmrCgo/rmrCgoApi.go index f65d10d..308ab63 100644 --- a/E2Manager/rmrCgo/rmrCgoApi.go +++ b/E2Manager/rmrCgo/rmrCgoApi.go @@ -61,7 +61,6 @@ func (ctx *Context) SendMsg(msg *MBuf, printLogs bool) (*MBuf, error) { ctx.checkContextInitialized() ctx.Logger.Debugf("#rmrCgoApi.SendMsg - Going to send message. MBuf: %v", *msg) allocatedCMBuf := ctx.getAllocatedCRmrMBuf(ctx.Logger, msg, ctx.MaxMsgSize) - defer C.rmr_free_msg(allocatedCMBuf) state := allocatedCMBuf.state if state != RMR_OK { errorMessage := fmt.Sprintf("#rmrCgoApi.SendMsg - Failed to get allocated message. state: %v - %s", state, states[int(state)]) @@ -76,6 +75,8 @@ func (ctx *Context) SendMsg(msg *MBuf, printLogs bool) (*MBuf, error) { } currCMBuf := C.rmr_send_msg(ctx.RmrCtx, allocatedCMBuf) + defer C.rmr_free_msg(currCMBuf) + state = currCMBuf.state if state != RMR_OK { @@ -90,9 +91,10 @@ func (ctx *Context) RecvMsg() (*MBuf, error) { ctx.checkContextInitialized() ctx.Logger.Debugf("#rmrCgoApi.RecvMsg - Going to receive message") allocatedCMBuf := C.rmr_alloc_msg(ctx.RmrCtx, C.int(ctx.MaxMsgSize)) - defer C.rmr_free_msg(allocatedCMBuf) currCMBuf := C.rmr_rcv_msg(ctx.RmrCtx, allocatedCMBuf) + defer C.rmr_free_msg(currCMBuf) + state := currCMBuf.state if state != RMR_OK { @@ -121,4 +123,4 @@ func (ctx *Context) Close() { ctx.Logger.Debugf("#rmrCgoApi.Close - Going to close RMR context") C.rmr_close(ctx.RmrCtx) time.Sleep(100 * time.Millisecond) -} +} \ No newline at end of file