コード例 #1
0
        /// <summary>
        /// Execute the receive task on the socket.
        /// </summary>
        /// <param name="input">Raw input to read client commands and pack data from. Caller must ensure the input is buffered, otherwise read performance may suffer. Response back to the Git network client. Caller must ensure the output is buffered, otherwise write performance may suffer.</param>
        /// <param name="messages">Secondary "notice" channel to send additional messages out through. When run over SSH this should be tied back to the standard error channel of the command execution. For most other network connections this should be null.</param>
        public void receive(Stream input, Stream output, Stream messages)
        {
            try
            {
                rawInput  = input;
                rawOutput = output;

                pckIn  = new PacketLineIn(rawInput);
                pckOut = new PacketLineOut(rawOutput);

                // TODO: [henon] port jgit's timeout behavior which is obviously missing here

                if (messages != null)
                {
                    msgs = new StreamWriter(messages, Constants.CHARSET);
                }

                enabledCapabilities = new List <string>();
                commands            = new List <ReceiveCommand>();

                Service();
            }
            finally
            {
                try
                {
                    if (pckOut != null)
                    {
                        pckOut.Flush();
                    }
                    if (msgs != null)
                    {
                        msgs.Flush();
                    }
                    if (sideBand)
                    {
                        // If we are using side band, we need to send a final
                        // flush-pkt to tell the remote peer the side band is
                        // complete and it should stop decoding. We need to
                        // use the original output stream as rawOut is now the
                        // side band data channel.
                        //
                        new PacketLineOut(output).End();
                    }
                }
                finally
                {
                    // TODO : [nulltoken] Aren't we missing some Dispose() love, here ?
                    UnlockPack();
                    rawInput            = null;
                    rawOutput           = null;
                    pckIn               = null;
                    pckOut              = null;
                    msgs                = null;
                    refs                = null;
                    enabledCapabilities = null;
                    commands            = null;
                }
            }
        }
コード例 #2
0
        public void Execute(Stream inout)
        {
            Stream = inout;
            string cmd = new PacketLineIn(inout).ReadStringRaw();

            if (string.IsNullOrEmpty(cmd))
            {
                return;
            }

            int nul = cmd.IndexOf('\0');

            if (nul >= 0)
            {
                cmd = cmd.Slice(0, nul);
            }

            DaemonService srv = Daemon.MatchService(cmd);

            if (srv == null)
            {
                return;
            }
            srv.Execute(this, cmd);
        }
コード例 #3
0
 public SideBandInputStream(PacketLineIn aPckIn, Stream aIns, ProgressMonitor aProgress)
 {
     pckIn = aPckIn;
     ins = aIns;
     monitor = aProgress;
     currentTask = string.Empty;
     progressBuffer = string.Empty;
 }
コード例 #4
0
 public SideBandInputStream(Stream @in, ProgressMonitor progress)
 {
     rawIn          = @in;
     pckIn          = new PacketLineIn(rawIn);
     monitor        = progress;
     currentTask    = string.Empty;
     progressBuffer = string.Empty;
 }
コード例 #5
0
 public SideBandInputStream(PacketLineIn aPckIn, Stream aIns, ProgressMonitor aProgress)
 {
     pckIn          = aPckIn;
     ins            = aIns;
     monitor        = aProgress;
     currentTask    = string.Empty;
     progressBuffer = string.Empty;
 }
コード例 #6
0
        protected void init(Stream instream, Stream outstream)
        {
            inStream  = instream is BufferedStream ? instream : new BufferedStream(instream, IndexPack.BUFFER_SIZE);
            outStream = outstream is BufferedStream ? outstream : new BufferedStream(outstream, IndexPack.BUFFER_SIZE);

            pckIn  = new PacketLineIn(inStream);
            pckOut = new PacketLineOut(outStream);

            outNeedsEnd = true;
        }
コード例 #7
0
        /// <summary>
        /// Execute the upload task on the socket.
        /// </summary>
        /// <param name="input">
        /// raw input to read client commands from. Caller must ensure the
        /// input is buffered, otherwise read performance may suffer.
        /// </param>
        /// <param name="output">
        /// response back to the Git network client, to write the pack
        /// data onto. Caller must ensure the output is buffered,
        /// otherwise write performance may suffer.
        /// </param>
        /// <param name="messages">
        /// secondary "notice" channel to send additional messages out
        /// through. When run over SSH this should be tied back to the
        /// standard error channel of the command execution. For most
        /// other network connections this should be null.
        /// </param>
        /// <exception cref="IOException"></exception>
        public void Upload(Stream input, Stream output, Stream messages)
        {
            _rawIn  = input;
            _rawOut = output;

            if (_timeout > 0)
            {
                var i = new TimeoutStream(_rawIn, _timeout * 1000);
                var o = new TimeoutStream(_rawOut, _timeout * 1000);
                _rawIn  = i;
                _rawOut = o;
            }

            _pckIn  = new PacketLineIn(_rawIn);
            _pckOut = new PacketLineOut(_rawOut);
            Service();
        }
コード例 #8
0
        public void Execute(Stream inout)
        {
            Stream = inout;
            string cmd = new PacketLineIn(inout).ReadStringRaw();
            if (string.IsNullOrEmpty(cmd))
                return;

            int nul = cmd.IndexOf('\0');
            if (nul >= 0)
            {
                cmd = cmd.Slice(0, nul);
            }

            DaemonService srv = Daemon.MatchService(cmd);
            if (srv == null)
                return;
            srv.Execute(this, cmd);
        }
