Revert "Fix Write() method of Port" 48/265748/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 28 Oct 2021 04:18:59 +0000 (13:18 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 28 Oct 2021 04:19:04 +0000 (13:19 +0900)
This reverts commit 99cc275334f64d281a3e10e5ace5e22e1f15a6a3.

Change-Id: I0b38339eb5d44d6136a9d49cf129f52dbcd28d8e

src/port-internal.cc
src/port-internal.hh

index 7dd3ce6..aaccee8 100644 (file)
@@ -35,7 +35,7 @@ namespace rpc_port {
 namespace internal {
 namespace {
 
-constexpr const int QUEUE_SIZE_MAX = 1024 * 1024 * 10;
+constexpr const int QUEUE_SIZE_MAX = 1024 * 1024;
 constexpr const int MAX_RETRY_CNT = 10;
 constexpr const int MAX_TIMEOUT = 1000;
 constexpr const int MIN_TIMEOUT = 50;
@@ -71,13 +71,10 @@ Port::Port(int fd, std::string id)
   uuid_generate(u);
   uuid_unparse(u, uuid);
   instance_ = std::string(uuid) + ":" + id_;
-  send_buffer_size_ = GetSendBufferSize();
 }
 
 Port::Port(int fd, std::string id, std::string instance)
-    : fd_(fd), id_(std::move(id)), instance_(std::move(instance)), seq_(0) {
-  send_buffer_size_ = GetSendBufferSize();
-}
+    : fd_(fd), id_(std::move(id)), instance_(std::move(instance)), seq_(0) {}
 
 Port::~Port() {
   ClearQueue();
@@ -182,19 +179,6 @@ int Port::Read(void* buf, unsigned int size) {
   return RPC_PORT_ERROR_NONE;
 }
 
-int Port::GetSendBufferSize() {
-  int value;
-  socklen_t len = sizeof(int);
-  int ret = getsockopt(fd_, SOL_SOCKET, SO_SNDBUF,
-      reinterpret_cast<void*>(&value), &len);
-  if (ret < 0) {
-    _E("getsockopt() is failed. errno(%d)", errno);
-    return 163840;
-  }
-
-  return value;
-}
-
 bool Port::CanRead(int timeout) {
   struct pollfd fds[1];
   fds[0].fd = fd_;
@@ -275,8 +259,7 @@ int Port::Write(const void* buf, unsigned int size, int* sent_bytes) {
   }
 
   while (left && (retry_cnt < MAX_RETRY_CNT)) {
-    size_t len = left > send_buffer_size_ ? send_buffer_size_ : left;
-    nb = send(fd_, buffer, len, MSG_NOSIGNAL);
+    nb = send(fd_, buffer, left, MSG_NOSIGNAL);
     if (nb == -1) {
       if (errno == EINTR) {
         LOGI("write_socket: EINTR continue ...");
index 028e786..853b27f 100644 (file)
@@ -67,7 +67,6 @@ class Port : public std::enable_shared_from_this<Port> {
   }
 
  private:
-  int GetSendBufferSize();
   bool CanRead(int timeout);
   bool CanWrite();
   void IgnoreIOEvent();
@@ -103,7 +102,6 @@ class Port : public std::enable_shared_from_this<Port> {
   int fd_;
   std::string id_;
   std::string instance_;
-  size_t send_buffer_size_;
   std::atomic<uint32_t> seq_;
   mutable std::recursive_mutex mutex_;
   std::queue<std::shared_ptr<DelayMessage>> queue_;