Commit b1c0e74
Fix race condition in http reverse proxy for websockets
When a WebSocket connection is established through the lws http reverse proxy, the
LWS_CALLBACK_ESTABLISHED callback was being called immediately. Under load, this
could lead to a race condition where the user code would write to the socket before
the connection was fully established on the other side of the proxy, causing the
connection to be dropped.
This patch fixes the issue by deferring the LWS_CALLBACK_ESTABLISHED
callback for proxied WebSocket connections. An lws_sul is added in order to
ensure the caller completed setting up the proxy connection before we try
to do anything with it.1 parent 9e9367b commit b1c0e74
3 files changed
Lines changed: 38 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
672 | 675 | | |
673 | 676 | | |
674 | 677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
27 | 46 | | |
28 | 47 | | |
29 | 48 | | |
| |||
861 | 880 | | |
862 | 881 | | |
863 | 882 | | |
864 | | - | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
865 | 892 | | |
866 | 893 | | |
867 | 894 | | |
| |||
871 | 898 | | |
872 | 899 | | |
873 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
874 | 905 | | |
875 | 906 | | |
876 | 907 | | |
| |||
0 commit comments