From: Juha Hyttinen Date: Wed, 15 Apr 2020 10:45:51 +0000 (+0300) Subject: Initiate rmr_mbuf_t with payload len when sending message. X-Git-Tag: v0.4.8^0 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=1307b2d8d34f48bf44267efc2d1e607823c8d06d;p=ric-plt%2Fxapp-frame.git Initiate rmr_mbuf_t with payload len when sending message. Change-Id: Ifce378ba5603f534ae1428f32c93dc24d95ea0c9 Signed-off-by: Juha Hyttinen --- diff --git a/ci/Dockerfile b/ci/Dockerfile index 8303114..dd5f626 100755 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -17,7 +17,7 @@ # #---------------------------------------------------------- -FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:4-u18.04-nng as xapp-base +FROM nexus3.o-ran-sc.org:10004/bldr-ubuntu18-c-go:5-u18.04-nng as xapp-base RUN apt-get update -y \ &&apt-get install -y \ apt-utils \ @@ -35,7 +35,7 @@ RUN apt-get update -y \ RUN curl -s https://packagecloud.io/install/repositories/o-ran-sc/master/script.deb.sh | bash # RMR -ARG RMRVERSION=3.6.5 +ARG RMRVERSION=3.7.2 #RUN apt-get install -y rmr=${RMRVERSION} rmr-dev=${RMRVERSION} RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr_${RMRVERSION}_amd64.deb RUN wget --content-disposition https://packagecloud.io/o-ran-sc/staging/packages/debian/stretch/rmr-dev_${RMRVERSION}_amd64.deb/download.deb && dpkg -i rmr-dev_${RMRVERSION}_amd64.deb diff --git a/pkg/xapp/rmr.go b/pkg/xapp/rmr.go index 0aeced2..9a3116d 100755 --- a/pkg/xapp/rmr.go +++ b/pkg/xapp/rmr.go @@ -212,8 +212,8 @@ func (m *RMRClient) parseMessage(rxBuffer *C.rmr_mbuf_t) { } } -func (m *RMRClient) Allocate() *C.rmr_mbuf_t { - buf := C.rmr_alloc_msg(m.context, 0) +func (m *RMRClient) Allocate(size int) *C.rmr_mbuf_t { + buf := C.rmr_alloc_msg(m.context, C.int(size)) if buf == nil { Logger.Error("rmrClient: Allocating message buffer failed!") } @@ -236,20 +236,24 @@ func (m *RMRClient) SendRts(params *RMRParams) bool { } func (m *RMRClient) CopyBuffer(params *RMRParams) *C.rmr_mbuf_t { - txBuffer := params.Mbuf - if txBuffer == nil { - txBuffer = m.Allocate() - if txBuffer == nil { - return nil - } + if params.Mbuf != nil { + m.Free(params.Mbuf) + params.Mbuf = nil } - txBuffer.mtype = C.int(params.Mtype) - txBuffer.sub_id = C.int(params.SubId) - txBuffer.len = C.int(len(params.Payload)) + payLen := len(params.Payload) if params.PayloadLen != 0 { - txBuffer.len = C.int(params.PayloadLen) + payLen = params.PayloadLen + } + + txBuffer := m.Allocate(payLen) + if txBuffer == nil { + return nil } + txBuffer.mtype = C.int(params.Mtype) + txBuffer.sub_id = C.int(params.SubId) + txBuffer.len = C.int(payLen) + datap := C.CBytes(params.Payload) defer C.free(datap)