Skip to content

ref: makes correction to SCTPConn close logic for SCTPWrite#87

Open
gomaja wants to merge 7 commits intoishidawataru:masterfrom
gomaja:refactor-sctpconn-close-logic
Open

ref: makes correction to SCTPConn close logic for SCTPWrite#87
gomaja wants to merge 7 commits intoishidawataru:masterfrom
gomaja:refactor-sctpconn-close-logic

Conversation

@gomaja
Copy link
Contributor

@gomaja gomaja commented Jan 8, 2026

Here is a PR that makes a correction to Close

fd := atomic.SwapInt32(&c._fd, -1) // fd = old value, c._fd = -1
c.SCTPWrite(nil, info) // BROKEN: uses c.fd() which returns -1

@gomaja gomaja marked this pull request as draft January 8, 2026 23:20
@gomaja
Copy link
Contributor Author

gomaja commented Jan 8, 2026

@ishidawataru after the fix, the c.SCTPWrite(nil, info) is returning an error "invalid argument"

I think SCTPWrite can be removed completely from Close.

@gomaja gomaja marked this pull request as ready for review January 11, 2026 12:21
@gomaja
Copy link
Contributor Author

gomaja commented Jan 18, 2026

This code part "defer" after an error with close is not performing well in dialSCTPExtConfig, specifically when SCTPConnect is returning one of the errors (syscall.EISCONN, syscall.EALREADY, syscall.EINPROGRESS). Mostly syscall.EINPROGRESS.
The close in defer is not completely closing the socket, and the next call of dialSCTPExtConfig is always giving syscall.EADDRINUSE. The issue can be fixed by adding also syscall.Shutdown(sock, syscall.SHUT_RDWR). However, I solved it with a more general close.

defer func() {
		if err != nil {
			syscall.Close(sock)
		}
	}()

@gomaja gomaja marked this pull request as draft January 20, 2026 21:08
@gomaja gomaja force-pushed the refactor-sctpconn-close-logic branch from b5ed2cc to b2960c6 Compare January 24, 2026 19:21
@gomaja gomaja marked this pull request as ready for review February 6, 2026 16:22
@gomaja
Copy link
Contributor Author

gomaja commented Feb 6, 2026

PR ready for review,. Changes have made operation very smooth as previously it was very faulty specifically when the connection sends to a backhole (peer no more reachable) while having many messages to send (Full send-Q).

Later we can refactor syscall.SendmsgN(c.fd(), b, cbuf, nil, syscall.MSG_DONTWAIT) to a better one.

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.

1 participant