Dela via


3.1.5.9 Managing Credits Prior to Sending

After a successful negotiation, and prior to sending a message to the peer, the following credit management is performed for both send and receive limits on the specified Connection.

If Connection.ReceiveCredits is nonzero and greater than or equal to Connection.ReceiveCreditTarget, then sufficient credits are already present and a value of zero SHOULD be returned. The value of Connection.ReceiveCreditTarget MAY be reduced.

If Connection.ReceiveCredits is zero, or if Connection.SendCredits is one and the Connection.SendQueue is not empty, the sender MUST allocate and post at least one receive of size Connection.MaxReceiveSize and MUST increment Connection.ReceiveCredits by the number allocated and posted. If no receives are posted, the processing MUST return a value of zero to indicate to the caller that no Send message can be currently performed.

If Connection.ReceiveCreditTarget is greater than Connection.ReceiveCredits and Connection.ReceiveCredits is less than Connection.ReceiveCreditMax, the sender SHOULD attempt to increase the credits available to the peer on the connection. In an implementation-specific manner, post a number of receive operations to the Connection, each of size Connection.MaxReceiveSize, and of count at least one and less than or equal to the smaller of Connection.ReceiveCreditTarget or Connection.ReceiveCreditMax. For each such receive successfully posted, the value of Connection.ReceiveCredits MUST be incremented by one.

The processing MUST return the number of receive credits successfully added to the connection.