Initiate rmr_mbuf_t with payload len when sending message. 74/3274/1 v0.4.8
authorJuha Hyttinen <juha.hyttinen@nokia.com>
Wed, 15 Apr 2020 10:45:51 +0000 (13:45 +0300)
committerJuha Hyttinen <juha.hyttinen@nokia.com>
Wed, 15 Apr 2020 10:46:30 +0000 (13:46 +0300)
Change-Id: Ifce378ba5603f534ae1428f32c93dc24d95ea0c9
Signed-off-by: Juha Hyttinen <juha.hyttinen@nokia.com>
ci/Dockerfile
pkg/xapp/rmr.go

index 8303114..dd5f626 100755 (executable)
@@ -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
index 0aeced2..9a3116d 100755 (executable)
@@ -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)