Commit 9d47d6d
committed
Move cs_vSend lock into SocketSendData
SocketSendData requires cs_vSend to be locked, but it places this
responsibility with the caller. This is unnecessary, unclear, and has
caused us to accidentally add RecordBytesSent under the lock.
This commit fixes both problems.
Justification is needed in the case of PushMessage. It is ok that we
let go of cs_vSend for a moment before locking it again and calling
SocketSendData. In the case where optimistic_send == false, this lock
is let go of for a long time between adding messages to vSendMsg and the
call to SocketSendData (in SocketHandler). As corrected in the comment
change, optimistic_send represents whether vSendMsg *was* empty, not
*is* empty (as, of course, we've just added to it).
If SocketHandler grabs cs_vSend in the middle then SocketSendData will
be empty when we call it in PushMessage. As suggested by the "if
(bytes_sent)" check, this is fine.1 parent 92897d4 commit 9d47d6d
1 file changed
+11
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
750 | | - | |
| 750 | + | |
751 | 751 | | |
| 752 | + | |
752 | 753 | | |
753 | 754 | | |
754 | 755 | | |
| |||
1445 | 1446 | | |
1446 | 1447 | | |
1447 | 1448 | | |
1448 | | - | |
1449 | | - | |
1450 | | - | |
1451 | | - | |
1452 | | - | |
| 1449 | + | |
| 1450 | + | |
1453 | 1451 | | |
1454 | 1452 | | |
1455 | 1453 | | |
| |||
2821 | 2819 | | |
2822 | 2820 | | |
2823 | 2821 | | |
2824 | | - | |
| 2822 | + | |
2825 | 2823 | | |
2826 | 2824 | | |
2827 | | - | |
| 2825 | + | |
2828 | 2826 | | |
2829 | 2827 | | |
2830 | 2828 | | |
| |||
2837 | 2835 | | |
2838 | 2836 | | |
2839 | 2837 | | |
2840 | | - | |
2841 | | - | |
2842 | | - | |
2843 | | - | |
2844 | | - | |
2845 | 2838 | | |
2846 | | - | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
2847 | 2844 | | |
2848 | 2845 | | |
2849 | 2846 | | |
| |||
0 commit comments