Skip to content

Comments

Fixed crash bug on client disconnect#1

Open
ortluk wants to merge 3 commits intotlfdev:masterfrom
ortluk:master
Open

Fixed crash bug on client disconnect#1
ortluk wants to merge 3 commits intotlfdev:masterfrom
ortluk:master

Conversation

@ortluk
Copy link

@ortluk ortluk commented Apr 8, 2018

server was crashing on client disconnect because the object pointed to by the iterator was being deleted before advancing the iterator. by waiting to close the socket till the next pass through the loop we can safely delete the dead socket.

@tlfdev
Copy link
Owner

tlfdev commented Apr 8, 2018

The problem I see with this pr, is that if there are say two sockets in the list and the second (last one) is to be closed, we'll mark it as closable but not actually handle it. I would much prefer to see us build a list of them, then delete and remove from the socket list at the end if there are any in list, or somehow otherwise handle this. Otherwise we'll have two code paths where sockets should be closed; one in the loop and one outside the loop which would require some code duplication.

@ortluk
Copy link
Author

ortluk commented Apr 25, 2018

or simply checking if it is the last member before flagging it for close, and if it is just close it.
i.e
if(sock == SockeList.back())
CloseSocket(sock);
else
slclose = sock;

ortluk added 2 commits April 25, 2018 20:28
added a check for last list entry needing closed, and handling that.
@ortluk
Copy link
Author

ortluk commented Apr 26, 2018

I made the changes, to handle your concerns.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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