Corrected demo COV handler for indefinite lifetime.
This commit is contained in:
@@ -380,6 +380,35 @@ static bool cov_send_request(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cov_lifetime_expiration_handler(
|
||||||
|
unsigned index,
|
||||||
|
uint32_t elapsed_seconds,
|
||||||
|
uint32_t lifetime_seconds)
|
||||||
|
{
|
||||||
|
if (index < MAX_COV_SUBCRIPTIONS) {
|
||||||
|
/* handle lifetime expiration */
|
||||||
|
if (lifetime_seconds >= elapsed_seconds) {
|
||||||
|
COV_Subscriptions[index].lifetime -= elapsed_seconds;
|
||||||
|
#if 0
|
||||||
|
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n",
|
||||||
|
index, (unsigned long) COV_Subscriptions[index].lifetime);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
COV_Subscriptions[index].lifetime = 0;
|
||||||
|
}
|
||||||
|
if (COV_Subscriptions[index].lifetime == 0) {
|
||||||
|
/* expire the subscription */
|
||||||
|
COV_Subscriptions[index].flag.valid = false;
|
||||||
|
if (COV_Subscriptions[index].flag.issueConfirmedNotifications) {
|
||||||
|
if (COV_Subscriptions[index].invokeID) {
|
||||||
|
tsm_free_invoke_id(COV_Subscriptions[index].invokeID);
|
||||||
|
COV_Subscriptions[index].invokeID = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Handler to check the list of subscribed objects for any that have changed
|
/** Handler to check the list of subscribed objects for any that have changed
|
||||||
* and so need to have notifications sent.
|
* and so need to have notifications sent.
|
||||||
* @ingroup DSCOV
|
* @ingroup DSCOV
|
||||||
@@ -404,30 +433,19 @@ static bool cov_send_request(
|
|||||||
void handler_cov_timer_seconds(
|
void handler_cov_timer_seconds(
|
||||||
uint32_t elapsed_seconds)
|
uint32_t elapsed_seconds)
|
||||||
{
|
{
|
||||||
int index = 0;
|
unsigned index = 0;
|
||||||
uint32_t lifetime_seconds = 0;
|
uint32_t lifetime_seconds = 0;
|
||||||
|
|
||||||
/* handle the subscription timeouts */
|
if (elapsed_seconds) {
|
||||||
for (index = 0; index < MAX_COV_SUBCRIPTIONS; index++) {
|
/* handle the subscription timeouts */
|
||||||
if (COV_Subscriptions[index].flag.valid) {
|
for (index = 0; index < MAX_COV_SUBCRIPTIONS; index++) {
|
||||||
/* handle timeouts */
|
if (COV_Subscriptions[index].flag.valid) {
|
||||||
lifetime_seconds = COV_Subscriptions[index].lifetime;
|
lifetime_seconds = COV_Subscriptions[index].lifetime;
|
||||||
if (lifetime_seconds >= elapsed_seconds) {
|
if (lifetime_seconds) {
|
||||||
COV_Subscriptions[index].lifetime -= elapsed_seconds;
|
/* only expire COV with definite lifetimes */
|
||||||
#if 0
|
cov_lifetime_expiration_handler(index,
|
||||||
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n",
|
elapsed_seconds,
|
||||||
index, (unsigned long) COV_Subscriptions[index].lifetime);
|
lifetime_seconds);
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
COV_Subscriptions[index].lifetime = 0;
|
|
||||||
}
|
|
||||||
if (COV_Subscriptions[index].lifetime == 0) {
|
|
||||||
COV_Subscriptions[index].flag.valid = false;
|
|
||||||
if (COV_Subscriptions[index].flag.issueConfirmedNotifications) {
|
|
||||||
if (COV_Subscriptions[index].invokeID) {
|
|
||||||
tsm_free_invoke_id(COV_Subscriptions[index].invokeID);
|
|
||||||
COV_Subscriptions[index].invokeID = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user