diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2019-12-05 20:08:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-05 20:08:26 +0300 |
commit | 269d509e42c3a359746f017d46c57c44a3cf3b39 (patch) | |
tree | 3755932cd169d2185167abbee10ee28a41b56ba0 /mcs/class/Mono.Messaging.RabbitMQ | |
parent | e67673fac85d13882256893d1b61c08ca0fc13c6 (diff) |
Remove DNS lookups of the local hostname in tests (#18059)
This allows us to workaround issues we currently have in the macOS bot network where DNS lookup of the hostname fails.
Diffstat (limited to 'mcs/class/Mono.Messaging.RabbitMQ')
-rw-r--r-- | mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessagingProvider.cs | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessagingProvider.cs b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessagingProvider.cs index 41644a3505a..020520969aa 100644 --- a/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessagingProvider.cs +++ b/mcs/class/Mono.Messaging.RabbitMQ/Mono.Messaging.RabbitMQ/RabbitMQMessagingProvider.cs @@ -43,33 +43,16 @@ namespace Mono.Messaging.RabbitMQ { public class RabbitMQMessagingProvider : IMessagingProvider { private int txCounter = 0; - private readonly uint localIp; + private readonly Guid localId; private readonly MessagingContextPool contextPool; public RabbitMQMessagingProvider () { - localIp = GetLocalIP (); + localId = Guid.NewGuid (); contextPool = new MessagingContextPool (new MessageFactory (this), CreateConnection); } - private static uint GetLocalIP () - { - String strHostName = Dns.GetHostName (); - IPHostEntry ipEntry = Dns.GetHostByName (strHostName); - foreach (IPAddress ip in ipEntry.AddressList) { - if (AddressFamily.InterNetwork == ip.AddressFamily) { - byte[] addr = ip.GetAddressBytes (); - uint localIP = 0; - for (int i = 0; i < 4 && i < addr.Length; i++) { - localIP += (uint) (addr[i] << 8 * (3 - i)); - } - return localIP; - } - } - return 0; - } - public IMessage CreateMessage () { return new MessageBase (); @@ -78,7 +61,7 @@ namespace Mono.Messaging.RabbitMQ { public IMessageQueueTransaction CreateMessageQueueTransaction () { Interlocked.Increment (ref txCounter); - string txId = localIp.ToString () + txCounter.ToString (); + string txId = localId.ToString () + "_" + txCounter.ToString (); return new RabbitMQMessageQueueTransaction (txId, contextPool); } |