DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xueming Li <xuemingl@mellanox.com>
To: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Cc: Xueming Li <xuemingl@mellanox.com>, dev@dpdk.org
Subject: [dpdk-dev] [PATCH] examples/simple_mp: fix received message length
Date: Thu, 26 Oct 2017 16:29:23 +0800	[thread overview]
Message-ID: <1509006563-52179-1-git-send-email-xuemingl@mellanox.com> (raw)

Simple_mp example receives message size less than 64 chars while send
side accepts chars less than 128, this leads to different result when
sending text lenght larger than 64.
This patch uses same buffer length on both message pool and command
line.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 examples/multi_process/simple_mp/main.c        | 4 ++--
 examples/multi_process/simple_mp/mp_commands.c | 2 +-
 examples/multi_process/simple_mp/mp_commands.h | 1 -
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/examples/multi_process/simple_mp/main.c b/examples/multi_process/simple_mp/main.c
index 2843d94..53b87c5 100644
--- a/examples/multi_process/simple_mp/main.c
+++ b/examples/multi_process/simple_mp/main.c
@@ -67,6 +67,7 @@
 #include <rte_mempool.h>
 #include <cmdline_rdline.h>
 #include <cmdline_parse.h>
+#include <cmdline_parse_string.h>
 #include <cmdline_socket.h>
 #include <cmdline.h>
 #include "mp_commands.h"
@@ -76,7 +77,6 @@
 static const char *_MSG_POOL = "MSG_POOL";
 static const char *_SEC_2_PRI = "SEC_2_PRI";
 static const char *_PRI_2_SEC = "PRI_2_SEC";
-const unsigned string_size = 64;
 
 struct rte_ring *send_ring, *recv_ring;
 struct rte_mempool *message_pool;
@@ -121,7 +121,7 @@
 		send_ring = rte_ring_create(_PRI_2_SEC, ring_size, rte_socket_id(), flags);
 		recv_ring = rte_ring_create(_SEC_2_PRI, ring_size, rte_socket_id(), flags);
 		message_pool = rte_mempool_create(_MSG_POOL, pool_size,
-				string_size, pool_cache, priv_data_sz,
+				STR_TOKEN_SIZE, pool_cache, priv_data_sz,
 				NULL, NULL, NULL, NULL,
 				rte_socket_id(), flags);
 	} else {
diff --git a/examples/multi_process/simple_mp/mp_commands.c b/examples/multi_process/simple_mp/mp_commands.c
index 8da244b..cde3abd 100644
--- a/examples/multi_process/simple_mp/mp_commands.c
+++ b/examples/multi_process/simple_mp/mp_commands.c
@@ -78,7 +78,7 @@ static void cmd_send_parsed(void *parsed_result,
 
 	if (rte_mempool_get(message_pool, &msg) < 0)
 		rte_panic("Failed to get message buffer\n");
-	snprintf((char *)msg, string_size, "%s", res->message);
+	snprintf((char *)msg, STR_TOKEN_SIZE, "%s", res->message);
 	if (rte_ring_enqueue(send_ring, msg) < 0) {
 		printf("Failed to send message - message discarded\n");
 		rte_mempool_put(message_pool, msg);
diff --git a/examples/multi_process/simple_mp/mp_commands.h b/examples/multi_process/simple_mp/mp_commands.h
index 7e9a4ab..452b364 100644
--- a/examples/multi_process/simple_mp/mp_commands.h
+++ b/examples/multi_process/simple_mp/mp_commands.h
@@ -34,7 +34,6 @@
 #ifndef _SIMPLE_MP_COMMANDS_H_
 #define _SIMPLE_MP_COMMANDS_H_
 
-extern const unsigned string_size;
 extern struct rte_ring *send_ring;
 extern struct rte_mempool *message_pool;
 extern volatile int quit;
-- 
1.8.3.1

             reply	other threads:[~2017-10-26  8:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  8:29 Xueming Li [this message]
2017-10-26 23:03 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509006563-52179-1-git-send-email-xuemingl@mellanox.com \
    --to=xuemingl@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=sergio.gonzalez.monroy@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).