Allow override for translation of WSA errors for analytics/tracking/experimentation.
Summary:
One of the top crashes for our desktop app happens when WSAECONNRESET is returned from the read/recv call on a socket pair setup on INADDR_LOOPBACK. We have not been able to repro this locally in spite of trying different network configurations, enabling/disabling adapters, standby/resume, installing various VPN software and actively changing connections etc.
There are numerous samples/explanations/myths around why (e.g. ancient KB 263823), which should not really apply to loopback, and potential mitigations SIO_UDP_CONNRESET that also seem to not always work, e.g. https://microsoft.public.win32.programmer.networks.narkive.com/TOtpcAWF/sio-udp-connreset-control-code-doesn-t-seem-to-be-working
There are a lot of examples on github simply ignoring the WSAECONNRESET from recv - and most damningly in the OS code in the leaked Windows sources (Windows Server 2003), e.g.
https://github.com/tongzx/nt5src/blob/
daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/net/dhcp/client/dhcp/dhcpmsg.c#L524
> // ignore spurious connection reset errors (???)
https://github.com/tongzx/nt5src/blob/
daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/net/tapi/litesabr/filters/rrcm/rtp/rtprecv.cpp#L167
> // Don't care to do anything with void packets received resulting
> // of the WSAECONNRESET (nobody listening to us) or
https://github.com/tongzx/nt5src/blob/
daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/ds/dns/server/server/udp.c#L30
> // Limit retries to protect against WSAECONNRESET nonsense
https://github.com/tongzx/nt5src/blob/
daad8a087a4e75422ec96b7911f1df4669989611/Source/XPSP1/NT/inetcore/wininet/apdetect/protocol.cxx#L1299
> if( WSAECONNRESET != Error ) break; // ignore possibly spurious conn-resets..
From GitHub:
https://github.com/meqif/rust-utp/pull/24
> On Windows, the recv_from operation on the UDP socket may return the
> following errors, which are expected and should be ignored: 10054 (WSAECONNRESET)
https://github.com/zhuyanxie/LangStack/blob/
2d1b23cc725898c49f5f3f58f19310881cad273d/cpp/include/Base/SocketHeader.h#L43
> #define IS_RECVFROM_IGNORABLE(code) ((code==WSAEWOULDBLOCK)||(code==WSAECONNRESET))
https://github.com/tankiJong/morph-engine/blob/master/Engine/Net/Socket.hpp#L44
> #define LOG_FATAL_SOCK_ERROR() {
> if (re != WSAEWOULDBLOCK && re != WSAEMSGSIZE && re != WSAECONNRESET) {
https://github.com/mysql/mysql-server/blob/8.0/plugin/innodb_memcached/daemon_memcached/win32/win32.h#L166
> if (error == WSAECONNRESET) {
> return 0;
etc.
We are hoping to experiment with ignoring WSAECONNRESET and send analytics, e.g. to ensure doing so does not result in spinning and other errors etc.
This hook will provide the context for the necessary analytics/experimentation to come up with an appropriate mitigation.
Differential Revision:
D40997259
fbshipit-source-id:
236341a960b3b252d1bed43a2d57a39b51a8fd20