Microsoft.Protocols.TestSuites.Common.NativeMethods.EcDoDisconnect C# (CSharp) Method

EcDoDisconnect() private method

private EcDoDisconnect ( IntPtr &pcxh ) : uint
pcxh System.IntPtr
return uint
        public static extern uint EcDoDisconnect(ref IntPtr pcxh);

Usage Example

Example #1
0
        /// <summary>
        /// It calls the native method EcDoDisconnect that closes a Session Context with the server.
        /// The Session Context is destroyed and all associated server state, objects, and resources that are associated with the Session Context are released.
        /// </summary>
        /// <param name="cxh">On input, contains the CXH of the Session Context that the client wants to disconnect.
        ///     On output, the server MUST clear the CXH to a zero value.</param>
        /// <returns>If the method succeeds, the return value is 0. If the method fails, the return value is an implementation-specific error code.</returns>
        public uint Disconnect(ref IntPtr cxh)
        {
            try
            {
                uint returnValue = NativeMethods.EcDoDisconnect(ref cxh);

                if (this.bindingHandle != IntPtr.Zero)
                {
                    bool rpcForceShutdownAssociation = bool.Parse(Common.GetConfigurationPropertyValue("RpcForceShutdownAssociation", this.site));
                    if (rpcForceShutdownAssociation)
                    {
                        uint status = NativeMethods.RpcBindingSetOption(this.bindingHandle, 13, 1); // 13 represents RPC_C_OPT_DONT_LINGER option
                        if (status != 0)
                        {
                            this.site.Assert.Fail("Failed to set option on the binding handle, the RpcBindingSetOption method returned status code: {0}", status);
                        }
                    }

                    NativeMethods.RpcBindingFree(ref this.bindingHandle);
                    this.bindingHandle = IntPtr.Zero;
                }

                return(returnValue);
            }
            catch (SEHException e)
            {
                this.site.Log.Add(LogEntryKind.Comment, "EcDoDisconnect throws exception, system error code is {0}, the error message is: {1}", RpcExceptionCode(e), (new Win32Exception((int)RpcExceptionCode(e))).ToString());

                // The exception in ECDoDisconnect should be ignored here.
                return(0);
            }
        }