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
RemoteVST: process all remaining messages after the process has quit #4371
Conversation
@@ -54,7 +54,7 @@ ProcessWatcher::ProcessWatcher( RemotePlugin * _p ) : | |||
|
|||
void ProcessWatcher::run() | |||
{ | |||
while( !m_quit && m_plugin->isRunning() ) | |||
while( !m_quit && (m_plugin->messagesLeft() || m_plugin->isRunning()) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me there's a possibility for a race condition:
m_plugin->messagesLeft()
returnsfalse
.- VST posts new message and then exits.
m_plugin->isRunning()
returnsfalse
.- Loop aborts even though there are pending messages.
I think the conditional should just be rearranged so that m_plugin->messagesLeft()
is only checked after m_plugin->isRunning()
:
while( !m_quit && (m_plugin->isRunning() || m_plugin->messagesLeft()) )
I'm not very familiar with the area of the code though, so don't hesitate to point out why I might be wrong about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh :) good catch, thanks. (I wanted to write something about why you were wrong but then realized you were right)
Thanks for the patch! I went ahead and made the adjustment mentioned above, and committed that to master: 4fd8ecd Credited you by your original username, but if there was any other metadata in the original commit, it was probably lost since I had to reauthor the commit (couldn't pull from the original repo since it's been deleted). |
@Wallacoloo It looks like this change is ineffective because of a second lmms/src/core/RemotePlugin.cpp Lines 454 to 460 in 392c753
I ran into Do you have any idea how to approach this? |
@lukas-w Interesting. I didn't dig around to figure out where we decide whether or not to build with SHM_FIFO. I don't know enough about this area. I'm going to assume you're building with SHM_FIFO undefined, in which case it looks like we're communicating with the remote plugin using sockets. If we try reading from the socket after the plugin has hung up, can we ever get data from it? I think we can - I think that data still hangs around after the process has exited. If that's the case, I don't understand why we can't still read queued messages from an "invalid" RemotePlugin. Can we just remove the
On the other hand, if the socket can no longer be read after the remote plugin exits, then we're out of luck. We would need to somehow make sure remote plugins wait until the host reads all messages before exiting - which wouldn't be easy to do if the plugin crashes / etc. Like I said, I don't know much about this area of LMMS. |
If the process exits, keep processing the remaining messages. Some might be debug messages or a msg that the vst loaded was 32 bits.
(cherry-picked msvc/ng)