zitilib: ZIti_connect honor socket non/blocking status#1016
Merged
Conversation
Refactor the zitilib connect path to support non-blocking sockets: return EINPROGRESS and let callers poll/select for completion. The app fd is dup'd so the caller can close it before connect completes. Replace the Unix socketpair/dup2 bridge mechanism with loopback listen/accept (matching the Windows approach) and add AF_INET6 support to both platform implementations. Also fix ziti_conn_bridge_fds parameter types (uv_os_fd_t -> uv_os_sock_t) and correct the inverted error check in ziti-fd-client sample. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dovholuknf
reviewed
Mar 25, 2026
|
|
||
| #if _WIN32 | ||
| WSADATA wsaData; | ||
| WSAStartup(MAKEWORD(2, 2), &wsaData); |
Member
There was a problem hiding this comment.
should this be done in ziti_lib_init on windows? or should ziti_lib track that it's been called somehow? it seems important to do (since you're doing it here). how would python or any other FFI handle this? does it need to?
Member
Author
There was a problem hiding this comment.
this is a sample app and it is opening socket before Ziti_lib_init()
dovholuknf
reviewed
Mar 25, 2026
dovholuknf
reviewed
Mar 25, 2026
dovholuknf
approved these changes
Mar 25, 2026
Member
dovholuknf
left a comment
There was a problem hiding this comment.
one leak question wrt req->conn but other than that lgtm
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.
[fixes #984]
Non-Blocking
Ziti_connectandZiti_connect_addr.The core
zitilibconnection functions have been redesigned to support non-blocking operations:connect()to this bridge.EINPROGRESS(orWSAEWOULDBLOCKon Windows), allowing applications to use select, poll, or epoll to monitor connectionprogress.
IPv6 Support
Cross-Platform Consistency & Stability
ziti_conn_bridge_fdsnow usesuv_os_sock_tfor better type safety across platforms.Sample Program Updates
ziti-fd-client: Extensively updated to demonstrate the new non-blocking API, including manual poll() usage and an optional blocking mode via the ZITI_SAMPLE_BLOCKING environment variable.ziti-ncat: Updated to align with API changes and ensure stable connection handling.