3.3.4.5 TearDownContext (Opnum 4)

The TearDownContext method is invoked by either a primary partner or a secondary partner. When invoked by a primary partner, the TearDownContext method requests that the secondary partner begin the next step of tearing down a session. When invoked by a secondary partner, the TearDownContext method requests that the primary partner complete the teardown of the session. The Microsoft Interface Definition Language (MIDL) syntax of the method is as follows.

 HRESULT TearDownContext(
   [in, out] PPCONTEXT_HANDLE contextHandle,
   [in] SESSION_RANK sRank,
   [in] TEARDOWN_TYPE tearDownType
 );

contextHandle: An RPC context handle, returned by a call to BuildContext or BuildContextW, is correlated with a session object that is in the Active state. After TearDownContext is executed, on either success or failure requests, contextHandle will be set to null. For context handles, see [C706].

sRank: A SESSION_RANK enumerated value indicating whether the teardown request is being made by a primary partner or secondary partner. The teardown request MUST be sent from a primary partner only.

Value

Meaning

SRANK_PRIMARY

0x01

The caller is the primary partner in this session. The callee MUST be a secondary partner in this session, and the caller MUST be a primary partner in this session.

SRANK_SECONDARY

0x02

The caller is the secondary partner in this session. The callee MUST be a primary partner in this session, and the caller MUST be a secondary partner in this session.

tearDownType: The reason for tearing down the session. It MUST be one of the following values.

Value

Meaning

TT_FORCE

0x00

The session is being forcefully torn down.

TT_PROBLEM

0x02

The session is being torn down because an error has occurred.

Return Values: This method MUST return zero (0x00000000) on success. On failure, it MUST return an implementation-specific HRESULT. A client MUST NOT depend on implementation-specific failure HRESULT values. From an over-the-wire communication point of view, the client MUST implement only a behavior for the case when the call succeeds and another behavior for the case when the call does not succeed, (see section 3.4.6.2). Standard errors are defined in [MS-ERREF] section 2.2. A client MUST NOT exhibit behavior observable on the wire that is dependent on implementation-specific failure HRESULT values.

Return value/code

Description

0x00000000

ERROR_STATUS

The return value indicates success.

0x80070057

E_INVALIDARG

This value MAY be returned when an invalid sRank value is passed as a parameter.<27>

0x80004005

E_FAIL

This return value indicates that the session failed to tear down within the interval specified by the Session Teardown Timer (section 3.2.2.2).

Thereafter, the method has a different effect depending on the value of the sRank parameter and the value of the teardownType parameter.