Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix deadlock when create database
  • Loading branch information
adrifer committed Sep 26, 2014
1 parent a2483aa commit 1e6c998
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Expand Up @@ -41,9 +41,10 @@
<ItemGroup>
<Reference Include="DocumentDB.AspNet.Identity, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\DocumentDB.AspNet.Identity.1.0.2-beta\lib\net45\DocumentDB.AspNet.Identity.dll</HintPath>
<HintPath>..\packages\DocumentDB.AspNet.Identity.1.0.6-beta\lib\net45\DocumentDB.AspNet.Identity.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Documents.Client">
<Reference Include="Microsoft.Azure.Documents.Client, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Azure.Documents.Client.0.9.0-preview\lib\net40\Microsoft.Azure.Documents.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
Expand Down
Expand Up @@ -2,7 +2,7 @@
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="bootstrap" version="3.0.0" targetFramework="net45" />
<package id="DocumentDB.AspNet.Identity" version="1.0.2-beta" targetFramework="net45" />
<package id="DocumentDB.AspNet.Identity" version="1.0.6-beta" targetFramework="net45" />
<package id="EntityFramework" version="6.1.1" targetFramework="net45" />
<package id="jQuery" version="1.10.2" targetFramework="net45" />
<package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentDB.AspNet.Identity.nuspec
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>DocumentDB.AspNet.Identity</id>
<version>1.0.2-beta</version>
<version>1.0.6-beta</version>
<title>DocumentDB.AspNet.Identity</title>
<authors>Tracker086</authors>
<owners>Tracker086</owners>
Expand Down
14 changes: 7 additions & 7 deletions src/UserStore.cs
Expand Up @@ -39,7 +39,7 @@ private static Database Database
{
if (database == null)
{
database = ReadOrCreateDatabase().Result;
database = ReadOrCreateDatabase();
}

return database;
Expand All @@ -56,7 +56,7 @@ private static IQueryable<TUser> Users
{
if (usersLink == null)
{
var collection = InitializeConnection(Database.SelfLink, "Users").Result;
var collection = InitializeCollection(Database.SelfLink, "Users");
usersLink = collection.DocumentsLink;
usersSelfLink = collection.SelfLink;
AddUserDefinedFunctionsIfNeeded(usersSelfLink);
Expand Down Expand Up @@ -528,7 +528,7 @@ public Task SetPhoneNumberConfirmedAsync(TUser user, bool confirmed)
return Task.FromResult(0);
}

private static async Task<Database> ReadOrCreateDatabase()
private static Database ReadOrCreateDatabase()
{
var databases = client.CreateDatabaseQuery()
.Where(db => db.Id == dataBaseName).ToArray();
Expand All @@ -539,10 +539,10 @@ private static async Task<Database> ReadOrCreateDatabase()
}

var newDatabase = new Database { Id = dataBaseName };
return await client.CreateDatabaseAsync(newDatabase);
return client.CreateDatabaseAsync(newDatabase).Result;
}

private static async Task<DocumentCollection> InitializeConnection(string databaseLink, string collectionId)
private static DocumentCollection InitializeCollection(string databaseLink, string collectionId)
{
var collections = client.CreateDocumentCollectionQuery(databaseLink)
.Where(col => col.Id == collectionId).ToArray();
Expand All @@ -552,8 +552,8 @@ private static async Task<DocumentCollection> InitializeConnection(string databa
return collections.First();
}

return await client.CreateDocumentCollectionAsync(databaseLink,
new DocumentCollection { Id = collectionId });
return client.CreateDocumentCollectionAsync(databaseLink,
new DocumentCollection { Id = collectionId }).Result;
}

private static void Initialize()
Expand Down

0 comments on commit 1e6c998

Please sign in to comment.