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

Reading and writing threads can shutdown without Connection knowing #143

Open
kurtkilpela opened this issue Dec 21, 2023 · 3 comments
Open
Assignees

Comments

@kurtkilpela
Copy link
Member

Pharo's testing framework automatically terminates any threads that were not cleaned up during a test run. If a TestResource, used to maintain an open Connection for various tests, is initialized during a test, the Connection's reading and writing threads will be terminated automatically.

In this scenario, the framework does not realize. The threads terminate and the Connection and Channel continue to believe they are open and connected.

There are different ways this could be handled.

  1. Threads could automatically restart
  2. The Connection could automatically close if the thread shuts down
  3. The Connection could be alerted and fail any future send to #remoteSelf until the threads are restarted by the framework user

If the socket is open, I think 1 is probably the best choice for when the thread unexpectedly is terminated. If the socket is closed, it seems we should signal the normal closure procedure.

Note, this only applies when our threads unexpectedly shutdown. If they shutdown for expected reasons, that situation dictates the proper behavior.

@kurtkilpela kurtkilpela self-assigned this Dec 21, 2023
@ericwinger
Copy link
Member

The symptoms are a bit nefarious. After the bug has occurred, any call to RSR will just hang without explanation.

@kurtkilpela
Copy link
Member Author

kurtkilpela commented Dec 21, 2023

There is something additional to keep in mind, if the thread is terminated, it could be terminated partway through writing data on the socket. I don't know if we can determine -- reliably -- the amount of data that has already been written to the socket.

Restarting the thread could result in part of a (or an entire) message never making it to the remote side. At best, the Socket could close. At worst, the missing data could cause incorrect remote messages to be sent. Messages sent by the client might never return.

@kurtkilpela
Copy link
Member Author

We do not have any way of knowing what the state of the communication is if the read/write threads die outside of our control. I think we need to close the Connection once detected.

The read or write threads could have been partway through a ready or write operation. We cannot safely continue. Messages could have been lost along the way.

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

No branches or pull requests

2 participants