Author: ilor
Date: Mon May 18 17:55:12 2009
New Revision: 35736
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35736&view=rev
Log:
Fix a networking problem when trying to send data to a disconnected socket
According to SDL docs, SDLNet_TCP_Send is blocking and if the returned
nubmer of bytes sent is less than expected, it's an error. Previous code
could trigger an infinite loop with the function returning zero and our
loop trying to send again and again.
Modified:
branches/1.6/src/network_worker.cpp
Modified: branches/1.6/src/network_worker.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/network_worker.cpp?rev=35736&r1=35735&r2=35736&view=diff
==============================================================================
--- branches/1.6/src/network_worker.cpp (original)
+++ branches/1.6/src/network_worker.cpp Mon May 18 17:55:12 2009
@@ -406,7 +406,11 @@
}
send_len = static_cast<int>(size - upto);
const int res = SDLNet_TCP_Send(sock, &buf[upto],send_len);
-
+ if (res < send_len) {
+ // according to
http://www.libsdl.org/cgi/docwiki.cgi/SDLNet_TCP_Send
+ // if the return value is less than len, it's an error
+ return SOCKET_ERRORED;
+ }
if( res == send_len) {
if (!raw_data_only)
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits