Skip to content

Commit

Permalink
Disable continue on captured context in library code to prevent dead…
Browse files Browse the repository at this point in the history
…locks (#219)
  • Loading branch information
alexandervantrijffel authored and kannappanr committed Apr 5, 2018
1 parent ab324ee commit 36f847e
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 81 deletions.
46 changes: 24 additions & 22 deletions Minio/ApiEndpoints/BucketOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public partial class MinioClient : IBucketOperations
//PrepareClient();

var request = new RestRequest("/", Method.GET);
var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);

ListAllMyBucketsResult bucketList = new ListAllMyBucketsResult();
if (HttpStatusCode.OK.Equals(response.StatusCode))
Expand Down Expand Up @@ -86,7 +86,7 @@ public partial class MinioClient : IBucketOperations
request.AddBody(config);
}

var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);

}

Expand All @@ -101,9 +101,8 @@ public partial class MinioClient : IBucketOperations
{
try
{
var request = await this.CreateRequest(Method.HEAD,
bucketName);
var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
var request = await this.CreateRequest(Method.HEAD, bucketName).ConfigureAwait(false);
var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
Expand All @@ -124,9 +123,9 @@ public partial class MinioClient : IBucketOperations
/// <returns>Task</returns>
public async Task RemoveBucketAsync(string bucketName, CancellationToken cancellationToken = default(CancellationToken))
{
var request = await this.CreateRequest(Method.DELETE, bucketName, resourcePath: null);
var request = await this.CreateRequest(Method.DELETE, bucketName, resourcePath: null).ConfigureAwait(false);

var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);

}

Expand All @@ -147,7 +146,7 @@ public partial class MinioClient : IBucketOperations
string marker = null;
while (isRunning)
{
Tuple<ListBucketResult, List<Item>> result = await GetObjectListAsync(bucketName, prefix, recursive, marker, cancellationToken);
Tuple<ListBucketResult, List<Item>> result = await GetObjectListAsync(bucketName, prefix, recursive, marker, cancellationToken).ConfigureAwait(false);
Item lastItem = null;
foreach (Item item in result.Item2)
{
Expand Down Expand Up @@ -203,11 +202,10 @@ public partial class MinioClient : IBucketOperations

var request = await this.CreateRequest(Method.GET,
bucketName,
resourcePath: "?" + query);



var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
resourcePath: "?" + query)
.ConfigureAwait(false);

var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);

var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
ListBucketResult listBucketResult = null;
Expand Down Expand Up @@ -254,9 +252,10 @@ public partial class MinioClient : IBucketOperations

var request = await this.CreateRequest(Method.GET, bucketName,
contentType: "application/json",
resourcePath: "?policy");
resourcePath: "?policy")
.ConfigureAwait(false);
string policyString = null;
response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);

using (var stream = new MemoryStream(contentBytes))
Expand All @@ -278,9 +277,10 @@ public partial class MinioClient : IBucketOperations
var request = await this.CreateRequest(Method.PUT, bucketName,
resourcePath: "?policy",
contentType: "application/json",
body: policyJson);
body: policyJson)
.ConfigureAwait(false);

IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -294,10 +294,11 @@ public partial class MinioClient : IBucketOperations
utils.validateBucketName(bucketName);
var request = await this.CreateRequest(Method.GET,
bucketName,
resourcePath: "?notification");
resourcePath: "?notification")
.ConfigureAwait(false);
BucketNotification notification = null;

var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
var response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
var contentBytes = System.Text.Encoding.UTF8.GetBytes(response.Content);
using (var stream = new MemoryStream(contentBytes))
{
Expand All @@ -316,13 +317,14 @@ public partial class MinioClient : IBucketOperations
{
utils.validateBucketName(bucketName);
var request = await this.CreateRequest(Method.PUT, bucketName,
resourcePath: "?notification");
resourcePath: "?notification")
.ConfigureAwait(false);

request.XmlSerializer = new RestSharp.Serializers.DotNetXmlSerializer();
request.RequestFormat = DataFormat.Xml;
request.AddBody(notification);

IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken);
IRestResponse response = await this.ExecuteTaskAsync(this.NoErrorHandlers, request, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -335,7 +337,7 @@ public partial class MinioClient : IBucketOperations
{
utils.validateBucketName(bucketName);
BucketNotification notification = new BucketNotification();
await SetBucketNotificationsAsync(bucketName, notification, cancellationToken);
await SetBucketNotificationsAsync(bucketName, notification, cancellationToken).ConfigureAwait(false);
}
}
}
Loading

0 comments on commit 36f847e

Please sign in to comment.