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

Close mountpoint sockets when leaving relay thread (fixes #3111) #3143

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

lminiero
Copy link
Member

@lminiero lminiero commented Jan 5, 2023

This PR closes the sockets used by a mountpoint when leaving the related thread: since a "destroy" request joins the thread, this ensures ports are free once a response is sent. Before, sockets would only be closed in the mountpoint free callback, so when reference counters gave the green light, which could take longer and cause the issue described in #3111.

@lminiero lminiero added the multistream Related to Janus 1.x label Jan 9, 2023
Comment on lines +9323 to +9331
if(stream->fd[0] > -1)
close(stream->fd[0]);
stream->fd[0] = -1;
if(stream->fd[1] > -1)
close(stream->fd[1]);
stream->fd[1] = -1;
if(stream->fd[2] > -1)
close(stream->fd[2]);
stream->fd[2] = -1;
Copy link
Member

@atoppi atoppi Jan 10, 2023

Choose a reason for hiding this comment

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

This looks a bit redundant, why not use a simple loop?

	for(int i=0; i<3; i++) {
  		if(stream->fd[i] > -1) {
			close(stream->fd[i]);
  			stream->fd[i] = -1;
		}
	}

Copy link
Member Author

Choose a reason for hiding this comment

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

Since i was small enough and known, it felt easier to do that. Besides, I just copied what we had in the _free callback already.

@lminiero
Copy link
Member Author

Merging.

@lminiero lminiero merged commit 053b50b into master Jan 11, 2023
@lminiero lminiero deleted the mountpoint-ports-close branch January 11, 2023 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multistream Related to Janus 1.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants