Example #1
0
void
v_deadLineInstanceListRemoveInstance(
    v_deadLineInstanceList list,
    v_instance instance)
{
    assert(C_TYPECHECK(list,v_deadLineInstanceList));
    assert((instance->prev != NULL) && (instance->next != NULL));
    assert(c_refCount(list) > 0);
    assert(c_refCount(instance) > 0);

    /* As the instance is removed, there is no need to update the lease.
     * Updating the lease might trigger the leasemanager thread to determine
     * the next expiry time. The next expiry time can also be determined on
     * the next deadline check, which is more efficient as the administration
     * might already have changed many times.
     */
    v_instanceRemove(instance);
    if (v_instanceAlone(v_instance(list))) { /* list has become empty */
        if (list->deadlineLease != NULL) {
            v_leaseManagerDeregister(list->leaseManager, list->deadlineLease);
            c_free(list->deadlineLease);
            list->deadlineLease = NULL;
        }
    }
}
Example #2
0
void
v_instanceDeinit(
    v_instance instance)
{
    assert(C_TYPECHECK(instance, v_instance));
    /* possible since next and prev are void pointers,
     * so c_free does not crash on this */
    v_instanceRemove(instance);
}
Example #3
0
void
v_deadLineInstanceListUpdate(
    v_deadLineInstanceList list,
    v_instance instance)
{
    assert(C_TYPECHECK(instance,v_instance));
    assert(C_TYPECHECK(list,v_deadLineInstanceList));
    assert(c_refCount(list) > 0);
    assert(c_refCount(instance) > 0);

    /* This will also place the current instance at the end of the list.
       Again no need to update the lease, we can determine the next wake-up
       as soon as the next deadlinecheck is performed.
    */
    if (v_instanceAlone(instance)) {
        v_deadLineInstanceListInsertInstance(list,instance);
    } else {
        v_instanceRemove(instance);
        v_instanceUpdate(instance); /* Updates instance checkTime */
        v_instanceAppend(v_instance(list), instance);
    }
}