|
39 | 39 | dirty_process_register/1, dirty_process_trace/1, |
40 | 40 | code_purge/1, literal_area/1, dirty_nif_send_traced/1, |
41 | 41 | nif_whereis/1, nif_whereis_parallel/1, nif_whereis_proxy/1, |
| 42 | + dirty_port_command/1, |
42 | 43 | set_halt_options_from_nif/1, |
43 | 44 | delay_halt/1, |
44 | 45 | delay_halt_old_code/1, |
|
65 | 66 | dirty_heap_access_nif/1, |
66 | 67 | whereis_term/2, |
67 | 68 | whereis_send/3, |
| 69 | + dirty_port_command/2, |
68 | 70 | dirty_terminating_literal_access/2, |
69 | 71 | delay_halt_normal/3, |
70 | 72 | delay_halt_io_bound/3, |
@@ -94,6 +96,7 @@ all() -> |
94 | 96 | dirty_nif_send_traced, |
95 | 97 | nif_whereis, |
96 | 98 | nif_whereis_parallel, |
| 99 | + dirty_port_command, |
97 | 100 | {group, halt_normal}, |
98 | 101 | {group, halt_dirty_cpu}, |
99 | 102 | {group, halt_dirty_io}, |
@@ -1048,6 +1051,21 @@ nif_whereis(Config) when is_list(Config) -> |
1048 | 1051 | false = whereis_term(port, RegName), |
1049 | 1052 | ok. |
1050 | 1053 |
|
| 1054 | +%% enif_port_command() from a dirty scheduler must return false, not crash, |
| 1055 | +%% when the port is no longer alive (OTP-11221). |
| 1056 | +dirty_port_command(Config) when is_list(Config) -> |
| 1057 | + erl_ddll:try_load(?config(data_dir, Config), echo_drv, []), |
| 1058 | + |
| 1059 | + Port = open_port({spawn, echo_drv}, [eof]), |
| 1060 | + Msg = ?MODULE_STRING " dirty port command\n", |
| 1061 | + ok = dirty_port_command(Port, Msg), |
| 1062 | + ok = receive {Port, {data, Msg}} -> ok after 1000 -> ct:fail(timeout) end, |
| 1063 | + |
| 1064 | + %% Closed port: lookup returns NULL on the dirty path. |
| 1065 | + port_close(Port), |
| 1066 | + false = dirty_port_command(Port, Msg), |
| 1067 | + ok. |
| 1068 | + |
1051 | 1069 | nif_whereis_parallel(Config) when is_list(Config) -> |
1052 | 1070 |
|
1053 | 1071 | %% try to be at least a little asymmetric |
@@ -1179,6 +1197,7 @@ dirty_sleeper(_) -> ?nif_stub. |
1179 | 1197 | dirty_heap_access_nif(_) -> ?nif_stub. |
1180 | 1198 | whereis_term(_Type,_Name) -> ?nif_stub. |
1181 | 1199 | whereis_send(_Type,_Name,_Msg) -> ?nif_stub. |
| 1200 | +dirty_port_command(_Port,_Msg) -> ?nif_stub. |
1182 | 1201 | dirty_terminating_literal_access(_Me, _Literal) -> ?nif_stub. |
1183 | 1202 | delay_halt_normal(_Pid, _FileName, _Delay) -> ?nif_stub. |
1184 | 1203 | delay_halt_io_bound(_Pid, _FileName, _Delay) -> ?nif_stub. |
|
0 commit comments