Repository navigation
Commit 0cef024
committed
Mark a removed
## Motivation and Context
Removing a listen stream after a failed write or a finished keepalive did not mark its entry closed,
as transport close does, so a delivery or keepalive that had taken the entry before the removal still
wrote to the stream being closed.
That write failed against the closing stream and was reported as a failed delivery.
Removal now marks the entry closed, and those writes skip it under the stream's write mutex.
The flag is set without taking the write mutex, which must never be taken inside the registry lock;
the close that follows a removal takes the write mutex outside the registry lock, so a write already past its check
lands before the stream closes, and every later one sees the flag.
## How Has This Been Tested?
A new test in `test/mcp/server/transports/streamable_http_transport_test.rb` delivers to an entry taken
before its removal and checks that nothing is written. Against the previous library the notification
is written to the removed stream.
The keepalive failure test also checks that the entry a failed ping removes is marked closed.
Another blocks a delivery inside its write, removes the entry from a second thread, and checks that the stream
is closed only after the write has completed.
## Breaking Changes
None.subscriptions/listen stream closed1 parent 402cb56 commit 0cef024
2 files changed
Lines changed: 100 additions & 11 deletions
File tree
- lib/mcp/server/transports
- test/mcp/server/transports
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1093 | 1093 | | |
1094 | 1094 | | |
1095 | 1095 | | |
1096 | | - | |
| 1096 | + | |
1097 | 1097 | | |
1098 | 1098 | | |
1099 | 1099 | | |
1100 | | - | |
| 1100 | + | |
1101 | 1101 | | |
1102 | 1102 | | |
1103 | 1103 | | |
| |||
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
1141 | | - | |
1142 | | - | |
1143 | | - | |
1144 | | - | |
1145 | | - | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
1146 | 1144 | | |
1147 | 1145 | | |
1148 | 1146 | | |
| |||
1254 | 1252 | | |
1255 | 1253 | | |
1256 | 1254 | | |
1257 | | - | |
| 1255 | + | |
1258 | 1256 | | |
1259 | 1257 | | |
1260 | 1258 | | |
1261 | 1259 | | |
1262 | 1260 | | |
1263 | 1261 | | |
1264 | 1262 | | |
1265 | | - | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1266 | 1271 | | |
1267 | 1272 | | |
1268 | 1273 | | |
1269 | 1274 | | |
1270 | 1275 | | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1271 | 1284 | | |
1272 | 1285 | | |
1273 | 1286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6876 | 6876 | | |
6877 | 6877 | | |
6878 | 6878 | | |
| 6879 | + | |
| 6880 | + | |
| 6881 | + | |
| 6882 | + | |
| 6883 | + | |
| 6884 | + | |
| 6885 | + | |
| 6886 | + | |
| 6887 | + | |
| 6888 | + | |
| 6889 | + | |
| 6890 | + | |
| 6891 | + | |
| 6892 | + | |
| 6893 | + | |
| 6894 | + | |
| 6895 | + | |
| 6896 | + | |
| 6897 | + | |
| 6898 | + | |
| 6899 | + | |
| 6900 | + | |
| 6901 | + | |
| 6902 | + | |
| 6903 | + | |
| 6904 | + | |
| 6905 | + | |
| 6906 | + | |
| 6907 | + | |
| 6908 | + | |
| 6909 | + | |
| 6910 | + | |
| 6911 | + | |
| 6912 | + | |
| 6913 | + | |
| 6914 | + | |
| 6915 | + | |
| 6916 | + | |
| 6917 | + | |
| 6918 | + | |
| 6919 | + | |
| 6920 | + | |
| 6921 | + | |
| 6922 | + | |
| 6923 | + | |
| 6924 | + | |
| 6925 | + | |
| 6926 | + | |
| 6927 | + | |
| 6928 | + | |
| 6929 | + | |
| 6930 | + | |
| 6931 | + | |
| 6932 | + | |
| 6933 | + | |
| 6934 | + | |
| 6935 | + | |
| 6936 | + | |
| 6937 | + | |
| 6938 | + | |
| 6939 | + | |
| 6940 | + | |
| 6941 | + | |
| 6942 | + | |
| 6943 | + | |
| 6944 | + | |
| 6945 | + | |
| 6946 | + | |
| 6947 | + | |
| 6948 | + | |
6879 | 6949 | | |
6880 | 6950 | | |
6881 | 6951 | | |
| |||
6902 | 6972 | | |
6903 | 6973 | | |
6904 | 6974 | | |
| 6975 | + | |
6905 | 6976 | | |
6906 | 6977 | | |
| 6978 | + | |
6907 | 6979 | | |
6908 | | - | |
6909 | | - | |
| 6980 | + | |
| 6981 | + | |
6910 | 6982 | | |
6911 | 6983 | | |
6912 | 6984 | | |
6913 | 6985 | | |
| 6986 | + | |
| 6987 | + | |
| 6988 | + | |
| 6989 | + | |
6914 | 6990 | | |
6915 | 6991 | | |
6916 | 6992 | | |
| |||
0 commit comments