Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
07c16dd4
Commit
07c16dd4
authored
Aug 09, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tidy up the write lock code (no functional change, just... more correct)
parent
bb2a551e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
Transactions.cs
StackExchange.Redis.Tests/Transactions.cs
+0
-1
PhysicalBridge.cs
StackExchange.Redis/StackExchange/Redis/PhysicalBridge.cs
+11
-10
No files found.
StackExchange.Redis.Tests/Transactions.cs
View file @
07c16dd4
...
@@ -1004,6 +1004,5 @@ public async Task WatchAbort_HashLengthEqual()
...
@@ -1004,6 +1004,5 @@ public async Task WatchAbort_HashLengthEqual()
await
Assert
.
ThrowsAsync
<
TaskCanceledException
>(()
=>
pong
);
await
Assert
.
ThrowsAsync
<
TaskCanceledException
>(()
=>
pong
);
}
}
}
}
}
}
}
}
StackExchange.Redis/StackExchange/Redis/PhysicalBridge.cs
View file @
07c16dd4
...
@@ -530,7 +530,7 @@ internal bool TryEnqueue(List<Message> messages, bool isSlave)
...
@@ -530,7 +530,7 @@ internal bool TryEnqueue(List<Message> messages, bool isSlave)
return
true
;
return
true
;
}
}
private
readonly
object
Write
Lock
=
new
object
();
private
readonly
object
SingleWriter
Lock
=
new
object
();
/// <summary>
/// <summary>
/// This writes a message to the output stream
/// This writes a message to the output stream
...
@@ -544,7 +544,9 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me
...
@@ -544,7 +544,9 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me
WriteResult
result
;
WriteResult
result
;
bool
haveLock
=
false
;
bool
haveLock
=
false
;
Monitor
.
TryEnter
(
WriteLock
,
TimeoutMilliseconds
,
ref
haveLock
);
try
{
Monitor
.
TryEnter
(
SingleWriterLock
,
TimeoutMilliseconds
,
ref
haveLock
);
if
(!
haveLock
)
if
(!
haveLock
)
{
{
message
.
Cancel
();
message
.
Cancel
();
...
@@ -552,8 +554,7 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me
...
@@ -552,8 +554,7 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me
this
.
CompleteSyncOrAsync
(
message
);
this
.
CompleteSyncOrAsync
(
message
);
return
WriteResult
.
TimeoutBeforeWrite
;
return
WriteResult
.
TimeoutBeforeWrite
;
}
}
try
{
var
messageIsSent
=
false
;
var
messageIsSent
=
false
;
if
(
message
is
IMultiMessage
)
if
(
message
is
IMultiMessage
)
{
{
...
@@ -589,7 +590,7 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me
...
@@ -589,7 +590,7 @@ internal WriteResult WriteMessageTakingWriteLock(PhysicalConnection physical, Me
}
}
finally
finally
{
{
if
(
haveLock
)
Monitor
.
Exit
(
Write
Lock
);
if
(
haveLock
)
Monitor
.
Exit
(
SingleWriter
Lock
);
}
}
return
result
;
return
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment