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
2629e253
Commit
2629e253
authored
Jul 07, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove SocketToken - that abstraction is no longer useful with the unified Socket code
parent
d8e8eb0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
42 deletions
+10
-42
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+7
-16
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+3
-26
No files found.
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
2629e253
...
@@ -72,7 +72,7 @@ private static readonly Message
...
@@ -72,7 +72,7 @@ private static readonly Message
private
IDuplexPipe
_ioPipe
;
private
IDuplexPipe
_ioPipe
;
private
Socket
Token
socketToken
;
private
Socket
_socket
;
public
PhysicalConnection
(
PhysicalBridge
bridge
)
public
PhysicalConnection
(
PhysicalBridge
bridge
)
{
{
...
@@ -94,7 +94,7 @@ public void BeginConnect(TextWriter log)
...
@@ -94,7 +94,7 @@ public void BeginConnect(TextWriter log)
var
endpoint
=
Bridge
.
ServerEndPoint
.
EndPoint
;
var
endpoint
=
Bridge
.
ServerEndPoint
.
EndPoint
;
Multiplexer
.
Trace
(
"Connecting..."
,
physicalName
);
Multiplexer
.
Trace
(
"Connecting..."
,
physicalName
);
socketToken
=
Multiplexer
.
SocketManager
.
BeginConnect
(
endpoint
,
this
,
Multiplexer
,
log
);
_socket
=
Multiplexer
.
SocketManager
.
BeginConnect
(
endpoint
,
this
,
Multiplexer
,
log
);
}
}
private
enum
ReadMode
:
byte
private
enum
ReadMode
:
byte
...
@@ -129,10 +129,10 @@ public void Dispose()
...
@@ -129,10 +129,10 @@ public void Dispose()
}
}
try
{
using
(
ioPipe
as
IDisposable
)
{
}
}
catch
{
}
try
{
using
(
ioPipe
as
IDisposable
)
{
}
}
catch
{
}
if
(
socketToken
.
HasValue
)
if
(
_socket
!=
null
)
{
{
Multiplexer
.
SocketManager
?.
Shutdown
(
socketToken
);
Multiplexer
.
SocketManager
?.
Shutdown
(
_socket
);
socketToken
=
default
(
SocketToken
)
;
_socket
=
default
;
Multiplexer
.
Trace
(
"Disconnected"
,
physicalName
);
Multiplexer
.
Trace
(
"Disconnected"
,
physicalName
);
RecordConnectionFailed
(
ConnectionFailureType
.
ConnectionDisposed
);
RecordConnectionFailed
(
ConnectionFailureType
.
ConnectionDisposed
);
}
}
...
@@ -255,7 +255,7 @@ void add(string lk, string sk, string v)
...
@@ -255,7 +255,7 @@ void add(string lk, string sk, string v)
// burn the socket
// burn the socket
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_ShutdownSocket
;
managerState
=
SocketManager
.
ManagerState
.
RecordConnectionFailed_ShutdownSocket
;
Multiplexer
.
SocketManager
?.
Shutdown
(
socketToken
);
Multiplexer
.
SocketManager
?.
Shutdown
(
_socket
);
}
}
public
override
string
ToString
()
public
override
string
ToString
()
...
@@ -845,7 +845,7 @@ private static void WriteUnified(PipeWriter writer, long value)
...
@@ -845,7 +845,7 @@ private static void WriteUnified(PipeWriter writer, long value)
writer
.
Advance
(
bytes
);
writer
.
Advance
(
bytes
);
}
}
internal
int
GetAvailableInboundBytes
()
=>
socketToken
.
Available
;
internal
int
GetAvailableInboundBytes
()
=>
_socket
?.
Available
??
0
;
private
static
LocalCertificateSelectionCallback
GetAmbientCertificateCallback
()
private
static
LocalCertificateSelectionCallback
GetAmbientCertificateCallback
()
{
{
...
@@ -1129,15 +1129,6 @@ private int ProcessBuffer(ref ReadOnlySequence<byte> buffer)
...
@@ -1129,15 +1129,6 @@ private int ProcessBuffer(ref ReadOnlySequence<byte> buffer)
// }
// }
//}
//}
bool
ISocketCallback
.
IsDataAvailable
{
get
{
try
{
return
socketToken
.
Available
>
0
;
}
catch
{
return
false
;
}
}
}
private
RawResult
ReadArray
(
in
ReadOnlySequence
<
byte
>
buffer
,
ref
BufferReader
reader
)
private
RawResult
ReadArray
(
in
ReadOnlySequence
<
byte
>
buffer
,
ref
BufferReader
reader
)
{
{
var
itemCount
=
ReadLineTerminatedString
(
ResultType
.
Integer
,
in
buffer
,
ref
reader
);
var
itemCount
=
ReadLineTerminatedString
(
ResultType
.
Integer
,
in
buffer
,
ref
reader
);
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
2629e253
...
@@ -47,22 +47,6 @@ internal partial interface ISocketCallback
...
@@ -47,22 +47,6 @@ internal partial interface ISocketCallback
// check for write-read timeout
// check for write-read timeout
void
CheckForStaleConnection
(
ref
SocketManager
.
ManagerState
state
);
void
CheckForStaleConnection
(
ref
SocketManager
.
ManagerState
state
);
bool
IsDataAvailable
{
get
;
}
}
internal
readonly
struct
SocketToken
{
internal
readonly
Socket
Socket
;
public
SocketToken
(
Socket
socket
)
{
Socket
=
socket
;
}
public
int
Available
=>
Socket
?.
Available
??
0
;
public
bool
HasValue
=>
Socket
!=
null
;
}
}
/// <summary>
/// <summary>
...
@@ -213,7 +197,7 @@ private void Dispose(bool disposing)
...
@@ -213,7 +197,7 @@ private void Dispose(bool disposing)
/// </summary>
/// </summary>
~
SocketManager
()
=>
Dispose
(
false
);
~
SocketManager
()
=>
Dispose
(
false
);
internal
Socket
Token
BeginConnect
(
EndPoint
endpoint
,
ISocketCallback
callback
,
ConnectionMultiplexer
multiplexer
,
TextWriter
log
)
internal
Socket
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
)
{
{
...
@@ -275,15 +259,8 @@ void proxyCallback(IAsyncResult ar)
...
@@ -275,15 +259,8 @@ void proxyCallback(IAsyncResult ar)
}
}
throw
;
throw
;
}
}
var
token
=
new
SocketToken
(
socket
);
return
socket
;
return
token
;
}
internal
void
Shutdown
(
SocketToken
token
)
{
Shutdown
(
token
.
Socket
);
}
}
private
async
void
EndConnectImpl
(
IAsyncResult
ar
,
ConnectionMultiplexer
multiplexer
,
TextWriter
log
,
Tuple
<
Socket
,
ISocketCallback
>
tuple
)
private
async
void
EndConnectImpl
(
IAsyncResult
ar
,
ConnectionMultiplexer
multiplexer
,
TextWriter
log
,
Tuple
<
Socket
,
ISocketCallback
>
tuple
)
{
{
var
socket
=
tuple
.
Item1
;
var
socket
=
tuple
.
Item1
;
...
@@ -346,7 +323,7 @@ private async void EndConnectImpl(IAsyncResult ar, ConnectionMultiplexer multipl
...
@@ -346,7 +323,7 @@ private async void EndConnectImpl(IAsyncResult ar, ConnectionMultiplexer multipl
partial
void
ShouldIgnoreConnect
(
ISocketCallback
callback
,
ref
bool
ignore
);
partial
void
ShouldIgnoreConnect
(
ISocketCallback
callback
,
ref
bool
ignore
);
[
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"
)]
private
void
Shutdown
(
Socket
socket
)
internal
void
Shutdown
(
Socket
socket
)
{
{
if
(
socket
!=
null
)
if
(
socket
!=
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