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
33554edc
Commit
33554edc
authored
Dec 10, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Completely untested, but I *think* this comes close to fixing the Connect API problem
parent
01817068
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
22 deletions
+34
-22
DebuggingAids.cs
StackExchange.Redis/StackExchange/Redis/DebuggingAids.cs
+3
-1
SocketManager.cs
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
+31
-21
No files found.
StackExchange.Redis/StackExchange/Redis/DebuggingAids.cs
View file @
33554edc
...
@@ -299,9 +299,10 @@ public enum CompletionType
...
@@ -299,9 +299,10 @@ public enum CompletionType
/// </summary>
/// </summary>
Async
=
2
Async
=
2
}
}
#if !CORE_CLR
internal
class
CompletionTypeHelper
internal
class
CompletionTypeHelper
{
{
public
static
void
RunWithCompletionType
(
Func
<
AsyncCallback
,
IAsyncResult
>
beginAsync
,
AsyncCallback
callback
,
CompletionType
completionType
)
public
static
void
RunWithCompletionType
(
Func
<
AsyncCallback
,
IAsyncResult
>
beginAsync
,
AsyncCallback
callback
,
CompletionType
completionType
)
{
{
AsyncCallback
proxyCallback
;
AsyncCallback
proxyCallback
;
...
@@ -343,6 +344,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin
...
@@ -343,6 +344,7 @@ public static void RunWithCompletionType(Func<AsyncCallback, IAsyncResult> begin
return
;
return
;
}
}
}
}
#endif
#if VERBOSE
#if VERBOSE
...
...
StackExchange.Redis/StackExchange/Redis/SocketManager.cs
View file @
33554edc
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
using
System.Net
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Net.Sockets
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
StackExchange.Redis
namespace
StackExchange.Redis
{
{
...
@@ -172,45 +173,56 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback, C
...
@@ -172,45 +173,56 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback, C
this
.
ShouldForceConnectCompletionType
(
ref
connectCompletionType
);
this
.
ShouldForceConnectCompletionType
(
ref
connectCompletionType
);
var
formattedEndpoint
=
Format
.
ToString
(
endpoint
);
var
formattedEndpoint
=
Format
.
ToString
(
endpoint
);
var
tuple
=
Tuple
.
Create
(
socket
,
callback
);
if
(
endpoint
is
DnsEndPoint
)
if
(
endpoint
is
DnsEndPoint
)
{
{
// A work-around for a Mono bug in BeginConnect(EndPoint endpoint, AsyncCallback callback, object state)
// A work-around for a Mono bug in BeginConnect(EndPoint endpoint, AsyncCallback callback, object state)
DnsEndPoint
dnsEndpoint
=
(
DnsEndPoint
)
endpoint
;
DnsEndPoint
dnsEndpoint
=
(
DnsEndPoint
)
endpoint
;
CompletionTypeHelper
.
RunWithCompletionType
(
(
cb
)
=>
{
multiplexer
.
LogLocked
(
log
,
"BeginConnect: {0}"
,
formattedEndpoint
);
#if CORE_CLR
#if CORE_CLR
throw
new
NotImplementedException
(
"TODO CORE CLR"
);
multiplexer
.
LogLocked
(
log
,
"BeginConnect: {0}"
,
formattedEndpoint
);
socket
.
ConnectAsync
(
dnsEndpoint
.
Host
,
dnsEndpoint
.
Port
).
ContinueWith
(
t
=>
{
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
EndConnectImpl
(
t
,
multiplexer
,
log
,
tuple
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
});
#else
#else
return
socket
.
BeginConnect
(
dnsEndpoint
.
Host
,
dnsEndpoint
.
Port
,
cb
,
Tuple
.
Create
(
socket
,
callback
));
CompletionTypeHelper
.
RunWithCompletionType
(
#endif
(
cb
)
=>
{
multiplexer
.
LogLocked
(
log
,
"BeginConnect: {0}"
,
formattedEndpoint
);
return
socket
.
BeginConnect
(
dnsEndpoint
.
Host
,
dnsEndpoint
.
Port
,
cb
,
tuple
);
},
},
(
ar
)
=>
(
ar
)
=>
{
{
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
EndConnectImpl
(
ar
,
multiplexer
,
log
,
tuple
);
EndConnectImpl
(
ar
,
multiplexer
,
log
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
},
},
connectCompletionType
);
connectCompletionType
);
#endif
}
}
else
else
{
{
#if CORE_CLR
multiplexer
.
LogLocked
(
log
,
"BeginConnect: {0}"
,
formattedEndpoint
);
socket
.
ConnectAsync
(
endpoint
).
ContinueWith
(
t
=>
{
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
EndConnectImpl
(
t
,
multiplexer
,
log
,
tuple
);
});
#else
CompletionTypeHelper
.
RunWithCompletionType
(
CompletionTypeHelper
.
RunWithCompletionType
(
(
cb
)
=>
{
(
cb
)
=>
{
multiplexer
.
LogLocked
(
log
,
"BeginConnect: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"BeginConnect: {0}"
,
formattedEndpoint
);
#if CORE_CLR
return
socket
.
BeginConnect
(
endpoint
,
cb
,
tuple
);
throw
new
NotImplementedException
(
"TODO CORE CLR"
);
#else
return
socket
.
BeginConnect
(
endpoint
,
cb
,
Tuple
.
Create
(
socket
,
callback
));
#endif
},
},
(
ar
)
=>
{
(
ar
)
=>
{
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"EndConnect: {0}"
,
formattedEndpoint
);
EndConnectImpl
(
ar
,
multiplexer
,
log
);
EndConnectImpl
(
ar
,
multiplexer
,
log
,
tuple
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
multiplexer
.
LogLocked
(
log
,
"Connect complete: {0}"
,
formattedEndpoint
);
},
},
connectCompletionType
);
connectCompletionType
);
#endif
}
}
}
}
catch
(
NotImplementedException
ex
)
catch
(
NotImplementedException
ex
)
...
@@ -273,19 +285,17 @@ internal void Shutdown(SocketToken token)
...
@@ -273,19 +285,17 @@ internal void Shutdown(SocketToken token)
Shutdown
(
token
.
Socket
);
Shutdown
(
token
.
Socket
);
}
}
private
void
EndConnectImpl
(
IAsyncResult
ar
,
ConnectionMultiplexer
multiplexer
,
TextWriter
log
)
private
void
EndConnectImpl
(
IAsyncResult
ar
,
ConnectionMultiplexer
multiplexer
,
TextWriter
log
,
Tuple
<
Socket
,
ISocketCallback
>
tuple
)
{
{
Tuple
<
Socket
,
ISocketCallback
>
tuple
=
null
;
try
try
{
{
tuple
=
(
Tuple
<
Socket
,
ISocketCallback
>)
ar
.
AsyncState
;
bool
ignoreConnect
=
false
;
bool
ignoreConnect
=
false
;
ShouldIgnoreConnect
(
tuple
.
Item2
,
ref
ignoreConnect
);
ShouldIgnoreConnect
(
tuple
.
Item2
,
ref
ignoreConnect
);
if
(
ignoreConnect
)
return
;
if
(
ignoreConnect
)
return
;
var
socket
=
tuple
.
Item1
;
var
socket
=
tuple
.
Item1
;
var
callback
=
tuple
.
Item2
;
var
callback
=
tuple
.
Item2
;
#if CORE_CLR
#if CORE_CLR
throw
new
NotImplementedException
(
"TODO CORE CLR"
);
multiplexer
.
Wait
((
Task
)
ar
);
// make it explode if invalid (note: already complete at this point)
#else
#else
socket
.
EndConnect
(
ar
);
socket
.
EndConnect
(
ar
);
...
...
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