Ejemplo n.º 1
0
		public virtual void SetUp()
		{
			@out = new PipedOutputStream();
			@in = new PipedInputStream(@out);
			timer = new InterruptTimer();
			@is = new TimeoutInputStream(@in, timer);
			@is.SetTimeout(timeout);
		}
Ejemplo n.º 2
0
		public void TestBigWrite ()
		{
			PipedInputStream pin = new PipedInputStream ();
			PipedOutputStream pout = new PipedOutputStream (pin);
			
			Random r = new Random (0);
			byte[] data = new byte [PipedInputStream.PIPE_SIZE * 3];
			r.NextBytes (data);
			
			ThreadPool.QueueUserWorkItem (delegate {
				pout.Write (data);
				pout.Close ();
			});
			int n = 0;
			byte[] buffer = new byte [100];
			int nr;
			while ((nr = pin.Read (buffer)) != -1) {
				for (int i=0; i < nr; i++)
					Assert.AreEqual (buffer[i], data[n++], "Position " + n);
			}
		}
Ejemplo n.º 3
0
		public PipedOutputStream (PipedInputStream iss) : this()
		{
			Attach (iss);
		}
Ejemplo n.º 4
0
                public _Thread_365(InternalLocalPushConnection _enclosing, Repository dst, PipedInputStream
					 out_r, PipedOutputStream in_w, string baseArg1)
                    : base(baseArg1)
                {
                    this._enclosing = _enclosing;
                    this.dst = dst;
                    this.out_r = out_r;
                    this.in_w = in_w;
                }
Ejemplo n.º 5
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalPushConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     PipedInputStream in_r;
     PipedOutputStream in_w;
     PipedInputStream out_r;
     PipedOutputStream out_w;
     try
     {
         in_r = new PipedInputStream();
         in_w = new PipedOutputStream(in_r);
         out_r = new PipedInputStream();
         out_w = new PipedOutputStream(out_r);
     }
     catch (IOException err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_365(this, dst, out_r, in_w, "JGit-Receive-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
Ejemplo n.º 6
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalFetchConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     PipedInputStream in_r;
     PipedOutputStream in_w;
     PipedInputStream out_r;
     PipedOutputStream out_w;
     try
     {
         in_r = new PipedInputStream();
         in_w = new PipedOutputStream(in_r);
         out_r = new _PipedInputStream_218();
         // The client (BasePackFetchConnection) can write
         // a huge burst before it reads again. We need to
         // force the buffer to be big enough, otherwise it
         // will deadlock both threads.
         out_w = new PipedOutputStream(out_r);
     }
     catch (IOException err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_233(this, dst, out_r, in_w, "JGit-Upload-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
Ejemplo n.º 7
0
		public ConsoleTextArea(string[] argv) : base()
		{
			history = new List<string>();
			console1 = new ConsoleWriter(this);
			console2 = new ConsoleWriter(this);
			@out = new TextWriter(console1, true);
			err = new TextWriter(console2, true);
			PipedOutputStream outPipe = new PipedOutputStream();
			inPipe = new PrintWriter(outPipe);
			@in = new PipedInputStream();
			try
			{
				outPipe.Connect(@in);
			}
			catch (IOException exc)
			{
				Sharpen.Runtime.PrintStackTrace(exc);
			}
			GetDocument().AddDocumentListener(this);
			AddKeyListener(this);
			SetLineWrap(true);
			SetFont(new Font("Monospaced", 0, 12));
		}
 internal void Attach(PipedInputStream iss)
 {
     ips = iss;
 }
Ejemplo n.º 9
0
 /// <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();
 }
Ejemplo n.º 10
0
				public _PipedOutputStream_250(JschConnection _enclosing, StreamCopyThread copier, 
					PipedInputStream baseArg1) : base(baseArg1)
				{
					this._enclosing = _enclosing;
					this.copier = copier;
				}
Ejemplo n.º 11
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_250(this, copier, pipeIn);
				// Just wake early, the thread will terminate anyway.
				copier.Start();
				return pipeOut;
			}
Ejemplo n.º 12
0
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveOutputStream(Channel _enclosing, PipedInputStream @in) : base(@in)
			{
				this._enclosing = _enclosing;
			}
Ejemplo n.º 13
0
 internal void Attach(PipedInputStream iss)
 {
     ips = iss;
 }
Ejemplo n.º 14
0
                public _PipedOutputStream_173(JschProcess _enclosing, StreamCopyThread copier, PipedInputStream
					 baseArg1)
                    : base(baseArg1)
                {
                    this._enclosing = _enclosing;
                    this.copier = copier;
                }
Ejemplo n.º 15
0
		public void Attach (PipedInputStream iss)
		{
			ips = iss;
		}
 public PipedOutputStream(PipedInputStream iss) : this()
 {
     Attach(iss);
 }
 public void Attach(PipedInputStream iss)
 {
     ips = iss;
 }