fungos / cr

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

Don't re-use version numbers after a rollback. #36

Closed Neopallium closed 5 years ago

Neopallium commented 5 years ago

This PR checks if new_file exists and increase the version until it files a free version.

If old version files are left over from a previous run, then the plugin will not start at version 1.

I am not sure if this is the best fix for the problem. Not sure what is keeping the old versions mapped and why dlopen/dlsym fails to load a new copy with the same name as an old version.

fungos commented 5 years ago

Hi, thanks for contributing back! :) So, this is weird, I can't recall having seen this issue. I think it would be interesting to understand what is really happening as it can be a real issue somewhere else. Also, I'm not sure about skipping version numbers, because now when roll backing we may not go exactly to the previous working version.

Neopallium commented 5 years ago

I would also like to find the root cause and understand it.

For the rollback issue, I just keep a HashSet of bad versions and skip over them.

Neopallium commented 5 years ago

I am reworking this change. Closing this PR and will open another.