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

Avm is initialized in a single place #1050

Merged
merged 2 commits into from
Oct 29, 2019
Merged

Avm is initialized in a single place #1050

merged 2 commits into from
Oct 29, 2019

Conversation

aionick
Copy link
Contributor

@aionick aionick commented Oct 29, 2019

  • We had a problem where the avm was being initialized in multiple places
    for different CLI arguments, and was even not being initialized at times
    it should be. This change fixes these issues by initializing the avm in
    a single place that all CLI variations have to pass through.
  • This change also fixes AKI-457 by checking that the thread owns the avm
    lock before calling release on it first.

Description

Fixes Issue # .

Type of change

  • Bug fix.
  • New feature.
  • Enhancement.
  • Unit test.
  • Breaking change (a fix or feature that causes existing functionality to not work as expected).
  • Requires documentation update.

Testing

@@ -82,6 +82,7 @@ public static void main(String args[]) {

ReturnType ret = new Cli().call(args, cfg);
if (ret != ReturnType.RUN) {
shutdownAvm();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can call System.exit from other parts of the code. Perhaps a better place for the AVM shutdown would be in the ShutdownHook thread defined below (around line 350).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shutdownAvm call is in the ShutdownHook, but that hook has not been registered at this point, so I had to include it also for a few of the early returns we make

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we register the hook first thing and it just knows whether a component has been started/loaded and how to shut it down if so, but as it stands that's one of the last things we run in the main method because we wait for everything to be started up first

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. Looks good to me.

@aionick aionick force-pushed the avm-init branch 2 times, most recently from afad7dc to b4646d1 Compare October 29, 2019 19:35
@AionJayT AionJayT added the bug Something isn't working label Oct 29, 2019
@AionJayT AionJayT added this to the 1.0 Denali (Unity consensus) milestone Oct 29, 2019
- We had a problem where the avm was being initialized in multiple places
  for different CLI arguments, and was even not being initialized at times
  it should be. This change fixes these issues by initializing the avm in
  a single place that all CLI variations have to pass through.
- This required gaining control over when we want the avm initialized in
  the CLI call path so that tests could run against these changes and not
  trip up over trying to re-initialize the avm.
- We can get into legitimate situations where we try to shut down the
  avm but we do not actually own the lock. In that case an exception is
  thrown when we try to release this. This fix just ensures that we only
  release it if we are the owner of the lock.
@AionJayT AionJayT merged commit 8eb8954 into master Oct 29, 2019
@aionick aionick deleted the avm-init branch October 30, 2019 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants