-
Notifications
You must be signed in to change notification settings - Fork 8
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
Wait for popen3 execution of goodhosts #43
Comments
I think that https://github.com/goodhosts/cli doesn't support a big hosts file at all. |
Thank you, will take the problem there. |
@Mte90 how do you know it's goodhosts itself that's stalling? |
So I had in the past a lot of hosts inside the file and goodhosts was parsing all of them for rewriting (clean as example) and this was changing the whole file and delay everything. At the end I removed everything on my hosts file and there are no issues anymore, also as goodhosts development is stalled I didn't opened a ticket for it. |
@Mte90 that's cleaning, we don't clean anymore on VVV where this was first seen, haven't for a long time. But even ignoring that, you've shared an anecdote, no actual data has been shared proving it, just assumptions. Instead, @conradolandia should be able to test the theory by trying to add a host with the goodhosts CLI to see if it still hangs. If so, it's the CLI. If not, it's the vagrant plugin. You're also assuming they have the latest version of the plugin, we don't know that |
@conradolandia grab the latest goodhosts from https://github.com/goodhosts/cli/releases and try to use it to add a host, e.g. |
and run |
Results: Downloaded the $ vagrant plugin list --local
vagrant-goodhosts (1.1.0, local) |
How much times takes? maybe is the ruby api that has issues with the timeout or similar. |
~ wc -l /etc/hosts
610748 /etc/hosts
~ time sudo goodhosts add 127.0.0.1 loquesea.test
hosts entry added: 127.0.0.1 loquesea.test
sudo goodhosts add 127.0.0.1 loquesea.test 3,61s user 0,37s system 156% cpu 2,545 total |
So I guess that the issue is at https://github.com/goodhosts/vagrant/blob/master/lib/vagrant-goodhosts/GoodHosts.rb#L119 Looking at the doc a pid is created but we are no printing it, https://ruby-doc.org/stdlib-2.4.2/libdoc/open3/rdoc/Open3.html#method-c-popen3 We can add a code that wait for the execution of the process like this https://stackoverflow.com/questions/11710542/wait-for-popen3-process-to-finish but I am not sure. |
we should wait for the command to finish before proceeding otherwise how do we know the command is finished, and how do we avoid multiple attempts happening at the same time from the same vagrant command |
We need the output of the command including also stderr https://github.com/goodhosts/vagrant/blob/main/lib/vagrant-goodhosts/GoodHosts.rb#L138 |
So |
We already use popen3 https://github.com/goodhosts/vagrant/blob/main/lib/vagrant-goodhosts/GoodHosts.rb#L113 so I need to know what are the differences between the two methods. |
What’s the reason for the change? Calling the CLI works already so I don’t
see any improvements to be had here and it sounds like it already uses the
optimum method
…On Wed, 7 Dec 2022 at 19:03, Daniele Scasciafratte ***@***.***> wrote:
We already use popen3
https://github.com/goodhosts/vagrant/blob/main/lib/vagrant-goodhosts/GoodHosts.rb#L113
so I need to know what are the differences between the two methods.
—
Reply to this email directly, view it on GitHub
<#43 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAOLZ5GZZNQ2JNXZBWJKVLWMDNQRANCNFSM5GAG5LCA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
|
Okay, it might be the deadlock problem of |
https://www.rubydoc.info/stdlib/open3/Open3.popen3
|
Not only the stderr, since we never read from stdout before join the waiting thread( stdin, stdout, stderr, wait_thr = Open3.popen3([env,] cmd... [, opts])
pid = wait_thr[:pid] # pid of the started process
...
stdin.close # stdin, stdout and stderr should be closed explicitly in this form.
stdout.close
stderr.close
exit_status = wait_thr.value # Process::Status object returned. |
According to "When I try to use goodhosts, it just freezes and whatever process I was on won't go on.", it seems a deadlock. However, the cli never output too much. |
Since |
I am not able to reproduce the issue but I think that to test it is required a big hosts file that take a lot to parse it. |
@Mte90 I'm not sure why a big hosts file would matter here as this code isn't inside goodhosts, it's the vagrant plugin that calls it, no host files are being touched by ruby itself |
can you make a PR? |
The problem is the execution of the cli command that takes a while and probably this freeze something in vagrant. In our case the output is very tiny anyway from this so I think that it is something to be improved on the cli side and not on the vagrant side. |
If the user walks away and comes back to a sudo or UAC prompt 5 minutes
later that’s no different to goodhosts taking 5 minutes to handle a massive
hosts file so this has to be handled at this end too if it’s a problem
…On Fri, 9 Dec 2022 at 14:02, Daniele Scasciafratte ***@***.***> wrote:
The problem is the execution of the cli command that takes a while and
probably this freeze something in vagrant. In our case the output is very
tiny anyway from this so I think that it is something to be improved on the
cli side and not on the vagrant side.
—
Reply to this email directly, view it on GitHub
<#43 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAOLZ3R7LYVKMSHDGFF4N3WMM3XVANCNFSM5GAG5LCA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I block malware sites and ads from the internet using a large
hosts
file (600.000+ lines), redirecting all these bad hosts to 0.0.0.0. When I try to use goodhosts, it just freezes and whatever process I was on won't go on. If I remove most of the entries form /etc/hosts, the process completes without problems. Is this a bug or expected behavior?The text was updated successfully, but these errors were encountered: