Topic: [BUG] sendto errors aren't handled properly
Hello,
I've found another bug in the network stack which lead to a corruption
in the game source.
The sendto function doesnt report the exact error on it's own. It returns
just -1 in error case. A further pull on the global errno variable is required
on unix systems in this case.
The teal corruption happens because the server doesnt report the client
lose properly. Thus the game mode thinks the client is still online even if
it is not the case. Thuse if a new client try connect on that socket, a double
allocation on that client ID occurs in the game mode source whichs leads to
a assert and after that the server will shutdown itself.
The patch submitted here fixes this issue by recognizing the error properly
and the function conn_flush in e_network_conn.c will set the connection into
an error state which lead into a clean disconnect of the client and will free
the clientID.
This patch has been tested on unix only and i'm pretty sure it will compile only
on unix systems.
This patch should fix the issue. Due to the nature of the bug I can't really test it.