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
dfebeb7d
Commit
dfebeb7d
authored
Sep 20, 2015
by
Jeremy Meng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Volatile.{Read,Write} instead.
parent
905f7d7c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
12 deletions
+12
-12
ConnectionMultiplexer.cs
...change.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
+3
-3
PhysicalBridge.cs
StackExchange.Redis/StackExchange/Redis/PhysicalBridge.cs
+1
-1
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+7
-7
ServerEndPoint.cs
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
+1
-1
No files found.
StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs
View file @
dfebeb7d
...
@@ -941,11 +941,11 @@ private void OnHeartbeat()
...
@@ -941,11 +941,11 @@ private void OnHeartbeat()
internal
long
LastHeartbeatSecondsAgo
{
internal
long
LastHeartbeatSecondsAgo
{
get
{
get
{
if
(
pulse
==
null
)
return
-
1
;
if
(
pulse
==
null
)
return
-
1
;
return
unchecked
(
Environment
.
TickCount
-
Thread
.
Volatile
Read
(
ref
lastHeartbeatTicks
))
/
1000
;
return
unchecked
(
Environment
.
TickCount
-
Volatile
.
Read
(
ref
lastHeartbeatTicks
))
/
1000
;
}
}
}
}
internal
static
long
LastGlobalHeartbeatSecondsAgo
internal
static
long
LastGlobalHeartbeatSecondsAgo
{
get
{
return
unchecked
(
Environment
.
TickCount
-
Thread
.
Volatile
Read
(
ref
lastGlobalHeartbeatTicks
))
/
1000
;
}
}
{
get
{
return
unchecked
(
Environment
.
TickCount
-
Volatile
.
Read
(
ref
lastGlobalHeartbeatTicks
))
/
1000
;
}
}
internal
CompletionManager
UnprocessableCompletionManager
{
get
{
return
unprocessableCompletionManager
;
}
}
internal
CompletionManager
UnprocessableCompletionManager
{
get
{
return
unprocessableCompletionManager
;
}
}
...
...
StackExchange.Redis/StackExchange/Redis/PhysicalBridge.cs
View file @
dfebeb7d
...
@@ -394,7 +394,7 @@ internal void OnHeartbeat(bool ifConnectedOnly)
...
@@ -394,7 +394,7 @@ internal void OnHeartbeat(bool ifConnectedOnly)
switch
(
state
)
switch
(
state
)
{
{
case
(
int
)
State
.
Connecting
:
case
(
int
)
State
.
Connecting
:
int
connectTimeMilliseconds
=
unchecked
(
Environment
.
TickCount
-
Thread
.
Volatile
Read
(
ref
connectStartTicks
));
int
connectTimeMilliseconds
=
unchecked
(
Environment
.
TickCount
-
Volatile
.
Read
(
ref
connectStartTicks
));
if
(
connectTimeMilliseconds
>=
multiplexer
.
RawConfig
.
ConnectTimeout
)
if
(
connectTimeMilliseconds
>=
multiplexer
.
RawConfig
.
ConnectTimeout
)
{
{
Trace
(
"Aborting connect"
);
Trace
(
"Aborting connect"
);
...
...
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
dfebeb7d
...
@@ -93,7 +93,7 @@ public PhysicalConnection(PhysicalBridge bridge)
...
@@ -93,7 +93,7 @@ public PhysicalConnection(PhysicalBridge bridge)
public
void
BeginConnect
(
TextWriter
log
)
public
void
BeginConnect
(
TextWriter
log
)
{
{
Thread
.
Volatile
Write
(
ref
firstUnansweredWriteTickCount
,
0
);
Volatile
.
Write
(
ref
firstUnansweredWriteTickCount
,
0
);
var
endpoint
=
this
.
bridge
.
ServerEndPoint
.
EndPoint
;
var
endpoint
=
this
.
bridge
.
ServerEndPoint
.
EndPoint
;
multiplexer
.
Trace
(
"Connecting..."
,
physicalName
);
multiplexer
.
Trace
(
"Connecting..."
,
physicalName
);
...
@@ -113,7 +113,7 @@ public long LastWriteSecondsAgo
...
@@ -113,7 +113,7 @@ public long LastWriteSecondsAgo
{
{
get
get
{
{
return
unchecked
(
Environment
.
TickCount
-
Thread
.
Volatile
Read
(
ref
lastWriteTickCount
))
/
1000
;
return
unchecked
(
Environment
.
TickCount
-
Volatile
.
Read
(
ref
lastWriteTickCount
))
/
1000
;
}
}
}
}
...
@@ -193,9 +193,9 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, ref Socket
...
@@ -193,9 +193,9 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, ref Socket
if
(
isCurrent
&&
Interlocked
.
CompareExchange
(
ref
failureReported
,
1
,
0
)
==
0
)
if
(
isCurrent
&&
Interlocked
.
CompareExchange
(
ref
failureReported
,
1
,
0
)
==
0
)
{
{
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_ReportFailure
;
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_ReportFailure
;
int
now
=
Environment
.
TickCount
,
lastRead
=
Thread
.
VolatileRead
(
ref
lastReadTickCount
),
lastWrite
=
Thread
.
Volatile
Read
(
ref
lastWriteTickCount
),
int
now
=
Environment
.
TickCount
,
lastRead
=
Volatile
.
Read
(
ref
lastReadTickCount
),
lastWrite
=
Volatile
.
Read
(
ref
lastWriteTickCount
),
lastBeat
=
Thread
.
Volatile
Read
(
ref
lastBeatTickCount
);
lastBeat
=
Volatile
.
Read
(
ref
lastBeatTickCount
);
int
unansweredRead
=
Thread
.
Volatile
Read
(
ref
firstUnansweredWriteTickCount
);
int
unansweredRead
=
Volatile
.
Read
(
ref
firstUnansweredWriteTickCount
);
var
exMessage
=
new
StringBuilder
(
failureType
+
" on "
+
Format
.
ToString
(
bridge
.
ServerEndPoint
.
EndPoint
)
+
"/"
+
connectionType
);
var
exMessage
=
new
StringBuilder
(
failureType
+
" on "
+
Format
.
ToString
(
bridge
.
ServerEndPoint
.
EndPoint
)
+
"/"
+
connectionType
);
var
data
=
new
List
<
Tuple
<
string
,
string
>>
var
data
=
new
List
<
Tuple
<
string
,
string
>>
...
@@ -903,7 +903,7 @@ private bool ProcessReadBytes(int bytesRead)
...
@@ -903,7 +903,7 @@ private bool ProcessReadBytes(int bytesRead)
Interlocked
.
Exchange
(
ref
lastReadTickCount
,
Environment
.
TickCount
);
Interlocked
.
Exchange
(
ref
lastReadTickCount
,
Environment
.
TickCount
);
// reset unanswered write timestamp
// reset unanswered write timestamp
Thread
.
Volatile
Write
(
ref
firstUnansweredWriteTickCount
,
0
);
Volatile
.
Write
(
ref
firstUnansweredWriteTickCount
,
0
);
ioBufferBytes
+=
bytesRead
;
ioBufferBytes
+=
bytesRead
;
multiplexer
.
Trace
(
"More bytes available: "
+
bytesRead
+
" ("
+
ioBufferBytes
+
")"
,
physicalName
);
multiplexer
.
Trace
(
"More bytes available: "
+
bytesRead
+
" ("
+
ioBufferBytes
+
")"
,
physicalName
);
...
@@ -1066,7 +1066,7 @@ RawResult TryParseResult(byte[] buffer, ref int offset, ref int count)
...
@@ -1066,7 +1066,7 @@ RawResult TryParseResult(byte[] buffer, ref int offset, ref int count)
public
void
CheckForStaleConnection
(
ref
SocketManager
.
ManagerState
managerState
)
public
void
CheckForStaleConnection
(
ref
SocketManager
.
ManagerState
managerState
)
{
{
int
firstUnansweredWrite
;
int
firstUnansweredWrite
;
firstUnansweredWrite
=
Thread
.
Volatile
Read
(
ref
firstUnansweredWriteTickCount
);
firstUnansweredWrite
=
Volatile
.
Read
(
ref
firstUnansweredWriteTickCount
);
DebugEmulateStaleConnection
(
ref
firstUnansweredWrite
);
DebugEmulateStaleConnection
(
ref
firstUnansweredWrite
);
...
...
StackExchange.Redis/StackExchange/Redis/ServerEndPoint.cs
View file @
dfebeb7d
...
@@ -484,7 +484,7 @@ internal void OnFullyEstablished(PhysicalConnection connection)
...
@@ -484,7 +484,7 @@ internal void OnFullyEstablished(PhysicalConnection connection)
internal
int
LastInfoReplicationCheckSecondsAgo
internal
int
LastInfoReplicationCheckSecondsAgo
{
{
get
{
return
unchecked
(
Environment
.
TickCount
-
Thread
.
Volatile
Read
(
ref
lastInfoReplicationCheckTicks
))
/
1000
;
}
get
{
return
unchecked
(
Environment
.
TickCount
-
Volatile
.
Read
(
ref
lastInfoReplicationCheckTicks
))
/
1000
;
}
}
}
private
EndPoint
masterEndPoint
;
private
EndPoint
masterEndPoint
;
...
...
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