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
664de5d3
Commit
664de5d3
authored
Mar 18, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix critical issue in connection fail (exception on worker)
parent
165bdc60
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
9 deletions
+62
-9
Lists.cs
StackExchange.Redis.Tests/Lists.cs
+39
-0
StackExchange.Redis.Tests.csproj
StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj
+1
-0
PhysicalConnection.cs
...kExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
+7
-5
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+15
-4
No files found.
StackExchange.Redis.Tests/Lists.cs
0 → 100644
View file @
664de5d3
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
NUnit.Framework
;
namespace
StackExchange.Redis.Tests
{
[
TestFixture
]
public
class
Lists
:
TestBase
{
[
Test
]
public
void
Ranges
()
{
using
(
var
conn
=
Create
())
{
var
db
=
conn
.
GetDatabase
();
RedisKey
key
=
Me
();
db
.
KeyDelete
(
key
,
CommandFlags
.
FireAndForget
);
db
.
ListRightPush
(
key
,
"abcdefghijklmnopqrstuvwxyz"
.
Select
(
x
=>
(
RedisValue
)
x
.
ToString
()).
ToArray
());
Assert
.
AreEqual
(
26
,
db
.
ListLength
(
key
));
Assert
.
AreEqual
(
"abcdefghijklmnopqrstuvwxyz"
,
string
.
Concat
(
db
.
ListRange
(
key
)));
var
last10
=
db
.
ListRange
(
key
,
-
10
,
-
1
);
Assert
.
AreEqual
(
"qrstuvwxyz"
,
string
.
Concat
(
last10
));
db
.
ListTrim
(
key
,
0
,
-
11
);
Assert
.
AreEqual
(
16
,
db
.
ListLength
(
key
));
Assert
.
AreEqual
(
"abcdefghijklmnop"
,
string
.
Concat
(
db
.
ListRange
(
key
)));
}
}
}
}
StackExchange.Redis.Tests/StackExchange.Redis.Tests.csproj
View file @
664de5d3
...
...
@@ -69,6 +69,7 @@
<Compile
Include=
"FloatingPoint.cs"
/>
<Compile
Include=
"Keys.cs"
/>
<Compile
Include=
"KeysAndValues.cs"
/>
<Compile
Include=
"Lists.cs"
/>
<Compile
Include=
"Locking.cs"
/>
<Compile
Include=
"MultiMaster.cs"
/>
<Compile
Include=
"Naming.cs"
/>
...
...
StackExchange.Redis/StackExchange/Redis/PhysicalConnection.cs
View file @
664de5d3
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Net
;
...
...
@@ -64,7 +65,7 @@ private static readonly Message
private
Stream
netStream
,
outStream
;
// things sent to this physical, but not yet received
Queue
<
Message
>
outstanding
=
new
Queue
<
Message
>();
private
readonly
Queue
<
Message
>
outstanding
=
new
Queue
<
Message
>();
private
SocketToken
socketToken
;
...
...
@@ -145,7 +146,7 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
// stop anything new coming in...
bridge
.
Trace
(
"Failed: "
+
failureType
);
bridge
.
OnDisconnected
(
failureType
,
this
);
if
(
Interlocked
.
CompareExchange
(
ref
failureReported
,
1
,
0
)
==
0
)
if
(
Interlocked
.
CompareExchange
(
ref
failureReported
,
1
,
0
)
==
0
)
{
try
{
...
...
@@ -161,11 +162,11 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
:
new
RedisConnectionException
(
failureType
,
message
,
innerException
);
throw
ex
;
}
catch
(
Exception
caught
)
catch
(
Exception
caught
)
{
bridge
.
OnConnectionFailed
(
this
,
failureType
,
caught
);
}
}
// cleanup
...
...
@@ -182,7 +183,8 @@ public void RecordConnectionFailed(ConnectionFailureType failureType, Exception
}
// burn the socket
multiplexer
.
SocketManager
.
Shutdown
(
socketToken
);
var
socketManager
=
multiplexer
.
SocketManager
;
if
(
socketManager
!=
null
)
socketManager
.
Shutdown
(
socketToken
);
}
public
override
string
ToString
()
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
664de5d3
...
...
@@ -282,10 +282,17 @@ private static void ProcessItems(Dictionary<IntPtr, SocketPair> socketLookup, Qu
#if VERBOSE
var
watch
=
Stopwatch
.
StartNew
();
#endif
switch
(
operation
)
try
{
case
CallbackOperation
.
Read
:
callback
.
Read
();
break
;
case
CallbackOperation
.
Error
:
callback
.
Error
();
break
;
switch
(
operation
)
{
case
CallbackOperation
.
Read
:
callback
.
Read
();
break
;
case
CallbackOperation
.
Error
:
callback
.
Error
();
break
;
}
}
catch
(
Exception
ex
)
{
Trace
.
WriteLine
(
ex
);
}
#if VERBOSE
watch
.
Stop
();
...
...
@@ -340,7 +347,11 @@ private void EndConnect(IAsyncResult ar)
{
if
(
tuple
!=
null
)
{
tuple
.
Item2
.
Error
();
try
{
tuple
.
Item2
.
Error
();
}
catch
(
Exception
ex
)
{
Trace
.
WriteLine
(
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