Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 53bc215

Browse files
authored
Merge pull request #459 from erezvani1529/master
[8.1.2] Download async hang issue + SendStream mem leak fix
2 parents 25e44ab + cd33f59 commit 53bc215

File tree

40 files changed

+571
-91
lines changed

40 files changed

+571
-91
lines changed

Lib/AspNet/Microsoft.WindowsAzure.Storage.Facade/FacadeLib/Microsoft.WindowsAzure.Storage.Shared.Protocol.Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public static class EncryptionConstants
245245
public const string TableEncryptionKeyDetails = "_ClientEncryptionMetadata1";
246246
public const string TableEncryptionPropertyDetails = "_ClientEncryptionMetadata2";
247247
public const string AgentMetadataKey = "EncryptionLibrary";
248-
public const string AgentMetadataValue = ".NET 8.1.1";
248+
public const string AgentMetadataValue = ".NET 8.1.2";
249249
}
250250
}
251251

Lib/AspNet/Microsoft.WindowsAzure.Storage.Facade/FacadeLib/Microsoft.WindowsAzure.Storage.Shared.Protocol.EncryptionConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public static class EncryptionConstants
1010
public const string TableEncryptionKeyDetails = "_ClientEncryptionMetadata1";
1111
public const string TableEncryptionPropertyDetails = "_ClientEncryptionMetadata2";
1212
public const string AgentMetadataKey = "EncryptionLibrary";
13-
public const string AgentMetadataValue = ".NET 8.1.1";
13+
public const string AgentMetadataValue = ".NET 8.1.2";
1414
}
1515

1616
}

Lib/AspNet/Microsoft.WindowsAzure.Storage.Facade/FacadeLib/Microsoft.WindowsAzure.Storage.Shared.Protocol.HeaderConstants.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ namespace Microsoft.WindowsAzure.Storage.Shared.Protocol
44

