Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com
Cc: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Subject: [spp] [PATCH 2/5] controller: change socket buffer length
Date: Mon,  1 Oct 2018 12:14:10 +0900	[thread overview]
Message-ID: <20181001031413.75652-3-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181001031413.75652-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Size of message via socket might exceed 1000 if network configuration is
complexed. This patch is for defining `spp_common.SOCK_BUF_SIZE` and its
size to 2048.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/conn_thread.py | 10 ++++------
 src/controller/spp.py         |  2 +-
 src/controller/spp_common.py  |  3 +++
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/controller/conn_thread.py b/src/controller/conn_thread.py
index e524e84..8bddfc0 100644
--- a/src/controller/conn_thread.py
+++ b/src/controller/conn_thread.py
@@ -52,8 +52,7 @@ class ConnectionThread(threading.Thread):
 
             # Receiving from secondary
             try:
-                # 1024 stands for bytes of data to be received
-                data = self.conn.recv(1024)
+                data = self.conn.recv(spp_common.SOCK_BUF_SIZE)
                 if data:
                     msg = "%s" % data.decode('utf-8')
                     spp_common.SEC2MAIN[self.client_id].put(msg)
@@ -99,7 +98,7 @@ class AcceptThread(threading.Thread):
         except KeyError:
             return -1
 
-        data = conn.recv(1024)
+        data = conn.recv(spp_common.SOCK_BUF_SIZE)
         if data is None:
             return -1
 
@@ -140,7 +139,7 @@ class AcceptThread(threading.Thread):
 
         msg = "_set_client_id %u" % free_client_id
         conn.send(msg.encode('utf-8'))
-        data = conn.recv(1024)
+        data = conn.recv(spp_common.SOCK_BUF_SIZE)
 
         return free_client_id
 
@@ -236,8 +235,7 @@ class PrimaryThread(threading.Thread):
 
                 # Receiving from primary
                 try:
-                    # 1024 stands for bytes of data to be received
-                    data = conn.recv(1024)
+                    data = conn.recv(spp_common.SOCK_BUF_SIZE)
                     if data:
                         spp_common.PRIMARY2MAIN.put(
                             "recv:%s:{%s}" % (str(addr), data.decode('utf-8')))
diff --git a/src/controller/spp.py b/src/controller/spp.py
index 57604de..80b1fab 100644
--- a/src/controller/spp.py
+++ b/src/controller/spp.py
@@ -24,7 +24,7 @@ class CmdRequestHandler(socketserver.BaseRequestHandler):
     CMD = None  # contains a instance of Shell class
 
     def handle(self):
-        self.data = self.request.recv(1024).strip()
+        self.data = self.request.recv(spp_common.SOCK_BUF_SIZE).strip()
         cur_thread = threading.currentThread()
         print(cur_thread.getName())
         print(self.client_address[0])
diff --git a/src/controller/spp_common.py b/src/controller/spp_common.py
index 80fab76..0cac2d9 100644
--- a/src/controller/spp_common.py
+++ b/src/controller/spp_common.py
@@ -30,6 +30,9 @@ PRIMARY2MAIN = Queue()
 # Maximum num of sock queues for secondaries
 MAX_SECONDARY = 16
 
+# Should be as same as MSG_SIZE in src/shared/common.h
+SOCK_BUF_SIZE = 2048
+
 PRIMARY = ''
 SECONDARY_COUNT = 0
 
-- 
2.7.4

  parent reply	other threads:[~2018-10-01  3:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-01  3:14 [spp] [PATCH 0/5] Change primary status command to be detailed ogawa.yasufumi
2018-10-01  3:14 ` [spp] [PATCH 1/5] shared: change socket buffer length ogawa.yasufumi
2018-10-01  3:14 ` ogawa.yasufumi [this message]
2018-10-01  3:14 ` [spp] [PATCH 3/5] primary: change status command detailed ogawa.yasufumi
2018-10-01  3:14 ` [spp] [PATCH 4/5] controller: change msg format in ConnectionThread ogawa.yasufumi
2018-10-01  3:14 ` [spp] [PATCH 5/5] controller: simply print primary status ogawa.yasufumi

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=20181001031413.75652-3-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /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).