TurboFloat LeaseCallback not getting called

After getting to the point where my app is successfully loading TurboFloat.dll, I'm running into a new issue, and I'm not sure how to go about debugging so I thought I would start a new thread.

My app is a plugin to a host app. I can see that when I first startup my plugin, the TurboFloat server I am running locally does recognize it and my app gets a license from the server. That's a huge win. Now, I would expect that after having registered the callback function in my code that the server would call the LeaseCallback. Alas, it is not.

Here's how I've implemented the request for the release. It's not much different than the example, and it seems to work:

#if LIC_FLOATING hr = TF_PDetsFromPath(datFile); tfHandle = TF_GetHandle(TA_GUID); hr = TF_SetLeaseCallback(tfHandle, LeaseCallback); hr = TF_RequestLease(tfHandle);

if (hr == TF_E_SERVER) { //TODO: Think of best way to get the IP address and port into this code hr = TF_SaveServer(tfHandle, _T("127.0.0.1"), 13, TF_SYSTEM);

if (hr != TF_OK) { printf("Failed to save the server details (TF_SaveServer() returned %d). Look in TurboFloat.h for a human readable explanation of the error.\n", hr); return 1; }

hr=TF_RequestLease(tfHandle); }

if (hr != TF_OK) { printf("Failed to get the floating license lease (TF_RequestLease() returned %d). Look in TurboFloat.h for a human readable explanation of the error.\n", hr); return 1; } #endif

Here's my lease callback implementation.

#if LIC_FLOATING void TF_CC LeaseCallback(uint32_t status) { std::cerr << status << std::endl; switch(status) { case TF_CB_FEATURES_CHANGED:

registered = true; printf("\n[APP] License Lease Callback: Success! Floating licensing server registered lease!"); break;

case TF_CB_EXPIRED: case TF_CB_EXPIRED_INET: default: //TODO: Disallow any features in your app. registered = false; printf("\n[APP] License Lease Callback: Floating licensing server canceled license lease."); break;

} }#endif

Now, when I place breakpoints on the switch line, my plugin's code won't break there. I also do not see any debug / error output for the status variable. However, I do see this in the debug output after I see that the floating licensing server issues the license:

First-chance exception at 0x00007FFF9105871C in {hostapp}.exe: Microsoft C++ exception: boost::interprocess::interprocess_exception at memory location 0x0000000000839630.First-chance exception at 0x00007FFF9105871C in {hostapp}.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x0000000000838F18.First-chance exception at 0x00007FFF9105871C in {hostapp}.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x0000000000839038.

I'm wondering if TurboFloat exists in some kind of thread created by boost. Any thoughts on how to at least troubleshoot / debug?

Thanks,Arie

After some debugging, and some research, I think my plugin needs to create a new thread to accept arbitrary incoming requests coming in from the floating license server. Here's what I've done, but am getting a build error:

...#include <thread>...

//Then in the main "setup" function of my plugin i have

...limelmThread = new thread(LeaseCallback);hr = TF_PDetsFromPath(datFile);tfHandle = TF_GetHandle(TA_GUID);hr = TF_SetLeaseCallback(tfHandle, LeaseCallback);hr = TF_RequestLease(tfHandle);

When I build I get this error, which I think has to do with the way / method I"m creating the thread:

Error 1 error C2198: 'void (__cdecl *)(uint32_t)' : too few arguments for call C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\functional 1152 1 TemplaterSettings

Any ideas?

Well, first of all the LeaseCallback function is rarely called. If your app is requesting leases (and getting renewals), but none of the custom license fields are changed, then TurboFloat won't call the callback at all. It will just handle the new lease times internally. It won't bother touching your code (because there's no reason to).

Your app can keep running under the assumption that everything is working as expected.

So, I think the real problem is that you're expecting the callback function to be called often, and it won't be (by design).

I think my plugin needs to create a new thread to accept arbitrary incoming requests coming in from the floating license server.

No, don't do that. The LeaseCallback function is already called from another thread (created and managed internally in the TurboFloat library). Just follow the example code -- that's the best way to implement it.

First-chance exception at 0x00007FFF9105871C in {hostapp}.exe: Microsoft C++ exception: boost::interprocess::interprocess_exception at memory location 0x0000000000839630.First-chance exception at 0x00007FFF9105871C in {hostapp}.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x0000000000838F18.First-chance exception at 0x00007FFF9105871C in {hostapp}.exe: Microsoft C++ exception: std::ios_base::failure at memory location 0x0000000000839038.

I don't know what that's from. If you're just dumping any and all exceptions that are thrown / caught, then you'll get a lot of noise . Some exceptions are normal behavior that TurboFloat handles internally.

A good way to test if your LeaseCallback function is working correctly, here's a good method:

  1. Set the lease length to a small number, like 30 seconds: http://wyday.com/limelm/help/turbofloat-server/#config-lease
  2. Restart the TFS.
  3. Run your app, make sure it successfully requests a lease.
  4. Stop the TFS instance.
  5. Wait 30-ish seconds -- your lease callback function will be called.

Does that make sense?

Thanks for the testing steps, Wyatt. I'll run that test.

I guess that I want some code to execute when my plugin app successfully gets a lease for the first time so I can enable features, and then some code to execute after the server takes back the lease.

Maybe my conceptual model for how TurboFloat works is incorrect. Do I enable all my app's features by default and only if it doesn't get a lease from the server do I disable features? I've been going off the assumption that I disable all the features by default and only if it gets a license from the server would I enable specific features.

Sorry if this sounds confusing, but I don't understand it yet fully.

Thanks,Arie

Well, the example app shows what you should do, and the help article explains the process: http://wyday.com/limelm/help/using-turbofloat-with-c-plus-plus/

Is there something in particular in the article that's not clear?