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
5b5be771
Commit
5b5be771
authored
Jul 01, 2018
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup pass
parent
e898ec45
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
40 deletions
+68
-40
Directory.build.props
Directory.build.props
+5
-4
Shared.ruleset
Shared.ruleset
+7
-0
StackExchange.Redis.sln
StackExchange.Redis.sln
+1
-0
PhysicalBridge.cs
StackExchange.Redis/StackExchange/Redis/PhysicalBridge.cs
+1
-1
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+35
-24
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+19
-11
No files found.
Directory.build.props
View file @
5b5be771
...
@@ -8,14 +8,15 @@
...
@@ -8,14 +8,15 @@
<PackageId>$(AssemblyName)</PackageId>
<PackageId>$(AssemblyName)</PackageId>
<Authors>Stack Exchange, Inc.; marc.gravell</Authors>
<Authors>Stack Exchange, Inc.; marc.gravell</Authors>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleset>$(MSBuildThisFileDirectory)Shared.ruleset</CodeAnalysisRuleset>
<PackageReleaseNotes>https://stackexchange.github.io/StackExchange.Redis/ReleaseNotes</PackageReleaseNotes>
<PackageReleaseNotes>https://stackexchange.github.io/StackExchange.Redis/ReleaseNotes</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/StackExchange/StackExchange.Redis/</PackageProjectUrl>
<PackageProjectUrl>https://github.com/StackExchange/StackExchange.Redis/</PackageProjectUrl>
<PackageLicenseUrl>https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE</PackageLicenseUrl>
<PackageLicenseUrl>https://raw.github.com/StackExchange/StackExchange.Redis/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/StackExchange/StackExchange.Redis/</RepositoryUrl>
<RepositoryUrl>https://github.com/StackExchange/StackExchange.Redis/</RepositoryUrl>
<DebugSymbols>true</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<DebugType>embedded</DebugType>
<DebugType>embedded</DebugType>
<DefaultLanguage>en-US</DefaultLanguage>
<DefaultLanguage>en-US</DefaultLanguage>
...
@@ -27,7 +28,7 @@
...
@@ -27,7 +28,7 @@
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
<PackageReference Include="SourceLink.Create.GitHub" Version="2.8.2" PrivateAssets="All" />
<PackageReference Include="SourceLink.Create.GitHub" Version="2.8.2" PrivateAssets="All" />
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.2" />
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.2" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.8.2" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.8.2" />
</ItemGroup>
</ItemGroup>
...
...
Shared.ruleset
0 → 100644
View file @
5b5be771
<?xml version="1.0" encoding="utf-8"?>
<RuleSet
Name=
"Rules for StackOverflow"
Description=
"Code analysis rules for the StackOverflow solution."
ToolsVersion=
"15.0"
>
<IncludeAll
Action=
"Warning"
/>
<Rules
AnalyzerId=
"Roslynator.CSharp.Analyzers"
RuleNamespace=
"Roslynator.CSharp.Analyzers"
>
<Rule
Id=
"RCS1057"
Action=
"None"
/>
</Rules>
</RuleSet>
\ No newline at end of file
StackExchange.Redis.sln
View file @
5b5be771
...
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
...
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.build.props = Directory.build.props
Directory.build.props = Directory.build.props
global.json = global.json
global.json = global.json
NuGet.Config = NuGet.Config
NuGet.Config = NuGet.Config
Shared.ruleset = Shared.ruleset
version.json = version.json
version.json = version.json
EndProjectSection
EndProjectSection
EndProject
EndProject
...
...
StackExchange.Redis/StackExchange/Redis/PhysicalBridge.cs
View file @
5b5be771
...
@@ -38,7 +38,7 @@ internal sealed partial class PhysicalBridge : IDisposable
...
@@ -38,7 +38,7 @@ internal sealed partial class PhysicalBridge : IDisposable
private
int
profileLogIndex
;
private
int
profileLogIndex
;
private
volatile
bool
reportNextFailure
=
true
,
reconfigureNextFailure
=
false
;
private
volatile
bool
reportNextFailure
=
true
,
reconfigureNextFailure
=
false
;
private
volatile
int
state
=
(
int
)
State
.
Disconnected
;
private
volatile
int
state
=
(
int
)
State
.
Disconnected
;
public
PhysicalBridge
(
ServerEndPoint
serverEndPoint
,
ConnectionType
type
,
int
timeoutMilliseconds
)
public
PhysicalBridge
(
ServerEndPoint
serverEndPoint
,
ConnectionType
type
,
int
timeoutMilliseconds
)
...
...
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
5b5be771
This diff is collapsed.
Click to expand it.
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
5b5be771
...
@@ -54,6 +54,7 @@ internal partial interface ISocketCallback
...
@@ -54,6 +54,7 @@ internal partial interface ISocketCallback
internal
struct
SocketToken
internal
struct
SocketToken
{
{
internal
readonly
Socket
Socket
;
internal
readonly
Socket
Socket
;
public
SocketToken
(
Socket
socket
)
public
SocketToken
(
Socket
socket
)
{
{
Socket
=
socket
;
Socket
=
socket
;
...
@@ -130,10 +131,12 @@ internal static SocketManager Shared
...
@@ -130,10 +131,12 @@ internal static SocketManager Shared
shared
=
new
SocketManager
(
"DefaultSocketManager"
,
false
,
DEFAULT_MIN_THREADS
,
DEFAULT_MAX_THREADS
*
2
);
shared
=
new
SocketManager
(
"DefaultSocketManager"
,
false
,
DEFAULT_MIN_THREADS
,
DEFAULT_MAX_THREADS
*
2
);
if
(
Interlocked
.
CompareExchange
(
ref
_shared
,
shared
,
null
)
==
null
)
if
(
Interlocked
.
CompareExchange
(
ref
_shared
,
shared
,
null
)
==
null
)
shared
=
null
;
shared
=
null
;
}
finally
{
shared
?.
Dispose
();
}
}
finally
{
shared
?.
Dispose
();
}
return
Interlocked
.
CompareExchange
(
ref
_shared
,
null
,
null
);
return
Interlocked
.
CompareExchange
(
ref
_shared
,
null
,
null
);
}
}
}
}
private
static
SocketManager
_shared
;
private
static
SocketManager
_shared
;
/// <summary>
/// <summary>
...
@@ -142,21 +145,22 @@ internal static SocketManager Shared
...
@@ -142,21 +145,22 @@ internal static SocketManager Shared
/// <param name="name">The name for this <see cref="SocketManager"/>.</param>
/// <param name="name">The name for this <see cref="SocketManager"/>.</param>
/// <param name="useHighPrioritySocketThreads">Whether this <see cref="SocketManager"/> should use high priority sockets.</param>
/// <param name="useHighPrioritySocketThreads">Whether this <see cref="SocketManager"/> should use high priority sockets.</param>
public
SocketManager
(
string
name
,
bool
useHighPrioritySocketThreads
)
public
SocketManager
(
string
name
,
bool
useHighPrioritySocketThreads
)
:
this
(
name
,
useHighPrioritySocketThreads
,
DEFAULT_MIN_THREADS
,
DEFAULT_MAX_THREADS
)
{}
:
this
(
name
,
useHighPrioritySocketThreads
,
DEFAULT_MIN_THREADS
,
DEFAULT_MAX_THREADS
)
{
}
private
const
int
DEFAULT_MIN_THREADS
=
1
,
DEFAULT_MAX_THREADS
=
5
;
const
int
DEFAULT_MIN_THREADS
=
1
,
DEFAULT_MAX_THREADS
=
5
;
private
SocketManager
(
string
name
,
bool
useHighPrioritySocketThreads
,
int
minThreads
,
int
maxThreads
)
private
SocketManager
(
string
name
,
bool
useHighPrioritySocketThreads
,
int
minThreads
,
int
maxThreads
)
{
{
if
(
string
.
IsNullOrWhiteSpace
(
name
))
name
=
GetType
().
Name
;
if
(
string
.
IsNullOrWhiteSpace
(
name
))
name
=
GetType
().
Name
;
Name
=
name
;
Name
=
name
;
const
long
Receive_PauseWriterThreshold
=
4L
*
1024
*
1024
*
1024
;
// let's give it up to 4GiB of buffer for now
const
long
Receive_PauseWriterThreshold
=
4L
*
1024
*
1024
*
1024
;
// let's give it up to 4GiB of buffer for now
const
long
Receive_ResumeWriterThreshold
=
3L
*
1024
*
1024
*
1024
;
const
long
Receive_ResumeWriterThreshold
=
3L
*
1024
*
1024
*
1024
;
var
defaultPipeOptions
=
PipeOptions
.
Default
;
var
defaultPipeOptions
=
PipeOptions
.
Default
;
_scheduler
=
new
DedicatedThreadPoolPipeScheduler
(
name
,
_scheduler
=
new
DedicatedThreadPoolPipeScheduler
(
name
,
minWorkers
:
minThreads
,
maxWorkers
:
maxThreads
,
minWorkers
:
minThreads
,
maxWorkers
:
maxThreads
,
priority
:
useHighPrioritySocketThreads
?
ThreadPriority
.
AboveNormal
:
ThreadPriority
.
Normal
);
priority
:
useHighPrioritySocketThreads
?
ThreadPriority
.
AboveNormal
:
ThreadPriority
.
Normal
);
SendPipeOptions
=
new
PipeOptions
(
SendPipeOptions
=
new
PipeOptions
(
defaultPipeOptions
.
Pool
,
_scheduler
,
_scheduler
,
defaultPipeOptions
.
Pool
,
_scheduler
,
_scheduler
,
pauseWriterThreshold
:
defaultPipeOptions
.
PauseWriterThreshold
,
pauseWriterThreshold
:
defaultPipeOptions
.
PauseWriterThreshold
,
...
@@ -170,7 +174,8 @@ private SocketManager(string name, bool useHighPrioritySocketThreads, int minThr
...
@@ -170,7 +174,8 @@ private SocketManager(string name, bool useHighPrioritySocketThreads, int minThr
defaultPipeOptions
.
MinimumSegmentSize
,
defaultPipeOptions
.
MinimumSegmentSize
,
useSynchronizationContext
:
false
);
useSynchronizationContext
:
false
);
}
}
DedicatedThreadPoolPipeScheduler
_scheduler
;
private
DedicatedThreadPoolPipeScheduler
_scheduler
;
internal
readonly
PipeOptions
SendPipeOptions
,
ReceivePipeOptions
;
internal
readonly
PipeOptions
SendPipeOptions
,
ReceivePipeOptions
;
private
enum
CallbackOperation
private
enum
CallbackOperation
...
@@ -183,6 +188,7 @@ private enum CallbackOperation
...
@@ -183,6 +188,7 @@ private enum CallbackOperation
/// Releases all resources associated with this instance
/// Releases all resources associated with this instance
/// </summary>
/// </summary>
public
void
Dispose
()
=>
Dispose
(
true
);
public
void
Dispose
()
=>
Dispose
(
true
);
private
void
Dispose
(
bool
disposing
)
private
void
Dispose
(
bool
disposing
)
{
{
// note: the scheduler *can't* be collected by itself - there will
// note: the scheduler *can't* be collected by itself - there will
...
@@ -195,12 +201,13 @@ private void Dispose(bool disposing)
...
@@ -195,12 +201,13 @@ private void Dispose(bool disposing)
GC
.
SuppressFinalize
(
this
);
GC
.
SuppressFinalize
(
this
);
OnDispose
();
OnDispose
();
}
}
}
}
/// <summary>
/// <summary>
/// Releases *appropriate* resources associated with this instance
/// Releases *appropriate* resources associated with this instance
/// </summary>
/// </summary>
~
SocketManager
()
=>
Dispose
(
false
);
~
SocketManager
()
=>
Dispose
(
false
);
internal
SocketToken
BeginConnect
(
EndPoint
endpoint
,
ISocketCallback
callback
,
ConnectionMultiplexer
multiplexer
,
TextWriter
log
)
internal
SocketToken
BeginConnect
(
EndPoint
endpoint
,
ISocketCallback
callback
,
ConnectionMultiplexer
multiplexer
,
TextWriter
log
)
{
{
void
RunWithCompletionType
(
Func
<
AsyncCallback
,
IAsyncResult
>
beginAsync
,
AsyncCallback
asyncCallback
)
void
RunWithCompletionType
(
Func
<
AsyncCallback
,
IAsyncResult
>
beginAsync
,
AsyncCallback
asyncCallback
)
...
@@ -221,7 +228,6 @@ void proxyCallback(IAsyncResult ar)
...
@@ -221,7 +228,6 @@ void proxyCallback(IAsyncResult ar)
}
}
}
}
var
addressFamily
=
endpoint
.
AddressFamily
==
AddressFamily
.
Unspecified
?
AddressFamily
.
InterNetwork
:
endpoint
.
AddressFamily
;
var
addressFamily
=
endpoint
.
AddressFamily
==
AddressFamily
.
Unspecified
?
AddressFamily
.
InterNetwork
:
endpoint
.
AddressFamily
;
var
protocolType
=
addressFamily
==
AddressFamily
.
Unix
?
ProtocolType
.
Unspecified
:
ProtocolType
.
Tcp
;
var
protocolType
=
addressFamily
==
AddressFamily
.
Unix
?
ProtocolType
.
Unspecified
:
ProtocolType
.
Tcp
;
var
socket
=
new
Socket
(
addressFamily
,
SocketType
.
Stream
,
protocolType
);
var
socket
=
new
Socket
(
addressFamily
,
SocketType
.
Stream
,
protocolType
);
...
@@ -237,7 +243,8 @@ void proxyCallback(IAsyncResult ar)
...
@@ -237,7 +243,8 @@ void proxyCallback(IAsyncResult ar)
{
{
RunWithCompletionType
(
RunWithCompletionType
(
cb
=>
socket
.
BeginConnect
(
dnsEndpoint
.
Host
,
dnsEndpoint
.
Port
,
cb
,
tuple
),
cb
=>
socket
.
BeginConnect
(
dnsEndpoint
.
Host
,
dnsEndpoint
.
Port
,
cb
,
tuple
),
ar
=>
{
ar
=>
{
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
EndConnectImpl
(
ar
,
multiplexer
,
log
,
tuple
);
EndConnectImpl
(
ar
,
multiplexer
,
log
,
tuple
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
...
@@ -247,7 +254,8 @@ void proxyCallback(IAsyncResult ar)
...
@@ -247,7 +254,8 @@ void proxyCallback(IAsyncResult ar)
{
{
RunWithCompletionType
(
RunWithCompletionType
(
cb
=>
socket
.
BeginConnect
(
endpoint
,
cb
,
tuple
),
cb
=>
socket
.
BeginConnect
(
endpoint
,
cb
,
tuple
),
ar
=>
{
ar
=>
{
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
EndConnectImpl
(
ar
,
multiplexer
,
log
,
tuple
);
EndConnectImpl
(
ar
,
multiplexer
,
log
,
tuple
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
...
@@ -313,7 +321,7 @@ private async void EndConnectImpl(IAsyncResult ar, ConnectionMultiplexer multipl
...
@@ -313,7 +321,7 @@ private async void EndConnectImpl(IAsyncResult ar, ConnectionMultiplexer multipl
}
}
}
}
}
}
catch
(
Exception
outer
)
catch
(
Exception
outer
)
{
{
ConnectionMultiplexer
.
TraceWithoutContext
(
outer
.
Message
);
ConnectionMultiplexer
.
TraceWithoutContext
(
outer
.
Message
);
if
(
callback
!=
null
)
if
(
callback
!=
null
)
...
...
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