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
f80be103
Commit
f80be103
authored
Aug 16, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
attempt to fix async cx flow
parent
adbc96c0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
8 deletions
+24
-8
ChannelMessageQueue.cs
StackExchange.Redis/ChannelMessageQueue.cs
+8
-2
PhysicalBridge.cs
StackExchange.Redis/PhysicalBridge.cs
+5
-1
PhysicalConnection.cs
StackExchange.Redis/PhysicalConnection.cs
+11
-5
No files found.
StackExchange.Redis/ChannelMessageQueue.cs
View file @
f80be103
...
...
@@ -151,9 +151,12 @@ private void AssertOnMessage(Delegate handler)
public
void
OnMessage
(
Action
<
ChannelMessage
>
handler
)
{
AssertOnMessage
(
handler
);
using
(
ExecutionContext
.
SuppressFlow
())
{
ThreadPool
.
QueueUserWorkItem
(
state
=>
((
ChannelMessageQueue
)
state
).
OnMessageSyncImpl
(),
this
);
}
}
private
async
void
OnMessageSyncImpl
()
{
...
...
@@ -181,9 +184,12 @@ private async void OnMessageSyncImpl()
public
void
OnMessage
(
Func
<
ChannelMessage
,
Task
>
handler
)
{
AssertOnMessage
(
handler
);
using
(
ExecutionContext
.
SuppressFlow
())
{
ThreadPool
.
QueueUserWorkItem
(
state
=>
((
ChannelMessageQueue
)
state
).
OnMessageAsyncImpl
(),
this
);
}
}
private
async
void
OnMessageAsyncImpl
()
{
...
...
StackExchange.Redis/PhysicalBridge.cs
View file @
f80be103
...
...
@@ -668,9 +668,13 @@ private PhysicalConnection GetConnection(TextWriter log)
// separate creation and connection for case when connection completes synchronously
// in that case PhysicalConnection will call back to PhysicalBridge, and most of PhysicalBridge methods assumes that physical is not null;
physical
=
new
PhysicalConnection
(
this
);
using
(
ExecutionContext
.
SuppressFlow
())
{
physical
.
BeginConnectAsync
(
log
);
}
}
}
return
null
;
}
catch
(
Exception
ex
)
...
...
StackExchange.Redis/PhysicalConnection.cs
View file @
f80be103
...
...
@@ -77,7 +77,7 @@ internal async void BeginConnectAsync(TextWriter log)
Thread
.
VolatileWrite
(
ref
firstUnansweredWriteTickCount
,
0
);
var
bridge
=
BridgeCouldBeNull
;
var
endpoint
=
bridge
?.
ServerEndPoint
?.
EndPoint
;
if
(
endpoint
==
null
)
if
(
endpoint
==
null
)
{
log
?.
WriteLine
(
"No endpoint"
);
}
...
...
@@ -598,7 +598,7 @@ internal void OnBridgeHeartbeat()
internal
void
OnInternalError
(
Exception
exception
,
[
CallerMemberName
]
string
origin
=
null
)
{
var
bridge
=
BridgeCouldBeNull
;
if
(
bridge
!=
null
)
if
(
bridge
!=
null
)
{
bridge
.
Multiplexer
.
OnInternalError
(
exception
,
bridge
.
ServerEndPoint
.
EndPoint
,
connectionType
,
origin
);
}
...
...
@@ -983,7 +983,7 @@ internal static void WriteUnifiedPrefixedString(PipeWriter writer, byte[] prefix
internal
static
Encoder
GetPerThreadEncoder
()
{
var
encoder
=
s_PerThreadEncoder
;
if
(
encoder
==
null
)
if
(
encoder
==
null
)
{
s_PerThreadEncoder
=
encoder
=
Encoding
.
UTF8
.
GetEncoder
();
}
...
...
@@ -1171,7 +1171,7 @@ internal async ValueTask<bool> ConnectedAsync(Socket socket, TextWriter log, Soc
{
ssl
.
AuthenticateAsClient
(
host
,
config
.
SslProtocols
);
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
Debug
.
WriteLine
(
ex
.
Message
);
bridge
.
Multiplexer
?.
SetAuthSuspect
();
...
...
@@ -1494,7 +1494,13 @@ private static RawResult ReadLineTerminatedString(ResultType type, ref BufferRea
return
new
RawResult
(
type
,
payload
,
false
);
}
internal
void
StartReading
()
=>
ReadFromPipe
();
internal
void
StartReading
()
{
using
(
ExecutionContext
.
SuppressFlow
())
{
ReadFromPipe
();
}
}
internal
static
RawResult
TryParseResult
(
in
ReadOnlySequence
<
byte
>
buffer
,
ref
BufferReader
reader
,
bool
includeDetilInExceptions
,
ServerEndPoint
server
,
bool
allowInlineProtocol
=
false
)
...
...
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