nn::nex::PromotionReferee::RegisterAffinityValidationCallback Member Function

Syntax

static void RegisterAffinityValidationCallback(
     ValidateAffinityCallback pfValidateAffinity
);

Parameters

Name Description
in pfValidateAffinity Pointer to the ValidateAffinityCallback callback function, which validates a station's affinity level.

Return Values

None.

Description

Registers a callback for validating the station's level of affinity.

This method is called by the PromotionReferee for the given station. Below is an example of the use of ValidateAffinityCallback. In this example, server processes have affinity levels of 1 through 101, and client processes have an affinity level of 0. Stations are tested to see whether the affinity levels they claims to have are valid.

Implementation Example


qByte DoubleCheckThatServerTakesOver(DOHandle hObject, DOHandle hCalleeStation, qByte byAffinity) {
    // Callee station hCalleeStation proposes an affinity, so we check
    // if is a valid value.  Clients are cheating if the value
    // is not zero. Servers are cheating (or most probably there is a
    // bug in the callback that reports affinity) if the value is not
    // between 1 and 101.
    Station::Ref refCallee(hCalleeStation);
    // Callee must be valid, since it sent me a message!
    SYSTEMCHECK(refCallee.IsValid());
    if (refCallee->GetProcessType()==Station::ServerProcess) {
        SYSTEMCHECK(byAffinity>0);
        return byAffinity;
    } else {
        // This is not a server.
        if (byAffinity > 0) {
            // Then the station must be cheating.  At this point, we
            // could decide to flag the station as a cheater and take
            // action.  We also report 0 as the affinity and ignore
            // whatever value the station claimed.
            return 0;
        }
        return byAffinity;
    }
}

See Also

RegisterAffinityCallback

Revision History

2011/06/02
Initial version.

CONFIDENTIAL