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
b2c05dec
Commit
b2c05dec
authored
Aug 13, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make _socket/_ioPipe more resilient to threading nasties
parent
221fac32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
PhysicalConnection.cs
StackExchange.Redis/PhysicalConnection.cs
+7
-8
No files found.
StackExchange.Redis/PhysicalConnection.cs
View file @
b2c05dec
...
@@ -56,6 +56,7 @@ private static readonly Message
...
@@ -56,6 +56,7 @@ private static readonly Message
private
IDuplexPipe
_ioPipe
;
private
IDuplexPipe
_ioPipe
;
private
Socket
_socket
;
private
Socket
_socket
;
private
Socket
VolatileSocket
=>
Interlocked
.
CompareExchange
(
ref
_socket
,
null
,
null
);
public
PhysicalConnection
(
PhysicalBridge
bridge
)
public
PhysicalConnection
(
PhysicalBridge
bridge
)
{
{
...
@@ -99,7 +100,7 @@ internal async void BeginConnectAsync(TextWriter log)
...
@@ -99,7 +100,7 @@ internal async void BeginConnectAsync(TextWriter log)
{
{
_socketArgs
.
Completed
+=
SocketAwaitable
.
Callback
;
_socketArgs
.
Completed
+=
SocketAwaitable
.
Callback
;
var
x
=
_s
ocket
;
var
x
=
VolatileS
ocket
;
if
(
x
==
null
)
if
(
x
==
null
)
{
{
awaitable
.
TryComplete
(
0
,
SocketError
.
ConnectionAborted
);
awaitable
.
TryComplete
(
0
,
SocketError
.
ConnectionAborted
);
...
@@ -125,7 +126,7 @@ internal async void BeginConnectAsync(TextWriter log)
...
@@ -125,7 +126,7 @@ internal async void BeginConnectAsync(TextWriter log)
timeoutSource
.
Cancel
();
timeoutSource
.
Cancel
();
timeoutSource
.
Dispose
();
timeoutSource
.
Dispose
();
}
}
var
x
=
_s
ocket
;
var
x
=
VolatileS
ocket
;
if
(
x
==
null
)
if
(
x
==
null
)
{
{
ConnectionMultiplexer
.
TraceWithoutContext
(
"Socket was already aborted"
);
ConnectionMultiplexer
.
TraceWithoutContext
(
"Socket was already aborted"
);
...
@@ -228,10 +229,8 @@ private enum ReadMode : byte
...
@@ -228,10 +229,8 @@ private enum ReadMode : byte
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2202:Do not dispose objects multiple times"
)]
[
System
.
Diagnostics
.
CodeAnalysis
.
SuppressMessage
(
"Microsoft.Usage"
,
"CA2202:Do not dispose objects multiple times"
)]
internal
void
Shutdown
()
internal
void
Shutdown
()
{
{
var
ioPipe
=
_ioPipe
;
var
ioPipe
=
Interlocked
.
Exchange
(
ref
_ioPipe
,
null
);
// compare to the critical read
var
socket
=
_socket
;
var
socket
=
Interlocked
.
Exchange
(
ref
_socket
,
null
);
_ioPipe
=
null
;
_socket
=
null
;
if
(
ioPipe
!=
null
)
if
(
ioPipe
!=
null
)
{
{
...
@@ -255,7 +254,7 @@ internal void Shutdown()
...
@@ -255,7 +254,7 @@ internal void Shutdown()
public
void
Dispose
()
public
void
Dispose
()
{
{
bool
markDisposed
=
_s
ocket
!=
null
;
bool
markDisposed
=
VolatileS
ocket
!=
null
;
Shutdown
();
Shutdown
();
if
(
markDisposed
)
if
(
markDisposed
)
{
{
...
@@ -1097,7 +1096,7 @@ internal static void WriteInteger(PipeWriter writer, long value)
...
@@ -1097,7 +1096,7 @@ internal static void WriteInteger(PipeWriter writer, long value)
writer
.
Advance
(
bytes
);
writer
.
Advance
(
bytes
);
}
}
internal
int
GetAvailableInboundBytes
()
=>
_s
ocket
?.
Available
??
-
1
;
internal
int
GetAvailableInboundBytes
()
=>
VolatileS
ocket
?.
Available
??
-
1
;
private
RemoteCertificateValidationCallback
GetAmbientIssuerCertificateCallback
()
private
RemoteCertificateValidationCallback
GetAmbientIssuerCertificateCallback
()
{
{
...
...
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