Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #151: bind not restarting when user uses closeBind #152

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

laduchesneau
Copy link
Collaborator

@laduchesneau laduchesneau commented Sep 4, 2024

When a pdu expires and the user returns true on closeBind, it should now call the close function with the proper state. This will allow OnClosed to be called and the bind to be restarted.

This also fixes the the transceiver context that is never closed.

@laduchesneau laduchesneau marked this pull request as ready for review September 4, 2024 17:12
@laduchesneau
Copy link
Collaborator Author

closing it for now, the error message doesnt match the close reason. There seems to be a race condition between the unbind start and the tcp disconnect. Ill reopen when I resolve this issue.

@laduchesneau laduchesneau reopened this Sep 6, 2024
@@ -127,6 +129,8 @@ func (t *transceivable) Close() (err error) {
if t.settings.OnClosed != nil {
t.settings.OnClosed(ExplicitClosing)
}

t.wg.Wait()
}
return
}
Copy link
Owner

Choose a reason for hiding this comment

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

Please update this function, reuse your nearly created closing

func (t *transceivable) Close() error {
    t.closing(ExplicitClosing)
    return  nil
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Some tests were failing after recommended change. So I added a returned error to the new closing () func.

func (t *transceivable) Close() (err error) {
	return t.closing(ExplicitClosing)
}

func (t *transceivable) closing(state State) (err error) {
	if atomic.CompareAndSwapInt32(&t.aliveState, Alive, Closed) {
		...
		// close underlying conn
		err = t.conn.Close()
		...
	}
	return
}

Copy link
Owner

@linxGnu linxGnu left a comment

Choose a reason for hiding this comment

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

LGTM. Just a small comment.

I am sorry for replying late due to personal matter

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.

2 participants