Beispiel #1
0
        internal static DeliveryImpl AllocationEndpointDeliveryImpl(
            Allocation * /*EndpointCore* opt(ExHeap)!*/ endpoint)
        {
            EndpointCore *ep = (EndpointCore *)Allocation.GetData(endpoint);

            if (ep == null)
            {
                return(null);
            }
            else
            {
                return(ep->EndpointDeliveryImpl);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Performs the initialization of the core part of each endpoint and cross links
        /// them to form a channel.  Uses the given delivery mechanism.
        /// </summary>
        public static void Connect(
            Allocation * /*EndpointCore* opt(ExHeap)!*/ imp,
            Allocation * /*EndpointCore* opt(ExHeap)!*/ exp,
            Allocation * /*EndpointCore* opt(ExHeap)!*/ securityEp,
            string deliveryImplType)
        {
            if (imp == null || exp == null)
            {
                throw new ApplicationException("Connect called with null endpoints");
            }
            EndpointCore *impData = (EndpointCore *)Allocation.GetData(imp);
            EndpointCore *expData = (EndpointCore *)Allocation.GetData(exp);

            if (impData == null || expData == null)
            {
                throw new ApplicationException("SharedHeap.GetData return null");
            }

            Tracing.Log(Tracing.Debug, "connect {0:x8} and {1:x8}",
                        (UIntPtr)imp, (UIntPtr)exp);

            if (!(DeliveryHandle.Create(deliveryImplType, imp, out impData->deliveryHandle) &&
                  DeliveryHandle.Create(deliveryImplType, exp, out expData->deliveryHandle)))
            {
                throw new EndpointCoreException(
                          "Error trying to create EndpointCore using \"" +
                          deliveryImplType +
                          "\" delivery implementation");
            }
#if false
            DebugStub.Print("imp handle {0,8:x} exp handle {1,8:x}\n",
                            __arglist((uint)impData->deliveryHandle.id, (uint)expData->deliveryHandle.id));
#endif
            DeliveryImpl impDi = impData->EndpointDeliveryImpl;
            DeliveryImpl expDi = expData->EndpointDeliveryImpl;

            VTable.Assert(impDi != null && expDi != null);

            impDi.Connect(expDi, securityEp);

            // keep track of how many channels are open
            Interlocked.Increment(ref openChannelCount);
#if CHANNEL_COUNT
            PerfCounters.IncrementChannelsCreated();
#endif
            Monitoring.Log(Monitoring.Provider.EndpointCore,
                           (ushort)EndpointCoreEvent.Connect, 0,
                           (uint)expData->ChannelId, 0, 0, 0, 0);
        }
Beispiel #3
0
        ////////////////////////////////////////////////////////////////////
        // Class Methods
        //

        internal DeliveryImpl(Allocation * /*EndpointCore* opt(ExHeap)!*/ ep)
        {
            this.endpointAlloc = ep;
            this.endpoint      = ((EndpointCore *)Allocation.GetData(ep));

            // set default values (shadow cached values in EndpointCore if necessary)
            setMessageEvent(new AutoResetEventHandle(
                                Process.kernelProcess.AllocateHandle(new AutoResetEvent(false))));
            endpoint->CollectionEvent = new AutoResetEventHandle();

            endpoint->SetCachedPeer(null);    // set as null by default

            ProcessId = Thread.CurrentProcess.ProcessId;
            ChannelId = 0;                    // zero initially, corrected in connect
            Marshall  = false;                // false by default
            Closed    = true;                 // opened in connect

            principalHandle = new PrincipalHandle(Thread.CurrentProcess.Principal.Val);
            delegationState = DelegationState.None;
            receiveCount    = 0;
        }