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
b3c880b3
Commit
b3c880b3
authored
Jun 26, 2018
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix length vs position error in ReadLineTerminatedString
parent
b0637c6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
42 deletions
+43
-42
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+17
-20
Program.cs
TestConsole/Program.cs
+26
-22
No files found.
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
b3c880b3
...
...
@@ -1140,15 +1140,13 @@ private RawResult ReadBulkString(in ReadOnlySequence<byte> buffer, ref BufferRea
private
RawResult
ReadLineTerminatedString
(
ResultType
type
,
in
ReadOnlySequence
<
byte
>
buffer
,
ref
BufferReader
reader
)
{
int
crlf
=
BufferReader
.
FindNextCrLf
(
reader
);
int
crlfOffsetFromCurrent
=
BufferReader
.
FindNextCrLf
(
reader
);
if
(
crlfOffsetFromCurrent
<
0
)
return
RawResult
.
Nil
;
if
(
crlf
<
0
)
return
RawResult
.
Nil
;
var
payload
=
buffer
.
Slice
(
reader
.
TotalConsumed
,
crlfOffsetFromCurrent
);
reader
.
Consume
(
crlfOffsetFromCurrent
+
2
);
var
inner
=
buffer
.
Slice
(
reader
.
TotalConsumed
,
crlf
);
reader
.
Consume
(
crlf
+
2
);
return
new
RawResult
(
type
,
inner
,
false
);
return
new
RawResult
(
type
,
payload
,
false
);
}
void
ISocketCallback
.
StartReading
()
=>
ReadFromPipe
();
...
...
@@ -1185,7 +1183,9 @@ public enum ConsumeResult
private
ReadOnlySequence
<
byte
>.
Enumerator
_iterator
;
private
ReadOnlySpan
<
byte
>
_current
;
public
ReadOnlySpan
<
byte
>
Span
=>
_current
;
public
ReadOnlySpan
<
byte
>
OversizedSpan
=>
_current
;
public
ReadOnlySpan
<
byte
>
SlicedSpan
=>
_current
.
Slice
(
OffsetThisSpan
,
RemainingThisSpan
);
public
int
OffsetThisSpan
{
get
;
private
set
;
}
public
int
TotalConsumed
{
get
;
private
set
;
}
public
int
RemainingThisSpan
{
get
;
private
set
;
}
...
...
@@ -1280,23 +1280,20 @@ public void Consume(int count)
bool
haveTrailingCR
=
false
;
do
{
var
span
=
reader
.
Span
;
if
(
reader
.
OffsetThisSpan
!=
0
)
span
=
span
.
Slice
(
reader
.
OffsetThisSpan
);
if
(
span
.
IsEmpty
)
if
(
reader
.
RemainingThisSpan
==
0
)
continue
;
var
span
=
reader
.
SlicedSpan
;
if
(
haveTrailingCR
)
{
if
(
span
[
0
]
==
'\n'
)
return
totalSkipped
-
1
;
haveTrailingCR
=
false
;
}
else
{
if
(
haveTrailingCR
&&
span
[
0
]
==
'\n'
)
return
totalSkipped
-
1
;
int
found
=
span
.
IndexOf
(
CRLF
);
if
(
found
>=
0
)
return
totalSkipped
+
found
;
int
found
=
span
.
IndexOf
(
CRLF
);
if
(
found
>=
0
)
return
totalSkipped
+
found
;
haveTrailingCR
=
span
[
span
.
Length
-
1
]
==
'\r'
;
totalSkipped
+=
span
.
Length
;
}
haveTrailingCR
=
span
[
span
.
Length
-
1
]
==
'\r'
;
totalSkipped
+=
span
.
Length
;
}
while
(
reader
.
FetchNextSegment
());
return
-
1
;
...
...
TestConsole/Program.cs
View file @
b3c880b3
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.IO.Pipelines
;
using
System.Linq
;
using
StackExchange.Redis
;
class
Program
{
static
int
Main
()
{
var
options
=
PipeOptions
.
Default
;
Console
.
WriteLine
(
options
.
PauseWriterThreshold
);
Console
.
WriteLine
(
options
.
ResumeWriterThreshold
);
var
s
=
new
StringWriter
();
try
{
#if DEBUG
Pipelines
.
Sockets
.
Unofficial
.
DebugCounters
.
SetLog
(
Console
.
Out
);
//
Pipelines.Sockets.Unofficial.DebugCounters.SetLog(Console.Out);
#endif
// it is sometimes hard to get the debugger to play nicely with benchmarkdotnet/xunit attached,
// so this is just a *trivial* exe
var
config
=
new
ConfigurationOptions
{
EndPoints
=
{
"127.0.0.1"
},
//TieBreaker = "",
//CommandMap = CommandMap.Create(new Dictionary<string, string>
//{
// ["SUBSCRIBE"] = null,
// ["PSUBSCRIBE"] = null,
//})
};
using
(
var
conn
=
ConnectionMultiplexer
.
Connect
(
config
,
log
:
s
))
{
Console
.
WriteLine
(
"Connected"
);
var
db
=
conn
.
GetDatabase
();
db
.
StringSet
(
"abc"
,
"def"
);
var
x
=
db
.
StringGet
(
"abc"
);
Console
.
WriteLine
(
x
);
//for (int i = 0; i < 10; i++)
//{
// Console.WriteLine($"Ping {i}");
// db.Ping();
//}
Execute
(
conn
);
}
Console
.
WriteLine
(
"Clean exit"
);
return
0
;
...
...
@@ -49,8 +38,23 @@ static int Main()
}
finally
{
Console
.
WriteLine
();
Console
.
WriteLine
(
s
);
//
Console.WriteLine();
//
Console.WriteLine(s);
}
}
private
static
void
Execute
(
ConnectionMultiplexer
conn
)
{
int
pageSize
=
100
;
RedisKey
key
=
nameof
(
Execute
);
var
db
=
conn
.
GetDatabase
();
db
.
KeyDelete
(
key
);
for
(
int
i
=
0
;
i
<
2000
;
i
++)
db
.
SetAdd
(
key
,
"s"
+
i
,
flags
:
CommandFlags
.
FireAndForget
);
int
count
=
db
.
SetScan
(
key
,
pageSize
:
pageSize
).
Count
();
Console
.
WriteLine
(
count
==
2000
?
"Pass"
:
"Fail"
);
}
}
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