fungos / cr

cr.h: A Simple C Hot Reload Header-only Library
https://fungos.github.io/cr-simple-c-hot-reload/
MIT License
1.57k stars 103 forks source link

Don't re-use version numbers after rollback #38

Closed Neopallium closed 5 years ago

Neopallium commented 5 years ago

I have re-worked the changes needed for cr-sys

This PR added a last_version field to cr_plugin to keep track of the last good version. This allows a rollback to skip over multiple crashing versions. This was the simplest way to skip over bad versions during a rollback.

Logic:

  1. plugin at version 1 -- last_version as at 1
  2. recompile: plugin reloads, now at version 2 -- last_version stays at 1
  3. recompile: plugin reloads, now at version 3 -- last_version is updated to 2, because version 2 didn't crash.
  4. version 3 crashes. rollback to version 2. -- last_version still at 2
  5. recompile: plugin reloads, now at version 4 -- last_version stays at 2
  6. version 4 crashes. rollback to version 2. -- last_version still at 2
  7. recompile: plugin reloads, now at version 5 -- last_version stays at 2
  8. recompile: plugin reloads, now at version 6 -- last_version is updated to 5 (version 5 didn't crash).
fungos commented 5 years ago

Thanks for this work!