コード例 #1
0
ファイル: v_deliveryWaitList.c プロジェクト: xrl/opensplice
v_result
v_deliveryWaitListIgnore (
    v_deliveryWaitList _this,
    v_gid readerGID)
{
    c_ulong size, i, count;
    v_gid *list;

    assert(C_TYPECHECK(_this,v_deliveryWaitList));

    count = 0;
    size = c_arraySize(_this->readerGID);
    list = (v_gid *)_this->readerGID;
    for (i=0; i<size; i++) {
        if (v_gidEqual(list[i],readerGID)) {
            /* Set the found reader gid to zero,
             * iThe waitlist can be unblocked when
             * all expected systemIds are zero.
             * In that case count will be 0.
             */
            v_gidSetNil(list[i]);
        }
        count += v_gidSystemId(list[i]);
    }
    if (count == 0) {
        c_free(_this->readerGID);
        _this->readerGID = NULL;
        c_mutexLock(&_this->mutex);
        c_condSignal(&_this->cv);
        c_mutexUnlock(&_this->mutex);
    }
    return V_RESULT_OK;
}
コード例 #2
0
ファイル: v_policy.c プロジェクト: osrf/opensplice
static v_ownershipResult claimOwnership(
    struct v_owner *owner,
    const struct v_owner *candidate,
    v_state messageState)
{
    v_ownershipResult result;

    if (v_stateTest(messageState, L_REGISTER)) {
        /* Don't modify anything: a register does not change state (yet). */
        result = V_OWNERSHIP_NOT_OWNER;
    } else if (v_stateTest(messageState, L_UNREGISTER)) {
        /* If the current owner unregisters, the ownership is reset. */
        v_gidSetNil (owner->gid);
        owner->strength = 0;
        result = V_OWNERSHIP_OWNER_RESET;
    } else {
        owner->gid = candidate->gid;
        owner->strength = candidate->strength;
        result = V_OWNERSHIP_OWNER;
    }
    return result;
}
コード例 #3
0
ファイル: v_deliveryWaitList.c プロジェクト: xrl/opensplice
v_result
v_deliveryWaitListNotify (
    v_deliveryWaitList _this,
    v_deliveryInfoTemplate msg)
{
    c_ulong size, i, count;
    v_gid *list;

    assert(C_TYPECHECK(_this,v_deliveryWaitList));
    assert(msg);

    list = (v_gid *)_this->readerGID;
    if(msg->userData.sequenceNumber == _this->sequenceNumber)
    {
        count = 0;
        
        size = c_arraySize(_this->readerGID);
        for (i=0; i<size; i++) {
            if (v_gidEqual(list[i],msg->userData.readerGID)) {
                /* Set the found readerGID to zero,
                 * iThe waitlist can be unblocked when
                 * all expected systemIds are zero.
                 * In that case count will be 0.
                 */
                v_gidSetNil(list[i]);
            }
            count += v_gidSystemId(list[i]);
        }
        if (count == 0) {
            c_free(_this->readerGID);
            _this->readerGID = NULL;
            c_mutexLock(&_this->mutex);
            c_condSignal(&_this->cv);
            c_mutexUnlock(&_this->mutex);
        }
    }
    return V_RESULT_OK;
}
コード例 #4
0
ファイル: v_policy.c プロジェクト: osrf/opensplice
v_ownershipResult
v_determineOwnershipByStrength (
    struct v_owner *owner,
    const struct v_owner *candidate,
    v_state messageState)
{
    c_equality equality;
    v_ownershipResult result;

    assert (owner != NULL);
    assert (candidate != NULL);

    if (owner->exclusive == TRUE) {
        if (v_gidIsValid (candidate->gid)) {
            if (owner->exclusive == candidate->exclusive) {
                if (v_gidIsValid (owner->gid)) {
                    equality = v_gidCompare (owner->gid, candidate->gid);

                    if (candidate->strength > owner->strength) {
                        if (equality == C_EQ) {
                            result = V_OWNERSHIP_ALREADY_OWNER;
                            owner->strength = candidate->strength;
                        } else {
                            result = claimOwnership(owner, candidate, messageState);
                        }
                    } else if (candidate->strength < owner->strength) {
                        if (equality == C_EQ) {
                            /* The current message comes from the a writer,
                             * which is the owner AND which lowered it's
                             * strength. The strength associated with the
                             * ownership must be updated.
                             */
                            owner->strength = candidate->strength;
                            result = V_OWNERSHIP_ALREADY_OWNER;
                        } else {
                            result = V_OWNERSHIP_NOT_OWNER;
                        }
                    } else {
                        if (equality == C_LT) {
                            result = V_OWNERSHIP_NOT_OWNER;
                        } else {
                            result = claimOwnership(owner, candidate, messageState);
                        }
                    }
                } else {
                    /* When the owner is not valid, nobody can claim ownership naturally because
                     * the smallest GID always wins. So enforce ownership transfer explicitly.
                     */
                    result = claimOwnership(owner, candidate, messageState);
                }
            } else {
                result = V_OWNERSHIP_INCOMPATIBLE_QOS;
            }
        } else {
            v_gidSetNil (owner->gid);
            owner->strength = 0;
            result = V_OWNERSHIP_OWNER_RESET;
        }
    } else {
        result = V_OWNERSHIP_SHARED_QOS;
    }

    return result;
}