55
public static class HeaderConstants
66
{
7-
public static readonly string UserAgent = "Azure-Storage/8.1.1 ";
7+
public static readonly string UserAgent = "Azure-Storage/8.1.2 ";
88
public const string UserAgentProductName = "Azure-Storage";
9-
public const string UserAgentProductVersion = "8.1.1";
9+
public const string UserAgentProductVersion = "8.1.2";
1010
public const string PrefixForStorageHeader = "x-ms-";
1111
public const string TrueHeader = "true";
1212
public const string FalseHeader = "false";

Lib/AspNet/Microsoft.WindowsAzure.Storage.Facade/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
// by using the '*' as shown below:
3232
// [assembly: AssemblyVersion("1.0.*")]
3333

34-
[assembly: AssemblyVersion("8.1.1.0")]
35-
[assembly: AssemblyFileVersion("8.1.1.0")]
34+
[assembly: AssemblyVersion("8.1.2.0")]
35+
[assembly: AssemblyFileVersion("8.1.2.0")]
3636

3737
[assembly: InternalsVisibleTo(
3838
"Microsoft.WindowsAzure.Storage.Facade.Portable, PublicKey=" +

Lib/AspNet/Microsoft.WindowsAzure.Storage.Facade/project.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"title": "Microsoft.WindowsAzure.Storage",
3-
"version": "8.1.1.0",
3+
"version": "8.1.2.0",
4+
45
"authors": [ "Microsoft Corporation" ],
56
"description": "Azure Storage SDK for NetCore",
67
"dependencies": {

Lib/AspNet/Microsoft.WindowsAzure.Storage/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
3636

37-
[assembly: AssemblyVersion("8.1.1.0")]
38-
[assembly: AssemblyFileVersion("8.1.1.0")]
39-
[assembly: AssemblyInformationalVersion("8.1.1.0")]
37+
[assembly: AssemblyVersion("8.1.2.0")]
38+
[assembly: AssemblyFileVersion("8.1.2.0")]
39+
[assembly: AssemblyInformationalVersion("8.1.2.0")]
4040

4141

4242
[assembly: InternalsVisibleTo(

Lib/AspNet/Microsoft.WindowsAzure.Storage/WindowsAzure.StorageK.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
33
<metadata minClientVersion="2.12">
44
<id>WindowsAzure.Storage</id>
5-
<version>8.1.1</version>
5+
<version>8.1.2</version>
66
<title>Windows Azure Storage</title>
77
<authors>Microsoft</authors>
88
<owners>Microsoft</owners>

Lib/AspNet/Microsoft.WindowsAzure.Storage/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "8.1.1.0",
2+
"version": "8.1.2.0",
33

44
"authors": [ "Microsoft Corporation" ],
55
"description": "Azure Storage SDK for NetCore",

Lib/ClassLibraryCommon/Core/Executor/Executor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ private static void EndOperation<T>(ExecutionState<T> executionState)
508508
Logger.LogError(executionState.OperationContext, shouldRetry ? SR.TraceRetryDecisionTimeout : SR.TraceRetryDecisionPolicy, executionState.ExceptionRef.Message);
509509

510510
// No Retry
511+
executionState.CheckDisposeSendStream();
511512
executionState.OnComplete();
512513
}
513514
else
@@ -572,6 +573,7 @@ private static void EndOperation<T>(ExecutionState<T> executionState)
572573
private static void RetryRequest<T>(object state)
573574
{
574575
ExecutionState<T> executionState = (ExecutionState<T>)state;
576+
executionState.CheckDisposeSendStream();
575577
Logger.LogInformational(executionState.OperationContext, SR.TraceRetry);
576578
Executor.FireRetrying(executionState);
577579
Executor.InitRequest(executionState);

Lib/ClassLibraryCommon/Core/Util/AsyncStreamCopier.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ namespace Microsoft.WindowsAzure.Storage.Core.Util
2323
using System.IO;
2424
using System.Threading;
2525
using System.Threading.Tasks;
26+
2627
// Class to copy streams with potentially overlapping read / writes. This uses no waithandle, extra threads, but does contain a single lock
2728
internal class AsyncStreamCopier<T> : IDisposable
2829
{
@@ -116,8 +117,6 @@ public void StartCopyStream(Action<ExecutionState<T>> completedDelegate, long? c
116117
{
117118
state.ReqTimedOut = timedOut;
118119

119-
// Note: the old logic had the following line happen on different threads for Desktop and Phone. I don't think
120-
// we still need to do that, but I'm not sure.
121120
#if WINDOWS_DESKTOP || WINDOWS_PHONE
122121
state.Req.Abort();
123122
#endif
@@ -218,7 +217,7 @@ public async Task StartCopyStreamAsync(long? copyLength, long? maxLength)
218217
{
219218
this.cancellationTokenSourceCombined = this.cancellationTokenSourceAbort;
220219
}
221-
220+
222221
await this.StartCopyStreamAsyncHelper(copyLength, maxLength, this.cancellationTokenSourceCombined.Token).ConfigureAwait(false);
223222
}
224223

@@ -284,7 +283,7 @@ private async Task StartCopyStreamAsyncHelper(long? copyLength, long? maxLength,
284283

285284
UpdateStreamCopyState(writeBuff, bytesCopied);
286285

287-
bytesCopied = await readTask.ConfigureAwait(false);
286+
bytesCopied = await readTask.WithCancellation(token).ConfigureAwait(false);
288287
totalBytes = totalBytes + bytesCopied;
289288

290289
CheckMaxLength(maxLength, totalBytes);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright file="TaskExtensions.cs" company="Microsoft">
3+
// Copyright 2013 Microsoft Corporation
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
// </copyright>
16+
//-----------------------------------------------------------------------
17+
18+
namespace Microsoft.WindowsAzure.Storage.Core.Util
19+
{
20+
using System;
21+
using System.Threading;
22+
using System.Threading.Tasks;
23+
24+
#if TASK
25+
26+
internal static class TaskExtensions
27+
{
28+
/// <summary>
29+
/// Extension method to add cancellation logic to non-cancellable operations.
30+
/// </summary>
31+
/// <param name="cancellationToken" the cancellation token which will be used to cancel the combined task </param>
32+
/// <remarks>Please refer to this post for more information: https://blogs.msdn.microsoft.com/pfxteam/2012/10/05/how-do-i-cancel-non-cancelable-async-operations/ </remarks>
33+
internal static async Task<T> WithCancellation<T>(this Task<T> task, CancellationToken cancellationToken)
34+
{
35+
var tcs = new TaskCompletionSource<bool>();
36+
using (cancellationToken.Register(
37+
taskCompletionSource => ((TaskCompletionSource<bool>)taskCompletionSource).TrySetResult(true), tcs))
38+
if (task != await Task.WhenAny(task, tcs.Task))
39+
throw new OperationCanceledException(cancellationToken);
40+
return await task;
41+
}
42+
}
43+
44+
#endif
45+
}

Lib/ClassLibraryCommon/Table/TableBatchOperation.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ private static RESTCommand<IList<TableResult>> BatchImpl(TableBatchOperation bat
140140
{
141141
Tuple<HttpWebRequest, Stream> res = TableOperationHttpWebRequestFactory.BuildRequestForTableBatchOperation(uri, builder, client.BufferManager, timeout, table.Name, batch, useVersionHeader, ctx, requestOptions, client.AccountName);
142142
batchCmd.SendStream = res.Item2;
143+
batchCmd.StreamToDispose = res.Item2;
143144
return res.Item1;
144145
};
145146

Lib/ClassLibraryCommon/Table/TableOperation.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ private static RESTCommand<TableResult> InsertImpl(TableOperation operation, Clo
138138
{
139139
Tuple<HttpWebRequest, Stream> res = TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions, client.AccountName);
140140
insertCmd.SendStream = res.Item2;
141+
insertCmd.StreamToDispose = res.Item2;
141142
return res.Item1;
142143
};
143144

@@ -176,6 +177,7 @@ private static RESTCommand<TableResult> MergeImpl(TableOperation operation, Clou
176177
{
177178
Tuple<HttpWebRequest, Stream> res = TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions, client.AccountName);
178179
mergeCmd.SendStream = res.Item2;
180+
mergeCmd.StreamToDispose = res.Item2;
179181
return res.Item1;
180182
};
181183

@@ -197,6 +199,7 @@ private static RESTCommand<TableResult> ReplaceImpl(TableOperation operation, Cl
197199
{
198200
Tuple<HttpWebRequest, Stream> res = TableOperationHttpWebRequestFactory.BuildRequestForTableOperation(uri, builder, client.BufferManager, timeout, operation, useVersionHeader, ctx, requestOptions, client.AccountName);
199201
replaceCmd.SendStream = res.Item2;
202+
replaceCmd.StreamToDispose = res.Item2;
200203
return res.Item1;
201204
};
202205

Lib/Common/Auth/StorageCredentials.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public bool IsSharedKey
102102
}
103103

104104
/// <summary>
105-
/// Gets the value of the shared access signature token's <code>sig</code> parameter.
105+
/// Gets the value of the shared access signature token's <c>sig</c> parameter.
106106
/// </summary>
107107
public string SASSignature
108108
{

0 commit comments

Comments
 (0)