Repository navigation
#75: Implemented socket abstraction library - #77
sgn4sangar wants to merge 27 commits into
Conversation
7d4b2d4 to
f4ee0d7
Compare
| ASSERT_EQ(::close(second_pipe[1]), 0); | ||
| } | ||
|
|
||
| TEST(SocketTest, ListenerConnectsAcceptsAndRequiresExplicitCleanup) |
There was a problem hiding this comment.
Maybe move all tests which use the unique_socket_path into a GTest fixture, which provides the temp path, and then automatically cleans up the temporary directory in TearDown().
There was a problem hiding this comment.
You can also use the same class I created in the DB, see
https://github.com/exasol/db/blob/tu.master.SPOT-31038_refactor_udf_fw/Engine/src/exscript/pluggable/server_based/test_utils/temporary_directory_cleanup.h and https://github.com/exasol/db/blob/tu.master.SPOT-31038_refactor_udf_fw/Engine/src/exscript/pluggable/server_based/test_utils/temporary_directory_cleanup.cpp
and here is an example of usage:
https://github.com/exasol/db/blob/e3887e7a372074faada36afe74e1a7f3672899f6/Engine/src/exscript/pluggable/server_based/instance/connection/unix_domain_socket_transport_utest.cpp#L35
There was a problem hiding this comment.
In db reference, there is a dedicated RAII cleanup class; the v2 fixture currently performs the cleanup directly in TearDown(), which, i guess matches the requested behavior. pls correct me if i am wrong
|
|
||
| UnixSocketListener::~UnixSocketListener() | ||
| { | ||
| close(); |
There was a problem hiding this comment.
I feel like the design does not follow RAII principles, we should also add the "unlink" to the destructor,
this would also thin out the public API
There was a problem hiding this comment.
@tkilias should we go for it? i remember you saying the unix-sock-fd migrate between processes.
| } | ||
| if (::listen(socket_fd.native_handle(), backlog) == -1) | ||
| { | ||
| throw std::system_error(errno, std::generic_category(), "listen on Unix socket"); |
There was a problem hiding this comment.
bind created the path, listen fails, how do you unlink the path then?
There was a problem hiding this comment.
UnixSocketListener::bind being a static function; if listen fails, i mean throws exception, is it not the caller's responsibility to unlink it.
|
| return std::exchange(this->file_descriptor, -1); | ||
| } | ||
|
|
||
| OwnedFileDescriptor::OwnedFileDescriptor(const int owned_fd) noexcept : file_descriptor(owned_fd) |
There was a problem hiding this comment.
OwnedFileDescriptor impl should go into its own cc file
|
|
||
| using exasol::udf::v2::socket::OwnedFileDescriptor; | ||
|
|
||
| TEST(SocketTest, OwnedDescriptorClosesExactlyOnceAfterMoveAndRelease) |
There was a problem hiding this comment.
rename file to the class that is actually tested here OwnedFileDescriptor




fixes #75