/// <exception cref="System.IO.IOException"></exception>
            private void SetupStreams()
            {
                this.inputStream = this.channel.GetInputStream();
                // JSch won't let us interrupt writes when we use our InterruptTimer
                // to break out of a long-running write operation. To work around
                // that we spawn a background thread to shuttle data through a pipe,
                // as we can issue an interrupted write out of that. Its slower, so
                // we only use this route if there is a timeout.
                OutputStream @out = this.channel.GetOutputStream();

                if (this.timeout <= 0)
                {
                    this.outputStream = @out;
                }
                else
                {
                    PipedInputStream  pipeIn  = new PipedInputStream();
                    StreamCopyThread  copier  = new StreamCopyThread(pipeIn, @out);
                    PipedOutputStream pipeOut = new _PipedOutputStream_173(this, copier, pipeIn);
                    // Just wake early, the thread will terminate
                    // anyway.
                    copier.Start();
                    this.outputStream = pipeOut;
                }
                this.errStream = this.channel.GetErrStream();
            }
Esempio n. 2
0
 public override void Close()
 {
     this.EndOut();
     if (this.errorThread != null)
     {
         try
         {
             this.errorThread.Halt();
         }
         catch (Exception)
         {
         }
         finally
         {
             // Stop waiting and return anyway.
             this.errorThread = null;
         }
     }
     base.Close();
     this.conn.Close();
 }
Esempio n. 3
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 internal SshPushConnection(TransportGitSsh _enclosing, TransportGitSsh.Connection
                            conn) : base(_enclosing)
 {
     this._enclosing = _enclosing;
     this.conn       = conn;
     try
     {
         MessageWriter msg = new MessageWriter();
         this.SetMessageWriter(msg);
         conn.Exec(this._enclosing.GetOptionReceivePack());
         InputStream rpErr = conn.GetErrorStream();
         this.errorThread = new StreamCopyThread(rpErr, msg.GetRawStream());
         this.errorThread.Start();
         this.Init(conn.GetInputStream(), conn.GetOutputStream());
         conn.Connect();
     }
     catch (TransportException err)
     {
         this.Close();
         throw;
     }
     catch (IOException err)
     {
         this.Close();
         throw new TransportException(this.uri, JGitText.Get().remoteHungUpUnexpectedly, err
                                      );
     }
     try
     {
         this.ReadAdvertisedRefs();
     }
     catch (NoRemoteRepositoryException notFound)
     {
         string msgs = this.GetMessages();
         this._enclosing.CheckExecFailure(conn.GetExitStatus(), this._enclosing.GetOptionReceivePack
                                              (), msgs);
         throw this._enclosing.CleanNotFound(notFound, msgs);
     }
 }
Esempio n. 4
0
            /// <exception cref="System.IO.IOException"></exception>
            internal override OutputStream GetOutputStream()
            {
                // JSch won't let us interrupt writes when we use our InterruptTimer
                // to break out of a long-running write operation. To work around
                // that we spawn a background thread to shuttle data through a pipe,
                // as we can issue an interrupted write out of that. Its slower, so
                // we only use this route if there is a timeout.
                //
                OutputStream @out = this.channel.GetOutputStream();

                if (this._enclosing.GetTimeout() <= 0)
                {
                    return(@out);
                }
                PipedInputStream  pipeIn  = new PipedInputStream();
                StreamCopyThread  copier  = new StreamCopyThread(pipeIn, @out);
                PipedOutputStream pipeOut = new _PipedOutputStream_259(this, copier, pipeIn);

                // Just wake early, the thread will terminate anyway.
                copier.Start();
                return(pipeOut);
            }
Esempio n. 5
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public SshPushConnection(TransportGitSsh _enclosing) : base(_enclosing)
 {
     this._enclosing = _enclosing;
     try
     {
         this.process = this._enclosing.GetSession().Exec(this._enclosing.CommandFor(this.
                                                                                     _enclosing.GetOptionReceivePack()), this._enclosing.GetTimeout());
         MessageWriter msg = new MessageWriter();
         this.SetMessageWriter(msg);
         InputStream rpErr = this.process.GetErrorStream();
         this.errorThread = new StreamCopyThread(rpErr, msg.GetRawStream());
         this.errorThread.Start();
         this.Init(this.process.GetInputStream(), this.process.GetOutputStream());
     }
     catch (TransportException err)
     {
         this.Close();
         throw;
     }
     catch (IOException err)
     {
         this.Close();
         throw new TransportException(this.uri, JGitText.Get().remoteHungUpUnexpectedly, err
                                      );
     }
     try
     {
         this.ReadAdvertisedRefs();
     }
     catch (NoRemoteRepositoryException notFound)
     {
         string msgs = this.GetMessages();
         this._enclosing.CheckExecFailure(this.process.ExitValue(), this._enclosing.GetOptionReceivePack
                                              (), msgs);
         throw this._enclosing.CleanNotFound(notFound, msgs);
     }
 }
 public _PipedOutputStream_173(JschProcess _enclosing, StreamCopyThread copier, PipedInputStream
                               baseArg1) : base(baseArg1)
 {
     this._enclosing = _enclosing;
     this.copier     = copier;
 }
Esempio n. 7
0
 public _PipedOutputStream_259(JschConnection _enclosing, StreamCopyThread copier,
                               PipedInputStream baseArg1) : base(baseArg1)
 {
     this._enclosing = _enclosing;
     this.copier     = copier;
 }