Fix building ExportedConnection on Windows#80
Open
SeverinLeonhardt wants to merge 1 commit intoscylladb:masterfrom
Open
Fix building ExportedConnection on Windows#80SeverinLeonhardt wants to merge 1 commit intoscylladb:masterfrom
SeverinLeonhardt wants to merge 1 commit intoscylladb:masterfrom
Conversation
The `<unistd.h>` header isn't available on Windows. The `dup` function is deprecated[^1] and apparently also not the correct function here. On Windows `uv_fileno` currently returns a `SOCKET`[^2] cast into `uv_os_fd_t`[^3]. Contrary to many other handles this handle type can't be duplicated using `DuplicateHandle`[^4]. `WSADuplicateSocket` has to be used instead. As documented an actual `SOCKET` has to be constructed from `WSAPROTOCOL_INFOW`. The parameters are taken from the struct, except for `g` and `dwFlags` which were taken from libuv's implementation[^5]. Error handling was omitted like with `uv_fileno` and `dup` already. Also changed the type of `fd` to what `uv_tcp_open` expects which is `SOCKET` instead of `int` on Windows. [^1]: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-dup-dup2 [^2]: https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/include/uv/win.h#L456 [^3]: https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/src/win/core.c#L689 [^4]: https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle#remarks [^5]: https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/src/win/tcp.c#L1281-L1282
Author
|
To test whether these changes work I've applied the following patch: diff --git a/src/connection_pool.cpp b/src/connection_pool.cpp
index 21464b18..891226ec 100644
--- a/src/connection_pool.cpp
+++ b/src/connection_pool.cpp
@@ -95,11 +95,7 @@ ConnectionPool::ConnectionPool(const Connection::Vec& connections, ConnectionPoo
++it) {
const Connection::Ptr& connection(*it);
if (!connection->is_closing()) {
- if (connections_by_shard_[connection->shard_id()].size() < num_connections_per_shard_) {
- add_connection(PooledConnection::Ptr(new PooledConnection(this, connection)));
- } else {
host_->add_unpooled_connection(std::move(connection));
- }
}
}This lead to |
prothegee
added a commit
to prothegee/behh
that referenced
this pull request
May 22, 2025
- scylladb-cpp-driver case: scylladb/cpp-driver#80 - updating test and config for scylladb test - modify preparing to use scylla in main cmake
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
<unistd.h>header isn't available on Windows. Thedupfunction is deprecated1 and apparently also not the correct function here.On Windows
uv_filenocurrently returns aSOCKET2 cast intouv_os_fd_t3. Contrary to many other handles this handle type can't be duplicated usingDuplicateHandle4.WSADuplicateSockethas to be used instead. As documented an actualSOCKEThas to be constructed fromWSAPROTOCOL_INFOW. The parameters are taken from the struct, except forganddwFlagswhich were taken from libuv's implementation5.Error handling was omitted like with
uv_filenoanddupalready.Also changed the type of
fdto whatuv_tcp_openexpects which isSOCKETinstead ofinton Windows.Footnotes
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-dup-dup2 ↩
https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/include/uv/win.h#L456 ↩
https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/src/win/core.c#L689 ↩
https://learn.microsoft.com/en-us/windows/win32/api/handleapi/nf-handleapi-duplicatehandle#remarks ↩
https://github.com/libuv/libuv/blob/2f1614b1286f53b3b2ab96a15a525cb25462ba9a/src/win/tcp.c#L1281-L1282 ↩