mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 01:05:42 +00:00
Minor changes Begin* End* preparation for ChannelSftp
This commit is contained in:
@@ -22,6 +22,9 @@ Global
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|Mixed Platforms = Debug|Mixed Platforms
|
||||
Debug|x86 = Debug|x86
|
||||
DebugNoTimeout|Any CPU = DebugNoTimeout|Any CPU
|
||||
DebugNoTimeout|Mixed Platforms = DebugNoTimeout|Mixed Platforms
|
||||
DebugNoTimeout|x86 = DebugNoTimeout|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|Mixed Platforms = Release|Mixed Platforms
|
||||
Release|x86 = Release|x86
|
||||
@@ -32,6 +35,11 @@ Global
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.DebugNoTimeout|Any CPU.ActiveCfg = DebugNoTimeout|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.DebugNoTimeout|Any CPU.Build.0 = DebugNoTimeout|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.DebugNoTimeout|Mixed Platforms.ActiveCfg = DebugNoTimeout|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.DebugNoTimeout|Mixed Platforms.Build.0 = DebugNoTimeout|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.DebugNoTimeout|x86.ActiveCfg = DebugNoTimeout|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2F5F8C90-0BD1-424F-997C-7BC6280919D1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
@@ -42,6 +50,11 @@ Global
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Debug|x86.Build.0 = Debug|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|Any CPU.ActiveCfg = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|Mixed Platforms.ActiveCfg = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|Mixed Platforms.Build.0 = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|x86.ActiveCfg = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.DebugNoTimeout|x86.Build.0 = DebugNoTimeout|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{23E84A34-A9EC-47D5-BECE-0725053BB17E}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
|
||||
@@ -11,8 +11,18 @@ namespace Renci.SshClient.Channels
|
||||
/// <value>The channel.</value>
|
||||
internal ChannelExec Channel { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bytes received. If SFTP only file bytes are counted.
|
||||
/// </summary>
|
||||
/// <value>Total bytes received.</value>
|
||||
public int BytesReceived { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the bytes sent by SFTP.
|
||||
/// </summary>
|
||||
/// <value>Total bytes sent.</value>
|
||||
public int BytesSent { get; set; }
|
||||
|
||||
#region IAsyncResult Members
|
||||
|
||||
public object AsyncState { get; internal set; }
|
||||
|
||||
@@ -111,6 +111,11 @@ namespace Renci.SshClient.Channels
|
||||
{
|
||||
this._channelData.Write(data.GetSshBytes().ToArray(), 0, data.Length);
|
||||
}
|
||||
|
||||
if (this._asyncResult != null)
|
||||
{
|
||||
this._asyncResult.BytesReceived += data.Length;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnChannelExtendedData(string data, uint dataTypeCode)
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace Renci.SshClient.Channels
|
||||
|
||||
private StringBuilder _packetData;
|
||||
|
||||
private ChannelAsyncResult _asyncResult;
|
||||
|
||||
public override ChannelTypes ChannelType
|
||||
{
|
||||
get { return ChannelTypes.Session; }
|
||||
@@ -229,7 +231,6 @@ namespace Renci.SshClient.Channels
|
||||
this._packetData.Append(data);
|
||||
}
|
||||
|
||||
|
||||
if (this._packetData.Length < this._packetData.MaxCapacity)
|
||||
{
|
||||
// Wait for more packet data
|
||||
@@ -350,6 +351,10 @@ namespace Renci.SshClient.Channels
|
||||
}
|
||||
else if (dataMessage != null)
|
||||
{
|
||||
if (this._asyncResult != null)
|
||||
{
|
||||
this._asyncResult.BytesReceived += dataMessage.Data.Length;
|
||||
}
|
||||
return dataMessage.Data;
|
||||
}
|
||||
else
|
||||
@@ -370,6 +375,12 @@ namespace Renci.SshClient.Channels
|
||||
var message = this.ReceiveMessage<StatusMessage>();
|
||||
|
||||
this.EnsureStatusCode(message, StatusCodes.Ok);
|
||||
|
||||
if (this._asyncResult != null)
|
||||
{
|
||||
this._asyncResult.BytesSent += data.Length;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RemoveRemoteFile(string fileName)
|
||||
|
||||
@@ -34,6 +34,22 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugNoTimeout|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\DebugNoTimeout\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;NOTIMEOUT</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<CodeAnalysisLogFile>bin\Debug\Renci.SshClient.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRuleSetDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRuleSets>false</CodeAnalysisIgnoreBuiltInRuleSets>
|
||||
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
||||
@@ -71,10 +71,11 @@ namespace Renci.SshClient
|
||||
|
||||
private IDictionary<uint, uint> _openChannels = new Dictionary<uint, uint>();
|
||||
|
||||
private EventWaitHandle _disconnectWaitHandle = new AutoResetEvent(false);
|
||||
|
||||
private EventWaitHandle _exceptionWaitHandle = new AutoResetEvent(false);
|
||||
|
||||
/// <summary>
|
||||
/// Exception that need to be thrown by waiting thread
|
||||
/// </summary>
|
||||
private Exception _exceptionToThrow;
|
||||
|
||||
/// <summary>
|
||||
@@ -218,26 +219,31 @@ namespace Renci.SshClient
|
||||
{
|
||||
var waitHandles = new WaitHandle[]
|
||||
{
|
||||
this._disconnectWaitHandle,
|
||||
this._exceptionWaitHandle,
|
||||
waitHandle,
|
||||
};
|
||||
|
||||
EventWaitHandle.WaitAny(waitHandles);
|
||||
// TODO: Signal waitandle to stop waiting, in case someone waiting for it.
|
||||
// TODO: throw exception in case of _disconnectWaitHandle or _exceptionWaitHandle was signalled
|
||||
|
||||
//var index = EventWaitHandle.WaitAny(waitHandles, this._waitTimeout);
|
||||
var index = 0;
|
||||
#if NOTIMEOUT
|
||||
index = EventWaitHandle.WaitAny(waitHandles);
|
||||
#else
|
||||
index = EventWaitHandle.WaitAny(waitHandles, this._waitTimeout);
|
||||
#endif
|
||||
if (this._exceptionToThrow != null)
|
||||
{
|
||||
var exception = this._exceptionToThrow;
|
||||
this._exceptionToThrow = null;
|
||||
throw exception;
|
||||
}
|
||||
else if (index > waitHandles.Length)
|
||||
{
|
||||
// TODO: Issue timeout disconnect message if approapriate
|
||||
throw new TimeoutException();
|
||||
}
|
||||
|
||||
//if (this._exceptionToThrow != null)
|
||||
//{
|
||||
// var exception = this._exceptionToThrow;
|
||||
// this._exceptionToThrow = null;
|
||||
// throw exception;
|
||||
//}
|
||||
//else if (index > waitHandles.Length)
|
||||
//{
|
||||
// // TODO: Issue timeout disconnect message if approapriate
|
||||
// throw new TimeoutException();
|
||||
//}
|
||||
}
|
||||
|
||||
protected abstract Message ReceiveMessage();
|
||||
|
||||
Reference in New Issue
Block a user