Semantic change to ISteamNetworkingSockets::SendMessages

Added bDeleteFailedMessages.  By setting this to false, the caller has
the opportunity to retry failed messages, which is an especially
reasonably thing to do in the case of the send buffer being full.

Also clarified expected (and enforced) expected behaviour on
how subsequent messages on a connection are handled after a failed
message send.  Previously, there was a fairly significant bug, which is
that we would coutinue to try to send messages, which is bad because
it can break fundamental guarantees about message delivery order.  Now,
we will always stop at the first failure.

This fixes issue #317
This commit is contained in:
Fletcher Dunn
2026-04-28 10:03:33 -07:00
parent 3b03992c80
commit 4fbfe83ef4
6 changed files with 69 additions and 28 deletions
+9 -9
View File
@@ -717,7 +717,7 @@ void Test_lane_quick_queueanddrain()
}
}
assert( idxMsg == k_nTotalMsg );
SteamNetworkingSockets()->SendMessages( idxMsg, pMessages, nullptr );
SteamNetworkingSockets()->SendMessages( idxMsg, pMessages, nullptr, true );
}
// Remember when we sent all the messages
@@ -785,7 +785,7 @@ void Test_lane_quick_queueanddrain()
pMsg->m_idxLane = (uint16)idxLane;
pMessages[idxLane] = pMsg;
}
SteamNetworkingSockets()->SendMessages( k_nLanes, pMessages, nullptr );
SteamNetworkingSockets()->SendMessages( k_nLanes, pMessages, nullptr, true );
}
int cbLaneReceived[k_nLanes] = {};
@@ -959,7 +959,7 @@ void Test_lane_quick_priority_and_background()
*(SteamNetworkingMicroseconds *)pMsg->m_pData = usecNow;
int64 nMsgNum;
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum );
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum, true );
++nMsgSent[k_LaneBackground];
assert( nMsgNum == nMsgSent[k_LaneBackground] );
}
@@ -977,7 +977,7 @@ void Test_lane_quick_priority_and_background()
*(SteamNetworkingMicroseconds *)pMsg->m_pData = usecNow;
int64 nMsgNum;
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum );
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum, true );
++nMsgSent[k_LaneUrgent];
assert( nMsgNum == nMsgSent[k_LaneUrgent] );
@@ -1003,7 +1003,7 @@ void Test_lane_quick_priority_and_background()
*(SteamNetworkingMicroseconds *)pMsg->m_pData = usecNow;
int64 nMsgNum;
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum );
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum, true );
++nMsgSent[k_LaneGameplay];
assert( nMsgNum == nMsgSent[k_LaneGameplay] );
}
@@ -1018,7 +1018,7 @@ void Test_lane_quick_priority_and_background()
pMsg->m_nFlags = std::uniform_int_distribution<>( 0, 100 )( g_rand ) < 30 ? k_nSteamNetworkingSend_ReliableNoNagle : k_nSteamNetworkingSend_UnreliableNoNagle;
int64 nMsgNum;
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum );
SteamNetworkingSockets()->SendMessages( 1, &pMsg, &nMsgNum, true );
assert( nMsgNum >= 0 );
}
@@ -1134,7 +1134,7 @@ void Test_pipe()
void *pSendData = pSendMsg->m_pData;
int64 nMsgNum;
SteamNetworkingSockets()->SendMessages( 1, &pSendMsg, &nMsgNum );
SteamNetworkingSockets()->SendMessages( 1, &pSendMsg, &nMsgNum, true );
assert( nMsgNum > 0 );
SteamNetworkingMessage_t *pRecvMsg = nullptr;
@@ -1153,7 +1153,7 @@ void Test_pipe()
pSendMsg->m_nFlags = k_nSteamNetworkingSend_Reliable;
int64 nMsgNum;
SteamNetworkingSockets()->SendMessages( 1, &pSendMsg, &nMsgNum );
SteamNetworkingSockets()->SendMessages( 1, &pSendMsg, &nMsgNum, true );
assert( nMsgNum > 0 );
SteamNetworkingMessage_t *pRecvMsg = nullptr;
@@ -1265,7 +1265,7 @@ void Test_netloopback_throughput()
// Don't bother initializing the body
int64 nMsgNumberOrResult;
SteamNetworkingSockets()->SendMessages( 1, &pSendMsg, &nMsgNumberOrResult );
SteamNetworkingSockets()->SendMessages( 1, &pSendMsg, &nMsgNumberOrResult, true );
if ( nMsgNumberOrResult == -k_EResultLimitExceeded )
{
TEST_Printf( "SendMessage returned limit exceeded trying to queue %d + %d = %d\n", serverStatus.m_cbPendingReliable, cbSendMsg, serverStatus.m_cbPendingReliable + cbSendMsg );