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

Avoid to close @socket of MQTT::Client unexpectedly #130

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ashie
Copy link
Contributor

@ashie ashie commented Dec 16, 2020

Since it is locked only when writing, it may be closed by anothre thread
while reading or writing. In actual we often get the following error
when we are processing massive messages by fluent-plugin-mqtt-io:

IOError,stream closed in another thread

This commit ensure to protect all atomic operations of the socket.

@ashie
Copy link
Contributor Author

ashie commented Dec 16, 2020

It's a revised patch of #129.

@ashie
Copy link
Contributor Author

ashie commented Dec 16, 2020

The patch can be simplified by using Thread::Mutex#owned? but I don't use it because it's breaks CI on Ruby 1.9.3.

Since it is locked only when writing, it may be closed by anothre thread
while reading or writing. In actual we often get the following error
when we are processing massive messages by fluent-plugin-mqtt-io:

  IOError,stream closed in another thread

This commit ensure to protect all atomic operations of the socket.

Signed-off-by: Takuro Ashie <[email protected]>
Although an error should be always raised on exiting @read_thread to
break `get` loop, there was a case that it's not raised.

Signed-off-by: Takuro Ashie <[email protected]>
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