Exemple #1
0
        void OnAllocateCallback(out uv_buf_t buf)
        {
            ReadOperation operation = this.unsafeChannel.PrepareRead();

            this.pendingReads.Offer(operation);
            buf = operation.GetBuffer();
        }
Exemple #2
0
            public Scratch()
            {
                byte[] scratch = ScratchBuf;
                _gcHandle = GCHandle.Alloc(scratch, GCHandleType.Pinned);
                IntPtr arrayHandle = _gcHandle.AddrOfPinnedObject();

                Buf = new uv_buf_t(arrayHandle, scratch.Length);
            }
Exemple #3
0
            public Ping(NativeHandle sentHandle) : base(uv_req_type.UV_WRITE, 0)
            {
                _sentHandle = sentHandle;
                byte[] array = PingBuf;
                Bufs = new uv_buf_t[1];

                GCHandle handle      = GCHandle.Alloc(array, GCHandleType.Pinned);
                IntPtr   arrayHandle = handle.AddrOfPinnedObject();

                _gcHandle = handle;

                Bufs[0] = new uv_buf_t(arrayHandle, array.Length);
            }
Exemple #4
0
        static void OnReadCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf)
        {
            var tcp    = GetTarget <Tcp>(handle);
            int status = (int)nread.ToInt64();

            OperationException error = null;

            if (status < 0 && status != NativeMethods.EOF)
            {
                error = NativeMethods.CreateError((uv_err_code)status);
            }

            tcp.OnReadCallback(status, error);
        }
Exemple #5
0
        static void OnReadCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf)
        {
            var tcp    = GetTarget <Tcp>(handle);
            int status = (int)nread.ToInt64();

            OperationException error = null;

            if (status < 0 && status != (int)uv_err_code.UV_EOF)
            {
                error = NativeMethods.CreateError((uv_err_code)status);
            }

            ReadOperation operation = tcp.pendingReads.Poll();

            if (operation == null)
            {
                if (error != null)
                {
                    // It is possible if the client connection resets
                    // causing errors where there are no pending read
                    // operations, in this case we just notify the channel
                    // for errors
                    operation = new ReadOperation(tcp.unsafeChannel, Unpooled.Empty);
                }
                else
                {
                    Logger.Warn("Channel read operation completed prematurely.");
                    return;
                }
            }

            try
            {
                operation.Complete(status, error);
            }
            catch (Exception exception)
            {
                Logger.Warn("Channel read callbcak failed.", exception);
            }
        }
Exemple #6
0
 void OnAllocateCallback(out uv_buf_t buf)
 {
     buf = this.scratch.Buf;
 }
Exemple #7
0
        static void OnAllocateCallback(IntPtr handle, IntPtr suggestedSize, out uv_buf_t buf)
        {
            var pipe = GetTarget <Pipe>(handle);

            pipe.OnAllocateCallback(out buf);
        }
Exemple #8
0
        static void OnReadCallback(IntPtr handle, IntPtr nread, ref uv_buf_t buf)
        {
            var pipe = GetTarget <Pipe>(handle);

            pipe.OnReadCallback((int)nread.ToInt64());
        }
Exemple #9
0
        static void OnAllocateCallback(IntPtr handle, IntPtr suggestedSize, out uv_buf_t buf)
        {
            var tcp = GetTarget <Tcp>(handle);

            tcp.OnAllocateCallback(out buf);
        }
Exemple #10
0
 void OnAllocateCallback(out uv_buf_t buf)
 {
     buf = _nativeUnsafe.PrepareRead(_pendingRead);
 }