mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
* BeginConnect complete to early when not using callback. The following commit, https://github.com/mono/mono/commit/068e8fe0424806753d7ab72a7b9bf0e54b58408b#diff-33b28a9dc0b8032650ed77213481a99f changed the way we do DNS resolve in BeginConnect using host name. Instead of doing a blocking DNS resolve, it switched to an async DNS resolve, followed by an async connect. The returned IAsyncResult was just representing the completion of the DNS resolve task and not the underlying connect. It also turns out that part of doing EndConnect, we did some validation of the used IAsyncResult making sure it was an instance of SocketAsyncResult, meaning that if EndConnect was called on the returned IAsyncResult from BeginConnect, EndConnect would throw and exception. NOTE, this only happens if you use pattern like this: var result = sock.BeginConnect (hostName, port, null, null); result.AsyncWaitHandle.WaitOne (2000); sock.EndConnect (result); It did not happened if you used callbacks, since then EndConnect would be called as part of callback and that IAsyncResult was of correct type, or if you did a BeginConnect with an EndPoint or IPAddress[] since that won't trigger the DNS resolve. Fix is to make sure we hand out the SocketAsyncResult instance that will be used in our internal connect calls from BeginConnect. We also make sure, we chain the DNS resolve task together with a task doing the async connect (using the same SocketAsyncResult instance). This will make sure the IAsyncResult returned from BeginConnect is the same one as used in internal connect call, so it will only complete when the connect call completes. * Adding test for BeginConnect using host name. * Bump API snapshot submodule