From: ThorstenB Date: Thu, 18 Aug 2011 20:36:44 +0000 (+0200) Subject: #410: multiplay manager reporting errors X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=104507ad8bf0dad616ce0011925a72bbb0e4c5bf;p=flightgear.git #410: multiplay manager reporting errors receive on a non-blocking socket may return 0, which does not indicate an error - and does not mean "errno" was upated. So do not check "errno", errors there belong to calls elsewhere... Error message apparently triggered constantly with FG2.4.0 on Windows. --- diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index 40a9c438a..d6be380da 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -849,16 +849,24 @@ FGMultiplayMgr::update(double dt) // packet waiting to be processed. ////////////////////////////////////////////////// simgear::IPAddress SenderAddress; - bytes = mSocket->recvfrom(msgBuf.Msg, sizeof(msgBuf.Msg), 0, + int RecvStatus = mSocket->recvfrom(msgBuf.Msg, sizeof(msgBuf.Msg), 0, &SenderAddress); ////////////////////////////////////////////////// // no Data received ////////////////////////////////////////////////// - if (bytes <= 0) { + if (RecvStatus == 0) + break; + // socket error reported? + if (RecvStatus < 0) + { + // errno isn't thread-safe - so only check its value when + // socket return status < 0 really indicates a failure. if (errno != EAGAIN && errno != 0) // MSVC output "NoError" otherwise perror("FGMultiplayMgr::MP_ProcessData"); break; } + // status is positive: bytes received + bytes = (ssize_t) RecvStatus; if (bytes <= static_cast(sizeof(T_MsgHdr))) { SG_LOG( SG_NETWORK, SG_DEBUG, "FGMultiplayMgr::MP_ProcessData - " << "received message with insufficient data" );