コード例 #9
0
        public override void Close()
        {
            if (outStream != null)
            {
                try
                {
                    if (outNeedsEnd)
                    {
                        pckOut.End();
                    }
                    outStream.Close();
                }
                catch (IOException)
                {
                    // Ignore any close errors.
                }
                finally
                {
                    outStream = null;
                    pckOut    = null;
                }
            }

            if (inStream != null)
            {
                try
                {
                    inStream.Close();
                }
                catch (IOException)
                {
                    // Ignore any close errors.
                }
                finally
                {
                    inStream = null;
                    pckIn    = null;
                }
            }

#if DEBUG
            GC.SuppressFinalize(this); // Disarm lock-release checker
#endif
        }
コード例 #10
0
ファイル: ReceivePack.cs プロジェクト: kkl713/GitSharp
        public void receive(Stream stream, Stream messages)
        {
            try
            {
                raw = stream;

                pckIn  = new PacketLineIn(raw);
                pckOut = new PacketLineOut(raw);

                if (messages != null)
                {
                    msgs = new StreamWriter(messages);
                }

                enabledCapabilities = new List <string>();
                commands            = new List <ReceiveCommand>();

                Service();
            }
            finally
            {
                try
                {
                    if (msgs != null)
                    {
                        msgs.Flush();
                    }
                }
                finally
                {
                    UnlockPack();
                    raw    = null;
                    pckIn  = null;
                    pckOut = null;
                    msgs   = null;
                    refs   = null;
                    enabledCapabilities = null;
                    commands            = null;
                }
            }
        }
コード例 #11
0
        public override void Close()
        {
            if (inStream != null)
            {
                try
                {
                    inStream.Close();
                }
                catch (IOException)
                {

                }
                finally
                {
                    inStream = null;
                    pckIn = null;
                }
            }

            if (outStream != null)
            {
                try
                {
                    if (outNeedsEnd)
                        pckOut.End();
                    outStream.Close();
                }
                catch (IOException)
                {

                }
                finally
                {
                    outStream = null;
                    pckOut = null;
                }
            }

            #if DEBUG
                GC.SuppressFinalize(this); // Disarm lock-release checker
            #endif
        }
コード例 #12
0
 private void init(string msg)
 {
     rawIn = new MemoryStream(Constants.encodeASCII(msg));
     pckIn = new PacketLineIn(rawIn);
 }
コード例 #13
0
ファイル: UploadPack.cs プロジェクト: dev218/GitSharp
        /// <summary>
        /// Execute the upload task on the socket.
        /// </summary>
        /// <param name="input">
        /// raw input to read client commands from. Caller must ensure the
        /// input is buffered, otherwise read performance may suffer.
        /// </param>
        /// <param name="output">
        /// response back to the Git network client, to write the pack
        /// data onto. Caller must ensure the output is buffered,
        /// otherwise write performance may suffer.
        /// </param>
        /// <param name="messages">
        /// secondary "notice" channel to send additional messages out
        /// through. When run over SSH this should be tied back to the
        /// standard error channel of the command execution. For most
        /// other network connections this should be null.
        /// </param>
        /// <exception cref="IOException"></exception>
        public void Upload(Stream input, Stream output, Stream messages)
        {
            _rawIn = input;
            _rawOut = output;

            if (_timeout > 0)
            {
                var i = new TimeoutStream(_rawIn);
					i.setTimeout(_timeout * 1000);
                var o = new TimeoutStream(_rawOut );
					 o.setTimeout(_timeout * 1000);
                _rawIn = i;
                _rawOut = o;
            }

            _pckIn = new PacketLineIn(_rawIn);
            _pckOut = new PacketLineOut(_rawOut);
            Service();
        }
コード例 #14
0
ファイル: ReceivePack.cs プロジェクト: georgeck/GitSharp
        public void receive(Stream stream, Stream messages)
        {
            try
            {
                raw = stream;

                pckIn = new PacketLineIn(raw);
                pckOut = new PacketLineOut(raw);

                if (messages != null)
                {
                    msgs = new StreamWriter(messages);
                }

                enabledCapabilities = new List<string>();
                commands = new List<ReceiveCommand>();

                Service();
            }
            finally
            {
                try
                {
                    if (msgs != null)
                        msgs.Flush();
                }
                finally
                {
                    UnlockPack();
                    raw = null;
                    pckIn = null;
                    pckOut = null;
                    msgs = null;
                    refs = null;
                    enabledCapabilities = null;
                    commands = null;
                }
            }
        }
コード例 #15
0
        protected void init(Stream myStream)
        {
            stream = myStream is BufferedStream ? myStream : new BufferedStream(myStream, IndexPack.BUFFER_SIZE);

            pckIn = new PacketLineIn(stream);
            pckOut = new PacketLineOut(stream);
            outNeedsEnd = true;
        }
コード例 #16
0
 public SideBandInputStream(Stream @in, ProgressMonitor progress)
 {
     rawIn = @in;
     pckIn = new PacketLineIn(rawIn);
     monitor = progress;
     currentTask = string.Empty;
     progressBuffer = string.Empty;
 }
コード例 #17
0
        protected void init(Stream instream, Stream outstream)
        {
            this.inStream = instream is BufferedStream ? instream : new BufferedStream(instream, IndexPack.BUFFER_SIZE);
            this.outStream = outstream is BufferedStream ? outstream : new BufferedStream(outstream, IndexPack.BUFFER_SIZE);

            pckIn = new PacketLineIn(inStream);
            pckOut = new PacketLineOut(outStream);

            outNeedsEnd = true;
        }