Fix 'router' node forwarding in forward test#118
Merged
Conversation
...so the poll thread could block inside mem_ll_send() during the TLS handshake and stop draining the opposite direction. It’s now a small packet ring buffer with non-blocking enqueue, which avoids that circular wait. I also forced the host TLS socket into non-blocking mode and added a 30s handshake deadline, so if something does stall again the test fails with a concrete error instead of hanging until the CI step timeout.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a potential deadlock/hang in the wolfSSL forwarding test by changing the in-memory router↔server link from a single blocking slot per direction to a small non-blocking ring buffer, and by making the host-side TLS client explicitly non-blocking with a handshake timeout to fail fast.
Changes:
- Replace the in-memory link-layer implementation with an 8-deep packet ring buffer to avoid blocking inside
mem_ll_send()during bidirectional traffic. - Force the host TLS client socket + wolfSSL I/O into non-blocking mode.
- Add a 30s TLS handshake deadline so CI fails with a concrete error instead of hanging indefinitely.
Comments suppressed due to low confidence (1)
src/test/test_wolfssl_forwarding.c:435
- The non-blocking connect retry loop doesn’t handle some common transient/terminal connect() errno values. In particular, EINTR can occur and should be retried, and some platforms may report completion via EISCONN (already connected) rather than returning 0. Also consider including EAGAIN separately from EWOULDBLOCK for portability where they differ.
cret = connect(fd, (struct sockaddr *)&remote, sizeof(remote));
if (cret == 0) {
connected = 1;
printf("TLS client: TCP connected\n");
break;
}
if (errno == EINPROGRESS || errno == EALREADY || errno == EWOULDBLOCK) {
if (poll(&(struct pollfd){ .fd = fd, .events = POLLOUT }, 1, 100) > 0) {
socklen_t errlen = sizeof(err);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &err, &errlen) == 0 && err == 0) {
connected = 1;
printf("TLS client: TCP connect completed after wait\n");
break;
}
}
continue;
}
if (errno == ECONNREFUSED || errno == ENETUNREACH || errno == ETIMEDOUT) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dgarske
approved these changes
May 12, 2026
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.
Fix in-mem router/server link: it was a single blocking slot per direction so the poll thread could block inside mem_ll_send() during the TLS handshake and stop draining the opposite direction. It’s now a small packet ring buffer with non-blocking enqueue, which avoids that circular wait. I also forced the host TLS socket into non-blocking mode and added a 30s handshake deadline, so if something does stall again the test fails with a concrete error instead of hanging until the CI step timeout.