public virtual void SetUp() { @out = new PipedOutputStream(); @in = new PipedInputStream(@out); timer = new InterruptTimer(); @is = new TimeoutInputStream(@in, timer); @is.SetTimeout(timeout); }
public override void Close() { if (@out != null) { try { if (outNeedsEnd) { outNeedsEnd = false; pckOut.End(); } @out.Close(); } catch (IOException) { } finally { // Ignore any close errors. @out = null; pckOut = null; } } if (@in != null) { try { @in.Close(); } catch (IOException) { } finally { // Ignore any close errors. @in = null; pckIn = null; } } if (myTimer != null) { try { myTimer.Terminate(); } finally { myTimer = null; timeoutIn = null; timeoutOut = null; } } }
/// <summary>Configure this connection with the directional pipes.</summary> /// <remarks>Configure this connection with the directional pipes.</remarks> /// <param name="myIn"> /// input stream to receive data from the peer. Caller must ensure /// the input is buffered, otherwise read performance may suffer. /// </param> /// <param name="myOut"> /// output stream to transmit data to the peer. Caller must ensure /// the output is buffered, otherwise write performance may /// suffer. /// </param> protected internal void Init(InputStream myIn, OutputStream myOut) { int timeout = transport.GetTimeout(); if (timeout > 0) { Sharpen.Thread caller = Sharpen.Thread.CurrentThread(); myTimer = new InterruptTimer(caller.GetName() + "-Timer"); timeoutIn = new TimeoutInputStream(myIn, myTimer); timeoutOut = new TimeoutOutputStream(myOut, myTimer); timeoutIn.SetTimeout(timeout * 1000); timeoutOut.SetTimeout(timeout * 1000); myIn = timeoutIn; myOut = timeoutOut; } @in = myIn; @out = myOut; pckIn = new PacketLineIn(@in); pckOut = new PacketLineOut(@out); outNeedsEnd = true; }
/// <summary>Execute the upload task on the socket.</summary> /// <remarks>Execute the upload task on the socket.</remarks> /// <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="System.IO.IOException">System.IO.IOException</exception> public virtual void Upload(InputStream input, OutputStream output, OutputStream messages ) { try { rawIn = input; rawOut = output; if (timeout > 0) { Sharpen.Thread caller = Sharpen.Thread.CurrentThread(); timer = new InterruptTimer(caller.GetName() + "-Timer"); TimeoutInputStream i = new TimeoutInputStream(rawIn, timer); TimeoutOutputStream o = new TimeoutOutputStream(rawOut, timer); i.SetTimeout(timeout * 1000); o.SetTimeout(timeout * 1000); rawIn = i; rawOut = o; } pckIn = new PacketLineIn(rawIn); pckOut = new PacketLineOut(rawOut); Service(); } finally { walk.Release(); if (timer != null) { try { timer.Terminate(); } finally { timer = null; } } } }