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
cad9dacd
Commit
cad9dacd
authored
Jun 17, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update socket lib
parent
82a73263
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
8 deletions
+21
-8
Program.cs
BasicTest/Program.cs
+2
-0
StackExchange.Redis.csproj
StackExchange.Redis/StackExchange.Redis.csproj
+1
-1
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+12
-5
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+6
-2
No files found.
BasicTest/Program.cs
View file @
cad9dacd
using
System
;
using
System.Diagnostics
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
StackExchange.Redis
;
...
...
@@ -9,6 +10,7 @@ internal static class Program
{
public
static
async
Task
Main
()
{
Thread
.
CurrentThread
.
Name
=
nameof
(
Main
);
using
(
var
conn
=
await
ConnectionMultiplexer
.
ConnectAsync
(
"127.0.0.1:6379,syncTimeout=2000"
))
{
int
expected
=
0
;
...
...
StackExchange.Redis/StackExchange.Redis.csproj
View file @
cad9dacd
...
...
@@ -31,6 +31,6 @@
<PackageReference Include="System.Memory" Version="$(CoreFxVersion)" />
<PackageReference Include="System.Buffers" Version="$(CoreFxVersion)" />
<PackageReference Include="System.IO.Pipelines" Version="$(CoreFxVersion)" />
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="0.2.0-alpha-00
5
" />
<PackageReference Include="Pipelines.Sockets.Unofficial" Version="0.2.0-alpha-00
7
" />
</ItemGroup>
</Project>
\ No newline at end of file
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
cad9dacd
...
...
@@ -975,27 +975,34 @@ void ISocketCallback.OnHeartbeat()
}
partial
void
OnWrapForLogging
(
ref
IDuplexPipe
pipe
,
string
name
);
private
async
void
ReadFromPipe
()
// yes it is an async void; deal with it!
{
try
{
bool
allowSyncRead
=
true
;
while
(
true
)
{
var
input
=
_ioPipe
?.
Input
;
if
(
input
==
null
)
break
;
var
readResult
=
await
input
.
ReadAsync
();
// note: TryRead will give us back the same buffer in a tight loop
// - so: only use that if we're making progress
if
(!(
allowSyncRead
&&
input
.
TryRead
(
out
var
readResult
)))
{
readResult
=
await
input
.
ReadAsync
();
}
if
(
readResult
.
IsCompleted
&&
readResult
.
Buffer
.
IsEmpty
)
{
break
;
// we're all done
}
var
buffer
=
readResult
.
Buffer
;
var
s
=
new
RawResult
(
ResultType
.
BulkString
,
buffer
,
false
).
GetString
().
Replace
(
"\r"
,
"\\r"
).
Replace
(
"\n"
,
"\\n"
);
int
handled
=
ProcessBuffer
(
ref
buffer
);
// updates buffer.Start
allowSyncRead
=
handled
!=
0
;
Multiplexer
.
Trace
(
$"Processed
{
handled
}
messages"
,
physicalName
);
input
.
AdvanceTo
(
buffer
.
Start
,
buffer
.
End
);
}
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
cad9dacd
...
...
@@ -174,8 +174,12 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback, C
{
var
formattedEndpoint
=
Format
.
ToString
(
endpoint
);
SocketConnection
.
ConnectAsync
(
endpoint
,
PipeOptions
,
conn
=>
EndConnectAsync
(
conn
,
multiplexer
,
log
,
callback
),
socket
);
var
t
=
SocketConnection
.
ConnectAsync
(
endpoint
,
PipeOptions
,
//SocketConnectionOptions.SyncReader | SocketConnectionOptions.SyncWriter,
SocketConnectionOptions
.
None
,
onConnected
:
conn
=>
EndConnectAsync
(
conn
,
multiplexer
,
log
,
callback
),
socket
:
socket
);
GC
.
KeepAlive
(
t
);
// make compiler happier
}
catch
(
NotImplementedException
ex
)
{
...
...
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