Skip to content

Instantly share code, notes, and snippets.

@Amanieu Amanieu/daemon.diff
Last active Feb 26, 2020

Embed
What would you like to do?
diff --git a/src/common/IPC/Primitives.cpp b/src/common/IPC/Primitives.cpp
index c348776e..6d48f779 100644
--- a/src/common/IPC/Primitives.cpp
+++ b/src/common/IPC/Primitives.cpp
@@ -302,13 +302,16 @@ void Socket::SendMsg(const Util::Writer& writer) const
const void* data = writer.GetData().data();
size_t len = writer.GetData().size();
+ // Use a smaller buffer size to avoid ENOBUFS errors from the kernel
+ const size_t MAX_IPC_BYTES = 4096;
+
while (numHandles || len) {
- bool more = numHandles > NACL_ABI_IMC_DESC_MAX || len > NACL_ABI_IMC_USER_BYTES_MAX - 1;
- InternalSendMsg(handle, more, handles, std::min<size_t>(numHandles, NACL_ABI_IMC_DESC_MAX), data, std::min<size_t>(len, NACL_ABI_IMC_USER_BYTES_MAX - 1));
+ bool more = numHandles > NACL_ABI_IMC_DESC_MAX || len > MAX_IPC_BYTES;
+ InternalSendMsg(handle, more, handles, std::min<size_t>(numHandles, NACL_ABI_IMC_DESC_MAX), data, std::min<size_t>(len, MAX_IPC_BYTES));
handles += std::min<size_t>(numHandles, NACL_ABI_IMC_DESC_MAX);
numHandles -= std::min<size_t>(numHandles, NACL_ABI_IMC_DESC_MAX);
- data = static_cast<const char*>(data) + std::min<size_t>(len, NACL_ABI_IMC_USER_BYTES_MAX - 1);
- len -= std::min<size_t>(len, NACL_ABI_IMC_USER_BYTES_MAX - 1);
+ data = static_cast<const char*>(data) + std::min<size_t>(len, MAX_IPC_BYTES);
+ len -= std::min<size_t>(len, MAX_IPC_BYTES);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.