I opted to implement a manual deactivate for floating licences (instead of automatically deactivate at the exit of the last instance), as it turned out to be pretty hard to reliably count the instances.
I also hoped this would be more robust to short outages of the internet. With an automatic deactivate, borrowing as described in the manual wouldn’t be possible, as the activate on the next start would need internet.
Borrowing floating licenses
Borrowing floating licenses for offline usage is supported out of the box. You just need to increase the
leaseDuration to the amount of time you wish to lease the license for offline usage.
When having a borrowed licence (eg. before lease duration expired) while the machine is offline, a callback registered by
SetLicenseCallback is being called straight away with a network error. I therefore opted to ignore network errors on the callback, otherwise it would exit the instance right after the start when being offline. On the next sync callbacks, when the lease duration has expired, the callback is just giving the same network error. The lincence will therefore run indefintely long when offline (going back online will detect that the licence expired and exit).
I can’t easily handle that case myself as I don’t want to make any hardcoded assumption about lease duration. I would expect LexActivator to call the callback function with a distinct error code to know that the lease expired and the activation couldn’t be renewed when offline.
Any suggestions on how to handle offline situations correctly in the callback?
I have another question about
IsLicenseGenuine. Documentation says that it starts the background thread to do the sync and call the callback. I couldn’t find following info in the documentation:
IsLicenseGenuine returns something different than
LA_OK, is the background thread still started?
- Is it safe to call
IsLicenseGenuine multiple times, or will this start multiple background threads for sync?