Commit d6e91e1
committed
mp.input: remove and mitigate race conditions from
This commit ensures that `input.terminate()` can only close input
requests made by the same script, and adds a new
argument to the input.terminate()` function
which allows specifying the specific input request to cancel.
Previosuly, there was no way to guarantee that the input request being
terminated was the one intended; the asynchronous nature of the API
meant that it was always possible (though unlikely) that another client
may have activated its own input request while the termination request
was in transit.
This commit removes the race condition between different scripts calling
`input.terminate()` by sending the script name alongside the termination
message, and provides a backwards compatible way to terminate specific
requests, which removes the race condition for different input requests
within the same script.
Now, `input.get()` and `input.select()` return an opaque id object,
which can be optionally passed into `input.terminate()` to specify which
input request should be terminated.
One advantage of this approach is that it is backwards compatible; a
script passing id values will work without issue on older versions of
mpv as `input.terminate()` previously ignored all of its arguments.
This approach is based on the behaviour of `mp.command_native_async` and
`mp.abort_async_command`.input.terminate()
1 parent 103df92 commit d6e91e1
File tree
5 files changed
+69
-11
lines changed- DOCS/man
- player
- javascript
- lua
5 files changed
+69
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
978 | | - | |
979 | | - | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
980 | 1014 | | |
981 | 1015 | | |
982 | 1016 | | |
| |||
1027 | 1061 | | |
1028 | 1062 | | |
1029 | 1063 | | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
1030 | 1067 | | |
1031 | 1068 | | |
1032 | 1069 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
687 | 691 | | |
688 | | - | |
689 | | - | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
690 | 697 | | |
691 | 698 | | |
692 | 699 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1659 | 1659 | | |
1660 | 1660 | | |
1661 | 1661 | | |
1662 | | - | |
1663 | | - | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
1664 | 1671 | | |
1665 | 1672 | | |
1666 | 1673 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
68 | | - | |
69 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| |||
0 commit comments