Emscripten, removed more network hacks, Emscripten bug 12996 is fixed in Emscripten 2.0.20
This commit is contained in:
@@ -166,29 +166,6 @@ typedef unsigned long in_addr_t;
|
|||||||
|
|
||||||
#endif /* OS/2 */
|
#endif /* OS/2 */
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
/**
|
|
||||||
* Emscripten doesn't set 'addrlen' for accept(), getsockname(), getpeername()
|
|
||||||
* and recvfrom(), which confuses other functions and causes them to crash.
|
|
||||||
* This function needs to be called after these four functions to make sure
|
|
||||||
* 'addrlen' is patched up.
|
|
||||||
*
|
|
||||||
* https://github.com/emscripten-core/emscripten/issues/12996
|
|
||||||
*
|
|
||||||
* @param address The address returned by those four functions.
|
|
||||||
* @return The correct value for addrlen.
|
|
||||||
*/
|
|
||||||
static inline socklen_t FixAddrLenForEmscripten(struct sockaddr_storage &address)
|
|
||||||
{
|
|
||||||
switch (address.ss_family) {
|
|
||||||
case AF_INET6: return sizeof(struct sockaddr_in6);
|
|
||||||
case AF_INET: return sizeof(struct sockaddr_in);
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
bool SetNonBlocking(SOCKET d);
|
bool SetNonBlocking(SOCKET d);
|
||||||
bool SetNoDelay(SOCKET d);
|
bool SetNoDelay(SOCKET d);
|
||||||
NetworkError GetSocketError(SOCKET d);
|
NetworkError GetSocketError(SOCKET d);
|
||||||
|
|||||||
@@ -42,9 +42,6 @@ public:
|
|||||||
socklen_t sin_len = sizeof(sin);
|
socklen_t sin_len = sizeof(sin);
|
||||||
SOCKET s = accept(ls, (struct sockaddr*)&sin, &sin_len);
|
SOCKET s = accept(ls, (struct sockaddr*)&sin, &sin_len);
|
||||||
if (s == INVALID_SOCKET) return;
|
if (s == INVALID_SOCKET) return;
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
sin_len = FixAddrLenForEmscripten(sin);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SetNonBlocking(s); // XXX error handling?
|
SetNonBlocking(s); // XXX error handling?
|
||||||
|
|
||||||
|
|||||||
@@ -130,9 +130,6 @@ void NetworkUDPSocketHandler::ReceivePackets()
|
|||||||
/* Did we get the bytes for the base header of the packet? */
|
/* Did we get the bytes for the base header of the packet? */
|
||||||
if (nbytes <= 0) break; // No data, i.e. no packet
|
if (nbytes <= 0) break; // No data, i.e. no packet
|
||||||
if (nbytes <= 2) continue; // Invalid data; try next packet
|
if (nbytes <= 2) continue; // Invalid data; try next packet
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
client_len = FixAddrLenForEmscripten(client_addr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NetworkAddress address(client_addr, client_len);
|
NetworkAddress address(client_addr, client_len);
|
||||||
p.PrepareToRead();
|
p.PrepareToRead();
|
||||||
|
|||||||
@@ -41,10 +41,6 @@
|
|||||||
|
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
#ifdef __EMSCRIPTEN__
|
|
||||||
# include <emscripten.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void ShowNetworkStartServerWindow();
|
static void ShowNetworkStartServerWindow();
|
||||||
static void ShowNetworkLobbyWindow(NetworkGameList *ngl);
|
static void ShowNetworkLobbyWindow(NetworkGameList *ngl);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user