Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Prevent stopping non-persistent jails twice #155

Merged
merged 2 commits into from
Jun 20, 2021

Conversation

grembo
Copy link
Collaborator

@grembo grembo commented Jun 19, 2021

This aims to address #152.

The problem at hand isn't really to prevent pot stop from
running in parallel (this could be handled on a global level),
but to prevent running "_js_stop" in pot start, after a
non-persistent jail was stopped.

The solution is very simple, as the use case this is about is:

  1. pot stop is called
  2. jail -r is called
  3. pot start continues and calls "_js_stop"

By removing a file (and touching it when running "_js_stop")
this can be prevented without having to use real lock files.

Note: Given the number of files pot creates, it might make sense
to start using a subdirectory called /tmp/pot.

This aims to address bsdpot#152.

The problem at hand isn't really to prevent `pot stop` from
running in parallel (this could be handled on a global level),
but to prevent running "_js_stop" in `pot start`, after a
non-persistent jail was stopped.

The solution is very simple, as the use case this is about is:
1. pot stop is called
2. jail -r is called
3. pot start continues and calls "_js_stop"

By removing a file (and touching it when running "_js_stop")
this can be prevented without having to use real lock files.

Note: Given the number of files pot creates, it might make sense
to start using a subdirectory called _/tmp/pot_.
@grembo
Copy link
Collaborator Author

grembo commented Jun 19, 2021

@pizzamig I hope I don't duplicate your work here - it's very little code though, so the damage done is limited :)

@pizzamig
Copy link
Collaborator

I didn't start yet, I was enjoying the hot day today and I was planning to prepare it tomorrow.
However, I'll run some tests on it.
Even if touching a file is not atomic (a small time window when the jail exits and pot stop is in execution) I think it's good enough, using lockf seems a major rework for a small benefit

@grembo
Copy link
Collaborator Author

grembo commented Jun 19, 2021

It was so hot today, the only thing I could move was my fingers :)

@pizzamig pizzamig merged commit fce2c9d into bsdpot:master Jun 20, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants