Skip to content

Fix 'router' node forwarding in forward test#118

Merged
dgarske merged 1 commit into
wolfSSL:masterfrom
danielinux:fix-stuck-forwarding-test
May 12, 2026
Merged

Fix 'router' node forwarding in forward test#118
dgarske merged 1 commit into
wolfSSL:masterfrom
danielinux:fix-stuck-forwarding-test

Conversation

@danielinux
Copy link
Copy Markdown
Member

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.

...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.
Copilot AI review requested due to automatic review settings May 12, 2026 17:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/test/test_wolfssl_forwarding.c
Comment thread src/test/test_wolfssl_forwarding.c
@dgarske dgarske merged commit fe6f1d5 into wolfSSL:master May 12, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants