Pinoccio/library-pinoccio — pull request #140 by emcmillan (2014-06-20 19:11:42+00:00)
Title: Expose temporary flag for key()

Exposes the (pre-existing) temporary flag for the key() command so that keys can expire as soon as the bitlash call ends. This allows the use of temporary keys without introducing a key leak that could eventually fill the key table with no way to free them. For example:

loop()
{
hq.report("uptime", key(uptime.minutes));
delay(60000);
}

would fill the key table in ~13 minutes (there's 51 default keys, and a key table max size of 64). With this update:

loop()
{
hq.report("uptime", key(uptime.minutes, 1));
delay(60000);
}

would run forever since the key is freed as soon as the hq.report command ends.

Two notes: The comments in key.c indicate there was thought of having the keys time-out after a certain interval indicated by the "at" variable, but that hasn't been implemented yet. This code may need to be tweaked if/when that happens.

Secondly, these changes will also need to be made to keyMap_int() if/when that pull-request is approved.