Commit aab404ad authored by Marc Gravell's avatar Marc Gravell

Tell mono folks why their DNS-based connect fails, and what to do about it

parent aecbdea6
...@@ -27,7 +27,7 @@ static void Main(string[] args) ...@@ -27,7 +27,7 @@ static void Main(string[] args)
} }
static void MassiveBulkOpsAsync(int AsyncOpsQty, bool preserveOrder, bool withContinuation) static void MassiveBulkOpsAsync(int AsyncOpsQty, bool preserveOrder, bool withContinuation)
{ {
using (var muxer = ConnectionMultiplexer.Connect("127.0.0.1")) using (var muxer = ConnectionMultiplexer.Connect("localhost,resolvedns=1"))
{ {
muxer.PreserveAsyncOrder = preserveOrder; muxer.PreserveAsyncOrder = preserveOrder;
RedisKey key = "MBOA"; RedisKey key = "MBOA";
......
...@@ -67,7 +67,15 @@ protected override void InsertItem(int index, EndPoint item) ...@@ -67,7 +67,15 @@ protected override void InsertItem(int index, EndPoint item)
protected override void SetItem(int index, EndPoint item) protected override void SetItem(int index, EndPoint item)
{ {
if (item == null) throw new ArgumentNullException("item"); if (item == null) throw new ArgumentNullException("item");
int existingIndex = IndexOf(item); int existingIndex;
try
{
existingIndex = IndexOf(item);
} catch(NullReferenceException)
{
// mono has a nasty bug in DnsEndPoint.Equals; if they do bad things here: sorry, I can't help
existingIndex = -1;
}
if (existingIndex >= 0 && existingIndex != index) throw new ArgumentException("EndPoints must be unique", "item"); if (existingIndex >= 0 && existingIndex != index) throw new ArgumentException("EndPoints must be unique", "item");
base.SetItem(index, item); base.SetItem(index, item);
} }
......
...@@ -122,7 +122,17 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback) ...@@ -122,7 +122,17 @@ internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback)
var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
SetFastLoopbackOption(socket); SetFastLoopbackOption(socket);
socket.NoDelay = true; socket.NoDelay = true;
try
{
socket.BeginConnect(endpoint, EndConnect, Tuple.Create(socket, callback)); socket.BeginConnect(endpoint, EndConnect, Tuple.Create(socket, callback));
} catch (NotImplementedException ex)
{
if (!(endpoint is IPEndPoint))
{
throw new InvalidOperationException("BeginConnect failed with NotImplementedException; consider using IP endpoints, or enable ResolveDns in the configuration", ex);
}
throw;
}
return new SocketToken(socket); return new SocketToken(socket);
} }
internal void SetFastLoopbackOption(Socket socket) internal void SetFastLoopbackOption(Socket socket)
......
...@@ -3,7 +3,7 @@ rm -rf BasicTest/bin/mono ...@@ -3,7 +3,7 @@ rm -rf BasicTest/bin/mono
mkdir -p StackExchange.Redis/bin/mono mkdir -p StackExchange.Redis/bin/mono
mkdir -p BasicTest/bin/mono mkdir -p BasicTest/bin/mono
echo -e "Building StackExchange.Redis.dll ..." echo -e "Building StackExchange.Redis.dll ..."
mcs -recurse:StackExchange.Redis/*.cs -out:StackExchange.Redis/bin/mono/StackExchange.Redis.dll -target:library -unsafe+ -o+ -r:System.IO.Compression.dll -d:MONO mcs -recurse:StackExchange.Redis/*.cs -out:StackExchange.Redis/bin/mono/StackExchange.Redis.dll -target:library -unsafe+ -o+ -r:System.IO.Compression.dll
echo -e "Building BasicTest.exe ..." echo -e "Building BasicTest.exe ..."
mcs BasicTest/Program.cs -out:BasicTest/bin/mono/BasicTest.exe -target:exe -o+ -r:StackExchange.Redis/bin/mono/StackExchange.Redis.dll mcs BasicTest/Program.cs -out:BasicTest/bin/mono/BasicTest.exe -target:exe -o+ -r:StackExchange.Redis/bin/mono/StackExchange.Redis.dll
cp StackExchange.Redis/bin/mono/*.* BasicTest/bin/mono/ cp StackExchange.Redis/bin/mono/*.* BasicTest/bin/mono/
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
@md StackExchange.Redis\bin\mono 1>nul 2>nul @md StackExchange.Redis\bin\mono 1>nul 2>nul
@md BasicTest\bin\mono 1>nul 2>nul @md BasicTest\bin\mono 1>nul 2>nul
@echo Building StackExchange.Redis.dll ... @echo Building StackExchange.Redis.dll ...
@call mcs -recurse:StackExchange.Redis\*.cs -out:StackExchange.Redis\bin\mono\StackExchange.Redis.dll -target:library -unsafe+ -o+ -r:System.IO.Compression.dll -d:MONO @call mcs -recurse:StackExchange.Redis\*.cs -out:StackExchange.Redis\bin\mono\StackExchange.Redis.dll -target:library -unsafe+ -o+ -r:System.IO.Compression.dll
@echo Building BasicTest.exe ... @echo Building BasicTest.exe ...
@call mcs BasicTest\Program.cs -out:BasicTest\bin\mono\BasicTest.exe -target:exe -o+ -r:StackExchange.Redis\bin\mono\StackExchange.Redis.dll @call mcs BasicTest\Program.cs -out:BasicTest\bin\mono\BasicTest.exe -target:exe -o+ -r:StackExchange.Redis\bin\mono\StackExchange.Redis.dll
@copy StackExchange.Redis\bin\mono\*.* BasicTest\bin\mono > nul @copy StackExchange.Redis\bin\mono\*.* BasicTest\bin\mono > nul
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment