-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IPC via abstract unix domain sockets #4
Conversation
- Added Nunavut generation - Added UDP platform stuff
# Conflicts: # CMakeLists.txt # README.md # src/cli/CMakeLists.txt # src/common/CMakeLists.txt # src/daemon/CMakeLists.txt # src/daemon/engine/CMakeLists.txt # src/daemon/engine/application.cpp # src/daemon/engine/application.hpp # src/daemon/engine/platform/debian/epoll_single_threaded_executor.hpp # src/daemon/engine/platform/defines.hpp # src/daemon/engine/platform/udp/udp_sockets.hpp
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay) | ||
std::memcpy(addr.sun_path, | ||
abstract_socket_path.c_str(), | ||
std::min(sizeof(addr.sun_path), abstract_socket_path.size())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On BSD I'm gonna return back to usual Unix domain sockets - BSD doesn't support abstract ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, @thirtytwobits let me know please, do you seek that our ocvsmd could run on macOS?
For now it is not a problem (besides the above comment about abstract unix domain sockets), but I would like to know whether it worth to spend a bit extra efforts on this or not. Thnx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not required for the contract work, no. It's always helpful to have for debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far so good but how does the client get server notifications? For example, what's the flow here if the client starts a firmware update and the server is monitoring it? How does the client get the firmware update progress from the server?
~UnixSocketClient(); | ||
|
||
bool connect_to_server(); | ||
void send_message(const std::string& message) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also support string_view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this send_message
was just to prove send and receive. real communication api of course will be different. probably passing back and forth some serialized structures.
CETL_NODISCARD libcyphal::IExecutor::Callback::Any registerListenCallback( | ||
libcyphal::IExecutor::Callback::Function&& function) const; | ||
|
||
void accept(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this return an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally it should but in my case there is nowhere to return it actually. See call site:
ipc_server_callback_ = ipc_server_.registerListenCallback([this](const auto&) {
//
ipc_server_.accept();
});
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay,hicpp-no-array-decay) | ||
std::memcpy(addr.sun_path, | ||
abstract_socket_path.c_str(), | ||
std::min(sizeof(addr.sun_path), abstract_socket_path.size())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not required for the contract work, no. It's always helpful to have for debugging.
const std::string socket_path_; | ||
int server_fd_; | ||
platform::IPosixExecutorExtension* const posix_executor_ext_; | ||
std::unordered_map<int, std::unique_ptr<detail::ClientContext>> client_contexts_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: might be more elegant to use a std::set<std::unique_ptr<detail::ClientContext>>
where detail::ClientContext
had a int GetHandle() const
method and you provided a custom comparitor that used that.
@@ -67,6 +67,13 @@ add_definitions( | |||
-DVCS_REVISION_ID=0x${vcs_revision_id}ULL | |||
-DNODE_NAME="org.opencyphal.ocvsmd" | |||
) | |||
if (DEFINED PLATFORM_LINUX_TYPE) | |||
if(${PLATFORM_LINUX_TYPE} STREQUAL "bsd") | |||
add_definitions(-DPLATFORM_LINUX_TYPE_BSD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BSD is not Linux, it's a different kernel family, so PLATFORM_LINUX_TYPE
may need renaming.
if(${PLATFORM_LINUX_TYPE} STREQUAL "bsd") | ||
add_definitions(-DPLATFORM_LINUX_TYPE_BSD) | ||
elseif(${PLATFORM_LINUX_TYPE} STREQUAL "debian") | ||
add_definitions(-DPLATFORM_LINUX_TYPE_DEBIAN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debian comes with BSD kernels as well, not just Linux. While we are at it, Linux is a kernel, not an OS, that would be GNU/Linux. Should we not simply go like PLATFORM_DEBIAN
, PLATFORM_BSD
? Although then it seems odd that one of them is an OS while the other is a kernel.
ocvsmd-cli
executable target to consume the SDK.platform::posixSyscallError
(which does retries onEINTR
). For now only IPC stuff correctly wrapped; the same for other places (like executors, udp sockets, etc.) to be continued...Also:
kevent
timeout calculations - now it's nanoseconds based instead of seconds).