From a070b0de9f9e9cbca150eea4eda74757ca588bed Mon Sep 17 00:00:00 2001 From: Jordan Augé Date: Wed, 23 Sep 2020 17:50:52 +0200 Subject: [HICN-645] Control plane (WIP) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4be6a40b690b62f22f57de6d8c10b01a1be42a6d Signed-off-by: Jordan Augé Signed-off-by: Enrico Loparco (eloparco) Signed-off-by: Mauro Sardara --- hicn-light/src/hicn/core/msgbuf_pool.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'hicn-light/src/hicn/core/msgbuf_pool.c') diff --git a/hicn-light/src/hicn/core/msgbuf_pool.c b/hicn-light/src/hicn/core/msgbuf_pool.c index 597123a7a..137d9bb99 100644 --- a/hicn-light/src/hicn/core/msgbuf_pool.c +++ b/hicn-light/src/hicn/core/msgbuf_pool.c @@ -43,11 +43,10 @@ msgbuf_pool_free(msgbuf_pool_t * msgbuf_pool) free(msgbuf_pool); } -int -msgbuf_pool_get(msgbuf_pool_t * msgbuf_pool, msgbuf_t * msgbuf) +off_t +msgbuf_pool_get(msgbuf_pool_t * msgbuf_pool, msgbuf_t ** msgbuf) { - pool_get(msgbuf_pool->buffers, msgbuf); - return 0; + return pool_get(msgbuf_pool->buffers, *msgbuf); } void @@ -60,15 +59,16 @@ int msgbuf_pool_getn(msgbuf_pool_t * msgbuf_pool, msgbuf_t ** msgbuf, size_t n) { for (unsigned i = 0; i < n; i++) { - if (!msgbuf_pool_get(msgbuf_pool, msgbuf[i])) { + // If not able to get the msgbuf + if (msgbuf_pool_get(msgbuf_pool, &msgbuf[i]) < 0) { + // Release all the msgbufs retrieved so far for (unsigned j = 0; j < i; j++) { msgbuf_pool_put(msgbuf_pool, msgbuf[j]); - return 0; } - break; + return -1; } } - return -1; + return 0; } off_t -- cgit 1.2.3-korg